Jump to content

No search results message even when results returned.


maximus83

Recommended Posts

Hi, I'm trying to get a no results returned message to appear after a search form, but at the moment I get the message when the user searches no matter if there are results or not. Could someone please look at my code below and tell me where I am going wrong.

 

Many thanks.

 

if ($_POST["search"]) {
	 $query = "SELECT ticket_number, first_name, surname, email, product, retailer, DATE_FORMAT(dop, '%d %M %Y') AS dop, message, address, DATE_FORMAT(created, '%d %M %Y %r') AS created, status FROM support_dev WHERE ticket_number LIKE '$search' OR email LIKE '$search' ORDER BY ticket_number DESC LIMIT $start, $display";

    if (mysql_num_rows($result) < 1) {


   echo 'Please try another search term.';

} else {  if ($result = mysql_query ($query)) {
	 echo '
<div id="supviewwrapperheader">
    <div id="supviewticket"><p>Ticket</p></div> 
    <div id="supviewfirst"><p>First Name</p></div>
<div id="supviewlast"><p>Last Name</p></div>
<div id="supviewemail"><p>Email</p></div>
<div id="supviewproduct"><p>Product</p></div>
<div id="supviewretailer"><p>Retailer</p></div>
<div id="supviewdop"><p>D.O.P.</p></div>
<div id="supviewmessage"><p>Message</p></div>
<div id="supviewaddress"><p>Address</p></div>
<div id="supviewcreated"><p>Date created</p></div>
<div id="supviewstatus"><p>Status</p></div>
<div id="supviewbuttons"><p></p></div>
</div>
';

while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
	echo "
	<div id=\"supviewwrapper\" class=\"".($row[10])."\">
	<div id=\"supviewticket\"><p><a name=\"a".$row[0]."\"></a>$row[0]</p></div>
	<div id=\"supviewfirst\"><p>$row[1]</p></div>
	<div id=\"supviewlast\"><p>$row[2]</p></div>
	<div id=\"supviewemail\"><p>$row[3]</p></div>
	<div id=\"supviewproduct\"><p>$row[4]</p></div>
	<div id=\"supviewretailer\"><p>$row[5]</p></div>
	<div id=\"supviewdop\"><p>$row[6]</p></div>
	<div id=\"supviewmessage\"><p>$row[7]</p></div>
	<div id=\"supviewaddress\"><p>$row[8]</p></div>
	<div id=\"supviewcreated\"><p>$row[9]</p></div>
	<div id=\"supviewstatus\"><p>$row[10]</p></div>
	<div id=\"supviewbuttons\"><p><form method=\"post\" action=\"".htmlentities($_SERVER['REQUEST_URL'])."#a".$row[0]."\"><input type=\"hidden\" name=\"close_row\" value=\"".($row[0])."\" /><input type=\"hidden\" name=\"viewstate\" value=\"".$viewstate."\" /><INPUT TYPE=\"submit\" name=\"open\" VALUE=\"\" class=\"submit_open\"><br /><INPUT TYPE=\"submit\" name=\"pending\" VALUE=\"\" class=\"submit_pending\"><br /><INPUT TYPE=\"submit\" name=\"pending_ami\" VALUE=\"\" class=\"submit_pendingami\"><br /><INPUT TYPE=\"submit\" name=\"pending_arp\" VALUE=\"\" class=\"submit_pendingarp\"><br /><INPUT TYPE=\"submit\" name=\"close\" VALUE=\"\" class=\"submit_closed\"></form></p></div></div>";


}

}}
}	

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.