Danny620 Posted June 2, 2010 Share Posted June 2, 2010 <?php require('config.inc.php'); require_once (MYSQL); $time = time(); $time = $time - 86400; // Query the database: $q = "SELECT company_id, image FROM profile WHERE date > '$time' LIMIT 9"; $r = mysqli_query ($dbc, $q) or trigger_error("Query: $q\n<br />MySQL Error: " . mysqli_error($dbc)); if (@mysqli_num_rows($r) >= 1) { // A match was made. while($row = mysqli_fetch_array ($r, MYSQLI_ASSOC)){ $image = $row['image']; echo "<div class=\"new_ads\"><a href=\"profile.php?id=$row[company_id]\"><img src=\"$image\" width=\"125\" height=\"100\" /></a></div>"; } } // Query the database: $q = "SELECT category FROM category LIMIT 9"; $r = mysqli_query ($dbc, $q) or trigger_error("Query: $q\n<br />MySQL Error: " . mysqli_error($dbc)); if (@mysqli_num_rows($r) >= 1) { // A match was made. $category = while($row = mysqli_fetch_array ($r, MYSQLI_ASSOC)){ $cat = $row['category']; $category= "<li><a href=\"search.php?$cat\" title=\"Search for $cat in United Kingdom\">$cat</a></li>"; } mysqli_free_result($r); } echo $category; in this piece of code i want it to be able to store this $category= "<li><a href=\"search.php?$cat\" title=\"Search for $cat in United Kingdom\">$cat</a> for as many time as the data is in the database so that i can echo $category where ever on my page thanks Link to comment https://forums.phpfreaks.com/topic/203689-result-capturing/ Share on other sites More sharing options...
teamatomic Posted June 2, 2010 Share Posted June 2, 2010 Put the cats into an array then store the array in a session var. Then you can write a function that will build a category list where ever you wish. HTH Teamatomic Link to comment https://forums.phpfreaks.com/topic/203689-result-capturing/#findComment-1066903 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.