PHP - Echo Var In Bold Or Strong
hi. i want to echo part of my code in bold or strong. can anyone help please?
echo "<table border='0'> <tr> <th></th> </tr>"; $row = mysql_fetch_array($result) or die(mysql_error()); echo "<tr>"; echo "<td>" . $row['question']. " ". $row['answer']; "</td>"; echo "<tr>"; echo "</table>"; I want to bold the $row question part. Hope someone knows. thanks Similar TutorialsHi,
Total PHP noob, obviously.
I want some form submission results to be in bold text. So I have:
$open = echo htmlentities("<strong>"); $close = echo htmlentities("</strong>"); $message .= 'Cushion Refilling Service: ' . $open . $_POST['cushion-refilling'] . $close . "\n\n";How should I be doing this? Thanks Richard This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=350611.0 Let's try something simple: I have a form that retrieves data from database and organizes the numbers inside of a table (sometimes in an input box). Is there a simple code so that VALUES > zero will be in BOLD font? OK, have no idea what's going on... I've done this a million times... why wont this output!?? I must have a major brain meltdown and dont know it yet!!! Code: [Select] <?php // this echoes just fine: echo $_POST['testfield']; // but this wont echo: echo if (isset($_POST['testfield'])) { $_POST['testfield'] = $test; } echo $test; /// or even this DOESNT echo either!: $_POST['testfield'] = $test; echo $test; ?> I have a text box for users to enter new text in. The box also contains text that is determined by a variable that is created from a mysql query and some other added text. I want to make a portion of the added text within the textbox bold. How would I achieve this with php? Code: [Select] <?php result = mysql_query("SELECT `something` FROM `table` WHERE `this` = '$that'"); row = mysql_fetch_row($result); $variable = $row[0]; $text = "<strong>Here is the text that I want bold</strong> $variable"; echo "<textarea name=\"textbox\">"; echo "$text"; echo "</textarea> ?> Doing this gives me this result in the textbox: "<strong>Here is the text that I want bold</strong> This is what the variable text says." Any ideas? i am making a search engine to search my site and the code is going well but i don't know how to find your search within the results and put it in bold (like google does). I use a thing called http://simplehtmldom.sourceforge.net/ for getting the html of my website. Code: [Select] <?php include('simple_html_dom.php'); ?> <?php $s = $_GET["s"]; if ($s == null) echo "you have not searched for anything"; else echo "you searched for $s<hr>"; $urls[0] = 'http://url.com/'; $urls[1] = 'http://url2.com'; foreach ($urls as $url) { $html = file_get_html($url); strip_tags($html); preg_match("/<body>(.*)<\/body>/s", $html, $body); $htmls_split = split('<', $body[1]); foreach ($htmls_split as $line) { if (preg_match("/$s.*/", $line, $matches)) { echo "<p>$matches[0]"; } } } ?> I'm using the fairly simple below code to output a list of the latest articles, but I'm wanting (not sure if it's possible) to display the articles from the current day in bold so users recognise that they are new and the older ones non-bold. I've tried a few things, but they're not giving the desired results. Code: [Select] <?php $con = mysql_connect("localhost","xxx","xxx"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("xxx", $con); $result = mysql_query("SELECT * FROM `articles` WHERE `quotes` NOT LIKE '%yes%' ORDER BY `date` DESC limit 0,14"); echo "<table class='links' border='0' width='100%'>"; while($row = mysql_fetch_array($result)) { echo '<tr><td width="270" valign="top"><h4>» <a href="news/display/'.$row['id'].'">'.$row['title'].'</a></td><td width="40" valign="top"><span class="small">'.date("M d", strtotime($row['date'])).'</span></h4></td></tr>'; } mysql_close($con); ?> Cheers! I want a code to automatically make specific words within my content bold. For example, If the word "car" appears, make that word bold. Thanks Hi All, I'm trying to echo the response from an SLA query, the query works and returns the data when I test it on an SQL application.. but when I run it on my webpage it won't echo the result. Please help? <?php $mysqli = mysqli_connect("removed", "removed", "removed", "removed"); $sql = "SELECT posts.message FROM posts INNER JOIN threads ON posts.pid=threads.firstpost WHERE threads.firstpost='1'"; $result = mysqli_query($mysqli, $sql); echo {$result['message']}; ?> So I need to echo a row from my database with php, but where i need to echo is already inside an echo. This is my part of my code: $con = mysql_connect("$host","$username","$password"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("main", $con); $result = mysql_query("SELECT * FROM Vendor"); while($row = mysql_fetch_array($result)) { //I need to echo right here .................. but I get a blank page when I try this. Please Help. echo '<option value=$row['vendor_id']>'; echo $row['vendor_id']; echo '</option>'; } mysql_close($con); Result: A Blank page. Thanks in advance! I have a log system that allows 10 logs on each side(Left and right). I am trying to make it so that the left side has the 10 most recent logs, then the right as the next 10. Any ideas? Hi
I try to echo out random lines of a html file and want after submit password to whole content of the same html file. I have two Problems.
1st Problem When I echo out the random lines of the html file I don't get just the text but the code of the html file as well. I don't want that. I just want the text. How to do that?
for($x = 1;$x<=40;$x++) { $lines = file("$filename.html"); echo $lines[rand(0, count($lines)-1)]."<br>"; }I tried instead of "file("$filename.html");" "readfile("$filename.html");" But then I get the random lines plus the whole content. Is there anything else I can use instead of file so that I get the random lines of text without the html code?P.S file_get_contents doesn't work either have tried that one. 2nd Problem: As you could see in my first problem I have a file called $filename.html. After I submit the value of a password I want the whole content. But it is like the program did forget what $filename.html is. How can I make the program remember what $filename.html is? Or with other words how to get the whole content of the html file? My code: if($_POST['submitPasswordIT']){ if ($_POST['passIT']== $password ){ $my_file = file_get_contents("$filename.html"); echo $my_file; } else{ echo "You entered wrong password"; } }If the password isn't correct I get: You entered wrong password. If the password is correct I get nothing. I probably need to create a path to the file "$filename.html", but I don't know exactly how to do that. I want to echo this div below but only if there is more than one of these fields missing. How would I go about this? <?php //only echo all of this if one or more of these fields does not exists so....... if () { echo" <div id=\"items_todo\"> <h3>Members Info</h3><br/> <ul>"; if (empty($User['address_L1'])) { echo "<li><a href=\"#\">Update Address</a></li>";} elseif (empty($User['intro'])) {echo "<li><a href=\"#\">About You</a></li>";} elseif (empty($User['profile_image'])){echo "<li><a href=\"#\">Add Profile Image</a></li>";} elseif (empty($User['Nickname'])){echo "<li><a href=\"#\">Add A Nickname</a></li>";} echo"</ul> </div>"; } ?> How do I echo the day from the db? It just displays day and I want it to display the day that was set. <select name="date_of_birth" id="date_of_birth"> <option value="">Day</option> <?php $isset = isset($_POST['date_of_birth']); for($day = 1; $day <= 31; ++$day) { echo '<option'; if ($isset && $_POST['date_of_birth'] === $day) { echo ' selected="selected"'; } echo ">${day}</option>\n\t\t\t\t\t\t"; } ?> </select> Hi freaks, Yes im a noob... I have some data in a db that im echoing out, but the last row wont multiply? The rest works great... I have tried having the data as the following: 1.12 or 0.12 & I have tried having it as a var. Do I need to have a % in there somewhere? Im adding up all the data then I want to multiply by 12% (*$row['markup']) <?php echo $row['Stock1']*$row['qty']+$row['cutting']+$row['production']+$row['additional']+$row['pluscover']+$row['selfcover']*$row['markup'];?> any help would be appreciated. cuzzmunger. I saw that <?=$var?> instead of <?php echo $var; ?> can be used for echo, does it work on every server? Hi all, I have a page which simply pulls info from a database by id: <?php include ('connect.php'); $id = $_GET['id']; $query = mysql_query("SELECT * FROM JOBS WHERE id=$id"); if (!$query) { echo "Could not run query: " . mysql_error(); exit; } $row = mysql_fetch_row($query); { echo "<body><h3>" . $row[1]. "</h3>"; echo "<h4>" . $row[2] . "</h4>"; echo "<h4>" . $row[3] . "</h4>"; echo "<h5>Duties & Responsibilities:</h5><ul>"; echo "<li><strong>" . $row[4] . "</strong>" . $row[5] . "</li>"; echo "<li><strong>" . $row[6] . "</strong>" . $row[7] . "</li>"; echo "<li><strong>" . $row[8] . "</strong>" . $row[9] . "</li>"; echo "<li><strong>" . $row[10] . "</strong>" . $row[11] . "</li>"; } ?> However in some cases the rows in the database may only contain data upto row 6 for example, how would I go about coding this so that it only displays rows that exist. If row 6 exists then 7 always will too as the information is connected. I am manually added this stuff into phpmyadmin as I do not need a form as once it is complete then it will not need to be added to. Also row 8 and 9 may contain data but 6 and 7 may not Many Thanks Hi all I am trying to get the contents from an array using the below SQL query: $sql = mysql_query ("SELECT MAX (postage_world) FROM `basket` "); while ($row = mysql_fetch_array($sql)) { echo $row["id"]; echo $row["description"]; echo $row["postage_world"]; } I need the SQL query to find the highest value from the table and then echo out the results. The error I get is "Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given" Many thanks for your help! Code: [Select] <span class="hotspot" onmouseover="tooltip.show('User ID :');" onmouseout="tooltip.hide();"> i want to know how to echo this above code Code: [Select] <?php $statisctis=("SELECT date_liked , COUNT(site_id) AS num_site_id FROM `liked` WHERE date_liked < CURDATE() AND date_liked > CURDATE() - INTERVAL 1 WEEK AND site_id='45' GROUP BY date_liked"); $result1 = mysql_query ($statisctis) or die(mysql_error()); ?> in php admin i get result like this date_liked num_site_id 2011-11-28 10:00:29 1 2011-11-29 05:03:17 1 2011-11-30 04:51:37 1 how to echo this in my page? Here i get a COUNT number only Code: [Select] <?php $sum_datas = mysql_result($result1, 0); echo $sum_datas['date_liked']; ?> |