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

02-18-2008, 07: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');

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.


02-18-2008, 08: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'";

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

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

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

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

02-19-2008, 09: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['inv_company'] = $_POST['inv_company'];

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

02-19-2008, 09: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

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