Hi
i have a query that i want to display the pulser1 pulser2 pulser3 pulser4 from table but only when the input type for each pulser=2
when i run the query not working as i want it
please check my query
$netw is a variable it can be any value from 1 until 72 it is serial_no

$query4="select account_ref,serial_no,pulser1_name,pulser2_name,pulser3_name,pulser4_name,pulser1_input_type,pulser2_input_type,
 pulser3_input_type,pulser4_input_type from net_watch_units
         where serial_no=$netw and pulser1_input_type=2 OR pulser2_input_type=2 OR pulser3_input_type=2 OR pulser4_input_type=2"; 
$result4=mysql_query($query4);
$record4=mysql_fetch_array($result4);
$pulser1=$record4['pulser1_name'];  
$pulser2=$record4['pulser2_name'];
$pulser3=$record4['pulser3_name'];
$pulser4=$record4['pulser4_name'];

Recommended Answers

All 5 Replies

You are mixing AND and OR. When you do, add parenthesis in the correct place.

where serial_no=$netw AND ( pulser1_input_type=2 OR pulser2_input_type=2 OR pulser3_input_type=2 OR pulser4_input_type=2)

I think so u want to check either of 4 input type = 2 and serial no = value padded

one of them must have 2 it can be puler1=2 the pulser2=3 pulser3=1 and pulser4=14
then if one of them have 2 i need to get the name
ex:if pulser1=2 then pulser1_name=name i collect the name ..and each pulser has a field

@asaidi : then use this:-

$query4="select account_ref,serial_no,pulser1_name,pulser2_name,pulser3_name,pulser4_name,pulser1_input_type,pulser2_input_type,
 pulser3_input_type,pulser4_input_type from net_watch_units
         where serial_no=$netw AND ((pulser1_input_type=2) OR (pulser2_input_type=2) OR (pulser3_input_type=2) OR (pulser4_input_type=2))"; 

Only thing i am not sure is why are you using serial_no=$netw
If it is your requirement then above code snippet will work for you

it is to test the right unit when the user choose then the variable is saved in $netw

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.