PHP - Making Td Value Bold
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? Similar TutorialsI 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? 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 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 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 want a code to automatically make specific words within my content bold. For example, If the word "car" appears, make that word bold. Thanks cud any1 tell me why this happens? when i run SOME of the php script using localhost, it says APACHE HTTP SERVER STOP WORKING Hi guys! new to forum and to coding. I have poured over the forums and lots of places for an answer. I am not sure if this is due to my thus far limited understanding or, nto a specific enough question was asked. Basically it was suggested to me to make a link on a site from this: Search our Catalog: It was asked that I tie a link to that text and make it sort of a button so that when clicked, it takes someone to our catalog. The site is built with Drupal 6 and uses Danland theme and and a WYSIWYG. WHen I open the gear to edit this section I see: "<P align=right><a href="https://catalog.ncpl.lib.oh.us/polaris/logon.aspx"> Access Library Account</a> - <a href="https://catalog.ncpl.lib.oh.us/polaris/patronaccount/selfregister.aspx?"> Get a Card</a> - <a href="http://catalog.ncpl.lib.oh.us/polaris/search/default.aspx">Search Catalog</a></P> <!-- // Start of Search form --> <script language="javascript"> String.prototype.trim = function() { return this.replace(/^\s*|\s*$/g,''); } function ProcessInput(e) { if (window.event) // IE keyNum = e.keyCode; else if (e.which) // Netscape/Firefox/Opera keyNum = e.which; if (keyNum == 13) { e.returnValue = false; e.cancelBubble = true; DoKeywordSearch('KW'); return false; } return true; } function DoKeywordSearch() { if (document.getElementById('textboxTerm').value.trim() != '') { var strURL = 'http://catalog.ncpl.lib.oh.us/polaris/search/searchresults.aspx?ctx=1.1033.0.0.1'; var strWindex = document.getElementById('Windex').value; var strTerm = escape(document.getElementById('textboxTerm').value); window.location = strURL + "&type=Keyword&limit=TOM=*&sort=PD_TI&Page=0&by=" + strWindex + "&term=" + strTerm; } else { alert('Please enter a search term'); document.getElementById('textboxTerm').focus(); } } </script> <noscript>JavaScript must be enabled for catalog!</noscript> <table border="0"> <tr> <td> <label for="search">Search our Catalog:</label> <input class="search" type=text id=textboxTerm size=30 onkeypress="return ProcessInput(event)" /> <select class="search" id="Windex"> <option value="KW" selected="selected"> Anywhere </option> <option value="SU"> Subject </option> <option value="TI"> Title </option> <option value="AU"> Author </option> <option value="KW&fic=1"> Fiction </option> <option value="KW&fic=0"> Nonfiction </option> </select> <input type="submit" class="button" value="Go!" name="submit" onclick="DoKeywordSearch()" /> </td> </tr> </table> <!--// End of Search form -->" My question is where would the code for the link go and is there a good resource i can use to figure out how to write it? Any help is greatly appreciated, thank you. Hey i'm just wanting to make a loop to loop members i do have a loop but im looking for a more better loop i need to loop my members in a table as spot: 1 spot: 2 spot: 3 spot 4 and if there more it puts in below the top for spots and so on $Members = mysql_query("SELECT * FROM users") or die(mysql_error()); $numRowsMembers = mysql_num_rows($Members); ?> <?php for($count = 1; $count <= $numRowsMembers; $count++) { $name = mysql_fetch_array($Members); ?> <td width="150" height="125"> <a href="view_profile.php?username=<? echo $name['Username']?>"><img src="<? echo $name['main_P']?>" width="100" height="100"/> <? echo $name['Username']?></a> <? } ?> Ok here are my 3 php pages: set.php <?php $Month = 2592000 + time(); $value = '1'; setcookie("cs_hpage", $value, $Month); ?> get.php <?php if (isset($_COOKIE["cs_hpage"])) { $cookie = $_COOKIE["cs_hpage"]; print("Received a cookie: ".$cookie."\n"); } else { print("Fail!.\n"); } ?> clear.php <?php setcookie ("cs_hpage", "", time()-60000); ?> It all works like charm but i dont know how to set if $cookie == 1 echo "Cookie here!" and if other then 1 echo "Fail!" All i managed to do is as you can see to echo the cookie :/ And question no.2: How can i set a cookie through a button?? (Like when pressed set cookie to value "1") Thanks.. Hi, I am trying to make a search based on information about a user in the database. Here is my code so far, notice any words like "and" or "the" in a multiword entry would mess it up. Any advice greatly appreciated. Ideally I would like a list of the matches by user name, and put the word "match" next to the matching data, because I used the OR statement it is going to bring back all of the user's info if one of the criteria matches. Any tutorials on the subject or keywords for google would be greatly appreciated. thanks. here is the search code. Code: [Select] <?php ini_set ("display_errors", "1"); error_reporting(E_ALL); $host = " ; $database = " "; $username = " "; $password = " "; $tbl_name = "users"; $conn = mysql_connect($host, $username, $password) or die("Could not connect: " . mysql_error()); if($conn) { mysql_select_db($database); echo "connected to database!!"; } else { echo "failed to select database"; } //include('bouncer.php'); //$currentUser = $_SESSION['myusername']; if(isset($_POST['submit'])) { $dob = mysql_real_escape_string( $_POST['dob']); $gender = mysql_real_escape_string( $_POST['gender']); $ethnic = mysql_real_escape_string( $_POST['ethnic']); //THE SEARCH FUNCTION $sql = mysql_query ( "SELECT * FROM users WHERE dob LIKE '%$dob%' OR gender LIKE '%$gender%' OR race LIKE '%$ethnic%' OR dob LIKE '%$dob%' ") or die(mysql_error()); $result = mysql_query($sql) or die( "<br>Query: $sql<br>Failed with error: " . mysql_error() ); if (!$result) { echo "Could not successfully run query ($sql) from DB: " . mysql_error(); exit; } if (mysql_num_rows($result) == 0) { echo "No rows found, nothing to print so am exiting"; exit; } // While a row of data exists, put that row in $row as an associative array // Note: If you're expecting just one row, no need to use a loop // Note: If you put extract($row); inside the following loop, you'll // then create $userid, $fullname, and $userstatus while ($row = mysql_fetch_assoc($result)) { echo $row["dob"]; echo $row["gender"]; echo $row["race"]; } }//if(isset($_POST['submit'])) ?> <html> <body> <p>Login Successful</p> <p> </p> <form action="login_success7.php" method="post"> <p> <input name="dob" type="text" size="20" id="dob" /> Date of Birth<br /> <input type="text" name="gender" size="20" id="gender" /> Gender <br /> <input type="text" name="ethnic" size="20" id="ethnic" /> Ethnicity <br /> <input type="submit" name="submit" value=" search" /> <input type="reset" value="Reset fields" /> </p> </form> </body> </html> Hi am in the middle of making a blog but am having problems with one page am working on if anyone can help me please. What is am looking for is to post username and avatar instead of just the username. I have already paid some guy to work on this but he didnt get back to me and ihave no more cash to give for the code to be finished so i would really appreciate if someone could help to finish this off please thanks. this is the where the username and text shows which i would like avatar to show as well. Code: [Select] <?php $query = yasDB_select("SELECT * FROM user WHERE username = '$user'"); $row = $avatarfile; $query = yasDB_select("SELECT * FROM topic WHERE userid = '$id' ORDER BY id DESC LIMIT 5"); if($query->num_rows == 0) { ?> <div id="memberstext">This topic has no comments, be the first to add one!</div> <?php } else { while($row = $query->fetch_array(MYSQLI_ASSOC)) { $text = $row['comment']; $text = str_replace(':D','<img src="' . $siteurl . 'templates/' . $setting['theme'] . '/styles/images/smileys/biggrin.gif" title="biggrin" alt="biggrin" />',$text); $text = str_replace(':?','<img src="' . $siteurl . 'templates/' . $setting['theme'] . '/styles/images/smileys/confused.gif" title="confused" alt="confused" />',$text); $text = str_replace('8)','<img src="' . $siteurl . 'templates/' . $setting['theme'] . '/styles/images/smileys/cool.gif" title="cool" alt="cool" />',$text); $text = str_replace(':cry:','<img src="' . $siteurl . 'templates/' . $setting['theme'] . '/styles/images/smileys/cry.gif" title="cry" alt="cry" />',$text); $text = str_replace(':shock:','<img src="' . $siteurl . 'templates/' . $setting['theme'] . '/styles/images/smileys/eek.gif" title="eek" alt="eek" />',$text); $text = str_replace(':evil:','<img src="' . $siteurl . 'templates/' . $setting['theme'] . '/styles/images/smileys/evil.gif" title="evil" alt="evil" />',$text); $text = str_replace(':lol:','<img src="' . $siteurl . 'templates/' . $setting['theme'] . '/styles/images/smileys/lol.gif" title="lol" alt="lol" />',$text); $text = str_replace(':x','<img src="' . $siteurl . 'templates/' . $setting['theme'] . '/styles/images/smileys/mad.gif" title="mad" alt="mad" />',$text); $text = str_replace(':P','<img src="' . $siteurl . 'templates/' . $setting['theme'] . '/stlyes/images/smileys/razz.gif" title="razz" alt="razz" />',$text); $text = str_replace(':oops:','<img src="' . $siteurl . 'templates/' . $setting['theme'] . '/styles/images/smileys/redface.gif" title="redface" alt="redface" />',$text); $text = str_replace(':roll:','<img src="' . $siteurl . 'templates/' . $setting['theme'] . '/styles/images/smileys/rolleyes.gif" title="rolleyes" alt="rolleyes" />',$text); $text = str_replace(':(','<img src="' . $siteurl . 'templates/' . $setting['theme'] . '/styles/images/smileys/sad.gif" title="sad" alt="sad" />',$text); $text = str_replace(':)','<img src="' . $siteurl . 'templates/' . $setting['theme'] . '/styles/images/smileys/smile.gif" title="smile" alt="smile" />',$text); $text = str_replace(':o','<img src="' . $siteurl . 'templates/' . $setting['theme'] . '/styles/images/smileys/surprised.gif" title="surprised" alt="surprised" />',$text); $text = str_replace(':twisted:','<img src="' . $siteurl . 'templates/' . $setting['theme'] . '/styles/images/smileys/twisted.gif" title="twisted" alt="twisted" />',$text); $text = str_replace(':wink:','<img src="' . $siteurl . 'templates/' . $setting['theme'] . '/styles/images/smileys/wink.gif" title="wink" alt="wink" />',$text); if ( $row['useavatar'] == '1' ) { $avatarimage = $siteurl . 'avatars/' . $row['avatarfile']; } else { $avatarimage = $siteurl . 'avatars/useruploads/noavatar.gif'; } ?> <div id="box"> <div class="name"><img src="<?php echo $avatarimage;?>" height="40" width="40" align="left"><br /><?php echo $row['name'];?></div> <div class="comment_text"><?php echo $text;?></div></div> This is the form part of it to add the text Code: [Select] <div id="box2"> <form name="addcomment" method="post" action=""> <strong>Message:</strong><br /> <textarea name="comment" rows="3" cols="40" id="comment_message"></textarea><br /> <input name="userid" type="hidden" value="<?php echo $id;?>" /> <input type="hidden" name="timestamp" id="timestamp" value="<?php echo time(); ?>" /> </center> <!-- start of smiles --> <div id="smiles"><center> <a href="javascript:addsmilie(' :D ')"><img src="<?php echo $siteurl.'templates/'.$theme.'/styles/images/smileys/biggrin.gif';?>" border="0" /></a> <a href="javascript:addsmilie(' :? ')"><img src="<?php echo $siteurl.'templates/'.$theme.'/styles/images/smileys/confused.gif';?>" border="0" /></a> <a href="javascript:addsmilie(' 8) ')"><img src="<?php echo $siteurl.'templates/'.$theme.'/styles/images/smileys/cool.gif';?>" border="0" /></a> <a href="javascript:addsmilie(' :cry: ')"><img src="<?php echo $siteurl.'templates/'.$theme.'/styles/images/smileys/cry.gif';?>" border="0" /></a> <a href="javascript:addsmilie(' :shock: ')"><img src="<?php echo $siteurl.'templates/'.$theme.'/styles/images/smileys/eek.gif';?>" border="0" /></a> <a href="javascript:addsmilie(' :evil: ')"><img src="<?php echo $siteurl.'templates/'.$theme.'/styles/images/smileys/evil.gif';?>" border="0" /></a> <a href="javascript:addsmilie(' :lol: ')"><img src="<?php echo $siteurl.'templates/'.$theme.'/styles/images/smileys/lol.gif';?>" border="0" /></a> <a href="javascript:addsmilie(' :x ')"><img src="<?php echo $siteurl.'templates/'.$theme.'/styles/images/smileys/mad.gif';?>" border="0" /></a><br /> <a href="javascript:addsmilie(' :P ')"><img src="<?php echo $siteurl.'templates/'.$theme.'/styles/images/smileys/razz.gif';?>" border="0" /></a> <a href="javascript:addsmilie(' :oops: ')"><img src="<?php echo $siteurl.'templates/'.$theme.'/styles/images/smileys/redface.gif';?>" border="0" /></a> <a href="javascript:addsmilie(' :roll: ')"><img src="<?php echo $siteurl.'templates/'.$theme.'/styles/images/smileys/rolleyes.gif';?>" border="0" /></a> <a href="javascript:addsmilie(' :( ')"><img src="<?php echo $siteurl.'templates/'.$theme.'/styles/images/smileys/sad.gif';?>" border="0" /></a> <a href="javascript:addsmilie(' :) ')"><img src="<?php echo $siteurl.'templates/'.$theme.'/styles/images/smileys/smile.gif';?>" border="0" /></a> <a href="javascript:addsmilie(' :o ')"><img src="<?php echo $siteurl.'templates/'.$theme.'/styles/images/smileys/surprised.gif';?>" border="0" /></a> <a href="javascript:addsmilie(' :twisted: ')"><img src="<?php echo $siteurl.'templates/'.$theme.'/styles/images/smileys/twisted.gif';?>" border="0" /></a> <a href="javascript:addsmilie(' :wink: ')"><img src="<?php echo $siteurl.'templates/'.$theme.'/styles/images/smileys/wink.gif';?>" border="0" /></a> </center></div> <input name="name" type="hidden" value="<?php echo $_SESSION['user'];?>" /><br /> <input name="addcomment" type="submit" value="Add Comment" style="border: 1px solid #000; margin-top: 2px;" /> </form></div> Hello. I want to make a web-based rpg with mysql and php but need alot of help, I tryed once and failed. Please msn me: cginbarrhaven@hotmail.com I need LOTS of help. Im stuck! Zeroth What kinds of things can I do to make Logging-In and being Logged-In *secure*?? I get the whole form validation thingy, but what about from the standpoint of how/where I store data in my database and how I keep track of who is logged in and where they can go, and so on? Thanks, Debbie Good evening, Im using GenRandomString, and wondered how I can get $confirm to keep its first value throughout my script. I have put comments on the lines that use $confirm. Do I need to change $confirm to a constant and how can I go about this? $firstname = $_GET['firstname']; $lastname = $_GET['lastname']; $companyname = $_GET['companyname']; $doornumber = $_GET ['doornumber']; $street = $_GET ['street']; $town = $_GET['town']; $postcode = $_GET['postcode']; $useremail = $_GET ['usermail']; $telephone = $_GET['telephone']; $shortcode = substr($postcode,0,2); function genRandomString() { $length = 10; $characters = '0123456789abcdefghijklmnopqrstuvwxyz'; $string = ""; for ($p = 0; $p < $length; $p++) { $string .= $characters[mt_rand(0, strlen($characters))];} return $string;} $confirm = genRandomString(); //creating a random number $query =mysql_query ("INSERT INTO treesurgeons (firstname, lastname, companyname, doornumber, street, town, postcode, useremail, telephone, Id) VALUES ('$firstname', '$lastname', '$companyname','$doornumber', '$street', '$town', '$postcode', '$useremail', '$telephone', '$confirm')");//1st Value echo mysql_error(); echo "<p>Thankyou for submiting your details.\r\n Please check your inbox and click on your confirmation link.</p>"; $message = "The following details have been submited to the tree directory and are awaiting confirmation; \r\n Please click on the link below to confirm these details are correct\r\n '$firstname', '$lastname', '$companyname','$doornumber', '$street', '$town', '$postcode', '$usermail', '$telephone' <a href='http://www.mywebsite.co.uk/confirmed.php?Id=$confirm'>"; //2nd Value $subject = "Your tree directory details"; $to = "$useremail"; $email = "$emailad"; mail( "$to", "$subject","$message", "$headers"); ?></body></html> I havent really played around with constants before, so please an advice appreciated! Im guessing im using DEFINE but im unsure how I would combine this with GenRandomString in my code. Hi there,
Can somebody please help me with the writing of a code for the following text?
4 Hi, Im trying to make pages switch. Read data from database and but every 10 data in 1 pages. I got my way on making pages by using PHP, but my way is not efficient. Please teach me and tell me the correct way or concept to do it. Or is there any website teaching this? Appreciate for the help thanks. I am having a dilemma. I am working on a script for a client. It is a match making system. It takes all the teams, minimum of 20 teams. 10 matches a season. No team can play the same team in the season. Here is my code I have so far. If it does not make sense ask me, I will try to explain more in depth.
<?php error_reporting(E_ALL); include("security/config.php"); //create season for testing purposes $sql_season = "insert into season (`season`) values ('1')"; $conn->query($sql_season) or die($conn->error); $season = 1; //testing purpose echo "Season 1:<br />"; //testing purpose //get number of teams $sql_teams = "select * from teams"; $rs = $conn->query($sql_teams) or die($conn->error); $num_of_teams = $rs->num_rows; echo " Number of teams this season: {$num_of_teams}<br />"; //testing purpose //put all teams in array $teams = array(); while($ts = $rs->fetch_array(MYSQLI_ASSOC)){ $teams[] = $ts; } if($num_of_teams % 2 != 0){ $teams[] = array('name' => 'bye week', 'id' => 0); $sql_dummy = "insert into teams (`name`) values ('bye week')"; $conn->query($sql_dummy); } //how many matches $weeks = 10; $matches = 10; echo " This Seaon will be {$weeks} consisting of {$matches} matches<br /><br />"; //testing purpose for($i = 0; $i < $weeks; $i++){ //mix up teams $teams1 = $teams; $teams2 = $teams; shuffle($teams1); shuffle($teams2); $week = $i + 1; //$sql_week = "insert into weeks (`number`, `season_id`) values ('{$week}', '{$season}')"; //$conn->query($sql_week) or die($conn->error); //$weekID = $conn->insert_id; echo " Week {$week} Created:<br />"; //$matchup = array(); for($x = 0; $x < $matches; $x++){ shuffle($teams1); shuffle($teams2); $team_1 = array_pop($teams1); $team_2 = array_pop($teams2); $rs = false; $rs = ($team_1['id'] == $team_2['id'] ? true : false); $sql_search = "select * from matches where season_id = '{$season}' " $sql_search .= "and team_1 = ('{$team_1['id']}' or '{$team_2['id']}') "; $sql_search .= "and team_2 = ('{$team_1['id']}' or '{$team_2['id']}')"; $rss = $conn->query($sql_search) or die($conn->error); if(!$rs || !$rss){ $sql_create = "insert into matches (`team_1`, `team_2`, `week`, `season_id`) values ('{$team_1['id']}', '{$team_2['id']}', '{$week}', '{$season}')"; $rs = $conn->query($sql_create); if($rs){ echo " "; //testing purpose echo "{$team_1['name']} vs {$team_2['name']}<br />"; //testing purpose } else{ echo 'error: ' . $conn->error . '<br />'; //testing purpose } } else{ $teams1[] = $team_1; $teams2[] = $team_2; $x--; } } } This will be my worst-ever question posted on this forum 😀 But here goes.... I have a mySQL script which retrieves data.... then my PHP script creates a text document out of it, and ends with:
$output = ob_get_contents(); The resultant thousand-item list will have some of the items duplicated, with one or more numerals appended, like this:
banana 1 When an item is duplicated and suffixed with more than one numeral, I want only the latest duplicated item, like this:
banana   What would be the most efficient way of letting my administrators make a poll? I want them to be able to set how many options (all options will be a radiobutton) they wish to have in the poll. I'm basically stuck on the part of: how would I store the poll options. Would I make separate table then store all the questions in there with the ID of the poll they created? When I move threads on my forum, I want there to be a old thread in the section it was moved from saying "Moved: new link". To do this, I'm inserting a new thread in the database with the value moved equal to the new location, so when threads are being displayed users can see the thread in the new section. Is there a quick function in MySQL that will allow me to create a duplicate row in MySQL, and then just run a quick update statement? I don't want to have to insert a whole new thread like this (unless it's the only way): //insert new thread mysql_query("INSERT INTO `threads` VALUES (null, '$id','$title', '$content', '". getUsername() ."', NOW(), '". qfc() ."', NOW(), '". getUsername() ."', '','{$_SERVER['REMOTE_ADDR']}', '0', '0', '0', '', '0')"); |