troubleshooting Question

insert values to one field

Avatar of asaidi
asaidi asked on
3 Comments1 Solution196 ViewsLast Modified:
i have this code with test,and i want to insert for example channel with values that can be p11,p22,p33 or p44 look the code and the same for usage can be v1 v2 v3 or v4
any help please
$pdf=" SELECT DATE(tran_date) as dateiy,unit_serial,account_no,
      SUM(case when pulse_channel = 1 then unit_qty else 0 end) as val1,
      SUM(case when pulse_channel = 2 then unit_qty else 0 end) as val2,
      SUM(case when pulse_channel = 3 then unit_qty else 0 end) as val3,
      SUM(case when pulse_channel = 4 then unit_qty else 0 end) as val4,
      SUM(unit_qty) as Total
  from count_transactions
  WHERE  DATE(tran_date) BETWEEN '".$start."' AND '".$end."'
  GROUP BY unit_serial";
$result=mysql_query($pdf) or die('Could not connect: ' . mysql_error());
//echo $num;

while($rows = mysql_fetch_array($result)) { 

//print var_dump($rows);
$query2="select * from net_watch_units
         where serial_no=$unit  ";

$q2="SELECT account_name FROM account_details WHERE auto_id=$account";

   $mes='High usage alarm detected'
   $mes='High usage alarm detected'
   $mes='High usage alarm detected'
   $mes='High usage alarm detected'
   $mes='Low usage alarm detected'
   $mes='Low usage alarm detected'
   $mes='Low usage alarm detected'
   $mes='Low usage alarm detected'
$sql="INSERT INTO `alarm` (account, unitname, channel, usage, details)
if (!mysql_query($sql,$con))
  die('Error: ' . mysql_error());
echo "1 record added";
Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros