cdoggg94 Posted June 25, 2012 Share Posted June 25, 2012 All i want to do is have a message for this search saying: a) there are___ results found (if there is anything) b) if there is no results..." there is no results for yours search here is my search code <?php //require_once("Connections/jodysConnect.php"); $mysearch = $_GET['findthis']; //echo $mysearch; mysql_select_db($database_TrendConnect); $q = "SELECT * FROM Sheet1 WHERE pro_name LIKE '%" . mysql_real_escape_string($mysearch) . "%' OR lcbo_num LIKE '%" . mysql_real_escape_string($mysearch) . "%' ORDER BY pro_name ASC"; $mystuff = mysql_query($q); //$num_rows = mysql_num_rows($result); while($row = mysql_fetch_assoc($mystuff)) { echo "<table border='0'><tr><td>";?><a href="#" onClick="MyWindow=window.open('<?php echo "http://www.THISWEBSITE.com/Agency/product3.php?Product=".$row['pro_id']; ?>','MyWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=800,height=886'); return false;"><?php echo $row['pro_name']."</a><br /></td></tr></table>"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/264711-displaying-number-of-results/ Share on other sites More sharing options...
Pikachu2000 Posted June 25, 2012 Share Posted June 25, 2012 You haven't told us what problems you're having. Quote Link to comment https://forums.phpfreaks.com/topic/264711-displaying-number-of-results/#findComment-1356715 Share on other sites More sharing options...
Mahngiel Posted June 25, 2012 Share Posted June 25, 2012 All i want to do is have a message for this search saying: mysql-num-rows Quote Link to comment https://forums.phpfreaks.com/topic/264711-displaying-number-of-results/#findComment-1356717 Share on other sites More sharing options...
cdoggg94 Posted June 25, 2012 Author Share Posted June 25, 2012 yea sorry that's kind of what it seemed like... I was thinking that $num_rows = mysql_num_rows($mystuff) ; then.. if($num_rows >= 1){ echo "you have".$num_rows."results"; } if($num_rows ==0){ echo "there were no results found"; } im just not sure if the $num_rows thing is what im looking for. Quote Link to comment https://forums.phpfreaks.com/topic/264711-displaying-number-of-results/#findComment-1356723 Share on other sites More sharing options...
cdoggg94 Posted June 25, 2012 Author Share Posted June 25, 2012 hopefully that explains it... again sorry.. Quote Link to comment https://forums.phpfreaks.com/topic/264711-displaying-number-of-results/#findComment-1356725 Share on other sites More sharing options...
Pikachu2000 Posted June 25, 2012 Share Posted June 25, 2012 If you need to use actual data returned from a query (and it seems you do) then mysql_num_rows() is the right choice. If all you need is to find the number of records that a particular query returns, then you'd just use a SELECT COUNT() query. Quote Link to comment https://forums.phpfreaks.com/topic/264711-displaying-number-of-results/#findComment-1356727 Share on other sites More sharing options...
cdoggg94 Posted June 25, 2012 Author Share Posted June 25, 2012 Well I have this: <?php //require_once("Connections/jodysConnect.php"); $mysearch = $_GET['findthis']; //echo $mysearch; mysql_select_db($database_TrendConnect); $q = "SELECT * FROM Sheet1 WHERE pro_name LIKE '%" . mysql_real_escape_string($mysearch) . "%' OR lcbo_num LIKE '%" . mysql_real_escape_string($mysearch) . "%' ORDER BY pro_name ASC"; $mystuff = mysql_query($q); $num_rows = mysql_num_rows($mystuff); if($num_rows >= 1){ echo "<span class='Graphtitle'>There were ".$num_rows." results for your search!</span><br /><br />"; while($row = mysql_fetch_assoc($mystuff)) { echo "<table border='0'><tr><td>";?><a href="#" onClick="MyWindow=window.open('<?php echo "http://www.THISWEBSITE.com/Agency/product3.php?Product=".$row['pro_id']; ? >','MyWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width= 800,height=886'); return false;"><?php echo $row['pro_name']."</a><br /></td></tr></table>"; } } if($num_rows == 0){ echo "<span class='Graphtitle'>There were no results for your search</span>"; } ?> It seems to be working. I don't know if its done in the best way possible, but it does seem to be doing what I want it to do. Thanks anyways for the help Cheers Quote Link to comment https://forums.phpfreaks.com/topic/264711-displaying-number-of-results/#findComment-1356730 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.