jd2007 Posted July 9, 2007 Share Posted July 9, 2007 <?php if (!$n) { include("search.php"); echo"No search term given."; } $name=explode(" ", $n); $namelen=count($name); if ($namelen==0) { include("connectdb.php"); $query = "SELECT * FROM Searching WHERE tags LIKE '%".$name."%'"; $result = mysql_query($query); while ($record = mysql_fetch_assoc($result)) { while (list($fieldname, $fieldvalue) = each ($record)) { echo $fieldname.": <B>".$fieldvalue."</B><BR>"; } echo "<BR>"; } } else {} ?> Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted July 9, 2007 Share Posted July 9, 2007 <?php if (!$_REQUEST['n']) { include("search.php"); echo"No search term given."; exit(); } $name=str_replace(' ','%', $_REQUEST['n']); $namelen=count($name); if ($namelen > 0) { include("connectdb.php"); $query = "SELECT * FROM Searching WHERE tags LIKE '%".$name."%'"; $result = mysql_query($query); while ($record = mysql_fetch_assoc($result)) { //while (list($fieldname, $fieldvalue) = each ($record)) { // echo $fieldname.": <strong>".$fieldvalue."</strong><br />"; //} echo "<br />"; } } else {} ?> I have commented out the the while loop as that part is a little confusing... list() only works on numerical arrays and mysql_fetch_assoc returns associative arrays (fieldnames as keys instead of numbers). it also relys on there being the correct fields in the correct order from the mysql_fetch_assoc. Now as I said mysql_fetch_assoc returns an associative array and we need a numerical one so that must change to mysql_fetch_row and the select query should select only the fields you want in the correct order... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.