Quantcast
Channel: PHP Freaks: PHP Help
Viewing all articles
Browse latest Browse all 13200

Problem with 'LIKE' operator

$
0
0

This is a function that searches an address DB, compares the $name with 'LIKE' and returns the address details.
If no address is found, I want to go to another function.

In my form, if I leave $name blank it works, but if I put a $name that is not in the database, $result still returns a value and doesn't seem to recognize that there is no record??

any ideas, thanks.


<?php

function getsupp()
{
global $name,$address1,$address2,$address3,$address4,$pcode,$email;

mysql_select_db("picture_cards");

$result = mysql_query("SELECT *
FROM supplier
WHERE name LIKE('$name%')") or die(mysql_error());

if($result ){
while($row = mysql_fetch_array($result))
{
$name = $row['name'];
$address1 = $row['address1'];
$address2 = $row['address2'];
$address3 = $row['address3'];
$address4 = $row['address4'];
$pcode = $row['pcode'];
$email = $row['email'];

}//endwhile


}//endif
}// endfunc getsupp()

?>


Viewing all articles
Browse latest Browse all 13200

Trending Articles