justlukeyou Posted August 18, 2012 Share Posted August 18, 2012 Hi, The following code shows the "Find 20 Red Widgets". Thats because I have a total of 20 Widgets in the database. It supposed to show "Find 8 Red Widgets" because I have 8 "red" in the database. I am using this code to show "Find 20 Widgets" but I cant get it to show "Find 8 Red Widgets" Does anyone know how I can do this please? Find <?php $link = mysql_connect("localhost", "ukhomefu", "eggplummer123"); mysql_select_db("ukhomefu_eventvital", $link); $result = mysql_query("SELECT * FROM hostdbase", $link); $num_rows = mysql_num_rows($result); echo "$num_rows \n"; ?> <?php if (isset($_GET['linkcategory'])) { $linkcategory = mysql_real_escape_string($_GET['linkcategory']); $res = mysql_query("SELECT * FROM hostdbase WHERE linkcategory = '{$linkcategory}' ORDER BY category DESC LIMIT 1") or die(mysql_error()); if($res && mysql_num_rows($res) > 0) { while($row = mysql_fetch_assoc($res)) { echo $row['category']; } } } ?>'s Quote Link to comment Share on other sites More sharing options...
Mahngiel Posted August 18, 2012 Share Posted August 18, 2012 a) 'eggplumber123' is an awesome password. hope that's fake. b) if you're querying for all the rows, why are you querying a second time? since you have already have the full query (for whatever reason), why don't you compare the $result array's key for the same query string? Quote Link to comment Share on other sites More sharing options...
justlukeyou Posted August 18, 2012 Author Share Posted August 18, 2012 b) if you're querying for all the rows, why are you querying a second time? since you have already have the full query (for whatever reason), why don't you compare the $result array's key for the same query string? Not sure what you mean by this. 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.