PDA

View Full Version : [PHP, MySQL, FLASH] - Search Query p2



- |Flash Man| -
June 23rd, 2006, 12:25 PM
Hey all,

just wondering with this script i have shown below, if its possible to edit it so that i could have the user type any of the input fields in flash instead of all in order to produce the complete results of the record.

at the moment its only out putting one of the record fields 'NAME' and they all must be filled in order to conduct search "which is not what i want".

Here is the code:

<?
$name=$_GET['name'];
$company=$_GET['company'];
$address=$_GET['address'];
$phone=$_GET['phone'];
$email=$_GET['email'];
$web=$_GET['web'];

mysql_pconnect("host","random","random") or die ("didn't connect to mysql");
mysql_select_db("database") or die ("no database");

$query = "SELECT * FROM tbl_name
WHERE Name = '$name'
AND Company = '$company'
AND Address = '$address'
AND Phone = '$phone'
AND Email = '$email'
AND Web = '$web'";
$result = mysql_query( $query ) or die ( mysql_error() );

$num = mysql_num_rows( $result );
//echo ($num);
if ($num == 1){
while ($line=mysql_fetch_array($result)) {
$profile = "name_show=" . $line['Name'];
$profile = "company_show=" . $line['Company'];
$profile = "address_show=" . $line['Address'];
$profile = "phone_show=" . $line['Phone'];
$profile = "email_show=" . $line['Email'];
$profile = "web_show=" . $line['Web'];

}
print $profile;

} else {
print "error=Sorry, but I can't show results";
}
?>

if you see anything wrong with this code as to my questions above any help will be great!!

Thanks in advance ppls!! :hr::hr:

bwh2
June 23rd, 2006, 03:38 PM
in your $sql, change AND to OR. (i.e., "OR Company = '$company'
OR Address = '$address'").

if you have any more questions about this specific issue, try to post them in the same thread.