hi, i have a search page and it's working ok when records exist in database. <?php if ($searchfor == "") {?> You must type a keyword! <?php } else { ?> <?php $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("storedb", $con); $result = mysql_query("SELECT * FROM products WHERE status=1 AND (product_id LIKE '".$searchfor."' OR name LIKE '".$searchfor."' OR manufacturer LIKE '".$searchfor."') ORDER BY pricer"); ?> <html table for results> <?php } ?> PHP: but when the search is not locate any record i wan't to display a message "no records found". how i can do this?
i am looking in your code and i cant understand this <?php if ($searchfor == "") {?> You must type a keyword! why are you closing php tag in almost every line?
It's called inline HTML. It's not required, but quicker than using echo() or print() statements. Its faster than using the latter, hence why it's used for large(r) outputs. Jay
Perhaps he wanted a line break? <?php for ($i=0; $i < 100000; $i++){ rand(0, $i); } ?> <?php for ($i=0; $i < 100000; $i++){ rand(0, $i); } ?> PHP: Times: real 0m0.202s user 0m0.050s sys 0m0.000s Code (markup): ---------------------------- <?php for ($i=0; $i < 100000; $i++){ rand(0, $i); } echo "\n"; for ($i=0; $i < 100000; $i++){ rand(0, $i); } ?> PHP: Times: real 0m0.203s user 0m0.060s sys 0m0.010s Code (markup): The include echo was actually slower on all accounts! The statistics don't lie! (Best time from 10 trials). Jay