Hi
i have this line of code that i want to test when a user choose ...

$c=count($pulse);

array_push($ser, $pulse);

foreach($ser as $serv){
  $serv1[] = $serv;
}
   if($c>=4){
        include('full.php');  
        $netw = empty($_POST['netw'])?null:$_POST['netw'];
        $client = empty($_POST['client'])?null:$_POST['client']; 
        getRecords($date,$date2,$report,$client,$netw,$auto);
     }

in this line all the check boxes supposed to be ticked and it works fine
and now i want to add to this command if a user tick only 2 1 any propabilities...
the script will be called

function getRecords($startDate,$endDate,$report,$customer,$serial,$auto){  

$sql="SELECT * FROM count_transactions WHERE DATE(tran_date) BETWEEN '$startDate' AND '$endDate' and account_no=$auto and unit_name='Litres' ";
           if ($customer != null) $sql .= " AND customer_no=$customer  ";
           if ($serial != null) $sql .= " AND unit_serial=$serial ";
            if ($ser<4) $sql .= " AND pulse_channel=$serv[] ";
           $sql .= " GROUP BY unit_serial";  

any help please

Recommended Answers

All 4 Replies

Member Avatar for LastMitch

and now i want to add to this command if a user tick only 2 1 any propabilities...

Was there an error when you ran this query?

It looks weird.

It is hard to figure out from your post what exactly is the problem but looking at your query on line 6 this certainly won't work:

if ($ser<4) $sql .= " AND pulse_channel=$serv[] ";

You can't use $serv[] a query (which is basicaly a string). You will either have to decide which element to use or run foreach loop and use each value from the array depending of the logic you want to implement.

that is what i want to test on line 6 it is not working of course when i run the script after adding line 6

Member Avatar for LastMitch
if ($ser<4) $sql .= " AND pulse_channel=$serv[] ";

What is the purpose < 4?

I know $ser is an array but like what broj1 mention about your query not working, to me your query doesn't make any sense.

You declare it here as

$serv1[] = $serv;

but in your query it's this

pulse_channel=$serv[]

Is $serv1[ ] is the same as $serv[ ]?

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.