Jump to content

php help ?


jd2007

Recommended Posts

echo $fieldvalue

 

the above is in a loop. $fieldvalue changes every time it loops. i want to use php to see if the same $fieldvalue content is already echoed, then stop $fieldvalue from being echoed. how to do this, pls help ?

Link to comment
Share on other sites

if (!$n) {
   include("search.php");
   echo "No search term given"; 
}
else    {
   $name=explode(" ", $n);
   $namelen=count($name);
   
   
   if ($namelen == 1) {
      $db = mysql_connect("localhost", "root");
      $connection=mysql_select_db("Search", $db);
      $query = "SELECT Searching.tags, Searching.page_title, Searching.info, Searching.link
	FROM Searching WHERE tags LIKE'%".$n."%'";
      $result = mysql_query($query);
      if (mysql_num_rows($result) == 0) {
	echo "Sorry, no matching results.";
	echo $link;
	exit;
      }		
      while ($record = mysql_fetch_assoc($result)) {
	while (list($fieldname, $fieldvalue) = each ($record)) {
		echo $fieldvalue."<BR>";
	}
	echo "<BR>";


   }
} else if ($namelen > 1) {
          
          $db = mysql_connect("localhost", "root");
          $connection=mysql_select_db("Search", $db);
          $i=$namelen;
          for ($j=0; $j<$i; $j++) {
           $query = "SELECT Searching.page_title, Searching.info, Searching.link
	FROM Searching WHERE info LIKE'%".$name[$j]."%'";
      $result = mysql_query($query);
      if (mysql_num_rows($result) == 0) {


	//echo "<br>";
      }	
      	
      while ($record = mysql_fetch_assoc($result)) {
	while (list($fieldname, $fieldvalue) = each ($record)) {
	       for ($l=0; $l<count($name); $l++) {
	       $old = array($name[$l]);
                       $new = array("<b><u>".$name[$l]."</u></b>");
                       $fieldvalue = str_replace($old, $new, $fieldvalue);
                       
                      
                       }
                          echo  $fieldvalue;
                }
                       
                       
	          
	          
	          }
	          




   }
          
          }
          
   }

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.