PDA

View Full Version : wondering why a select won't combine with results


nanny
02-18-2008, 06:50 AM
I have been using a select statement to allow a user to place their company name and telephone. I am wanting the result to combine the two.
What is happening is the results are showing for all company names that have different telephone numbers.
If a franchise has same name but different number then I am in trouble.
What I am doing for the form is this:

if (!empty($name) && !empty($tel)) {
$query = "SELECT banner.inv_company, tel FROM banner WHERE tel='" . $tel . "'";
mysql_select_db($database_config, $config);
$selectRS=mysql_query($query, $config) or die(mysql_error());
$FoundUser = mysql_num_rows($selectRS);
if($FoundUser == 0){
$error['tel'] = "$name and $tel can not be found as a match or your business banner isn't online. <br />Please contact SalonSpa for your banner id.";
}
}
if (!isset($error)) {
header('Location: update_b.php');
exit;

If company name say JO and the telephone number is 4445555 I get that result but also JO with telephone number 4445897 etc.

I thought it should select the two with the query but I was thinking the only alternative would be to do a session bit by bit ............ boring.

Any suggestions are welcome.

Thanks.

davidj
02-18-2008, 07:05 AM
just a quick point first

you have this

$query = "SELECT banner.inv_company, tel FROM banner WHERE tel='" . $tel . "'";i suggest this...

$query = "SELECT inv_company, tel FROM banner WHERE tel='$tel'";

nanny
02-18-2008, 07:08 AM
Thanks davidj
I had that to begin with a typo sorry.
But it still does the same.

nanny
02-18-2008, 07:13 AM
I also had this as well

"SELECT inv_company, tel FROM banner WHERE inv_company='$name' AND tel='$tel'";

davidj
02-18-2008, 08:13 AM
that SELECT should return one record unless you have more than one record with the same $name and $tel

nanny
02-19-2008, 08:25 AM
No it won't it will select all from the inv_company name placed in the form.
I even changed the session from inv_company to tel but still didn't work.
e.g. on top of the page is

session_start();
$_SESSION['inv_company'] = $_POST['inv_company'];

davidj
02-19-2008, 08:36 AM
is the select working at all

nanny
02-19-2008, 08:47 AM
Yeh it will select only the inv_company name but if there are many telephone numbers it shows on the next page. So maybe that is the problem page.
Because the page with this form will work perfectly on giving the match of inv_company and tel:

if($FoundUser == 0){
$error['tel'] = "$name and $tel can not be found as a match or your business banner isn't

nanny
02-25-2008, 04:18 AM
Hi I got it to work by placing the tel and inv_company as a session.