Forums

PHP

This topic is locked

Mutliple Behaviors in one field

Posted 26 Jan 2004 22:49:29
1
has voted
26 Jan 2004 22:49:29 Joshua Jones posted:
I am trying to pull data from two tables into one display 3 diffrent ways.
Account Number
Phone Number
Customer Number

The person can select either or.
I know the easy way around would be to set behaviors for each search, but I have a hard time inserting all the behaviors in to a form field.
(I am new at this so I find the easy ways first) I think there are no easy ways wround this and I am going to have to code a query that will pull from either, but I figured I would ask if there is another way to insert multiple bahaviors into one field.

Replies

Replied 30 Jan 2004 14:48:26
30 Jan 2004 14:48:26 Joshua Jones replied:
If any one needs this here is the string

PHP and MySQL
$colname_rsSearch = "1";
if (isset($_POST['Eaccount'])) {
$colname_rsSearch = (get_magic_quotes_gpc()) ? $_POST['Eaccount'] : addslashes($_POST['Eaccount']);
}
$colnamea_rsSearch = "1";
if (isset($_POST['PhoneNumber'])) {
$colnamea_rsSearch = (get_magic_quotes_gpc()) ? $_POST['PhoneNumber'] : addslashes($_POST['PhoneNumber']);
}
mysql_select_db($database_connYankeeEquip, $connYankeeEquip);
$query_rsSearch = sprintf("SELECT customers.equipaccount, customers.partsaccount, customers.company_name, customers.address, customers.city, customers.state, customers.zip_code, customers.contact_name, customers.phone_number, customers.fax_number, customers.`phone_number2`, customers.email, customers.customer_type, equipment.make, equipment.model, equipment.serial, equipment.date_installed FROM customers LEFT JOIN equipment ON (customers.equipaccount = equipment.equipaccount) WHERE ( (customers.equipaccount = '%s') OR (customers.phone_number = '%s') ) ", $colname_rsSearch,$colnamea_rsSearch);
$rsSearch = mysql_query($query_rsSearch, $connYankeeEquip) or die(mysql_error());
$row_rsSearch = mysql_fetch_assoc($rsSearch);
$totalRows_rsSearch = mysql_num_rows($rsSearch);


Edited by - homchz on 30 Jan 2004 14:48:59

Reply to this topic