kat35601 Posted February 6, 2015 Share Posted February 6, 2015 I need to have a check box on each row that when it is check it will update the status field on that record to '10' (see comments in code) <html> <head> <title>Status Screen</title> </head> <body> <p> Schedule Items Not Scanned </p> <?php $schedule=$_POST["schedule"]; $connect =odbc_connect("removed"); if(!$connect) { exit("Connection Failed: " . $connect); } $sql="SELECT uompscheduleColor,jmaPartID,ompSalesOrderID, uomlSorP,serial,rail,panel,stile,upsdescription,itemtype ,case uomlStyleGroup When 'Slab' Then 'Veneer' else uomlStyleGroup end as 'uomlStyleGroup' FROM WIP_master where uompScheduleNumber='$schedule' and status='2' and itemtype in ('DR','DDF') and jmaPartID not like '%311%' Order By uomlSorP,uomlStyleGroup,itemtype,jmaPartID"; $result =odbc_exec($connect,$sql); if(!$result){ exit("Error in SQL"); } $data = ''; while (odbc_fetch_row($result)) { $bgcolor= odbc_result($result, "uompscheduleColor"); $jmaPartID= odbc_result($result, "jmaPartID"); $ompSalesOrderID= odbc_result($result, "ompSalesOrderID"); $uomlSorP= odbc_result($result, "uomlSorP"); $serial= odbc_result($result, "serial"); $rail= odbc_result($result, "rail"); $panel= odbc_result($result, "panel"); $stile= odbc_result($result, "stile"); $upsdescription= odbc_result($result, "upsdescription"); $itemtype = odbc_result($result, "itemtype"); $uomlStyleGroup = odbc_result($result, "uomlStyleGroup"); // I want to add a check box that is on every row that when I check it then it runs this sql statment to update the status // of the item and then change the color of the row. // update wip_master set status = '10' where uompScheduleNumber='$schedule' and serial="""the serial number of the Item I clicked the check box on"""" // Then the change the color of the row to red where status='10' $data .= "<tr><td>$jmaPartID</td>"; $data .= "<td style='text-align:center'>$ompSalesOrderID</td>"; $data .= "<td style='text-align:center'>$uomlSorP</td>"; $data .= "<td style='text-align:center'>$serial</td>"; $data .= "<td style='text-align:center'> $panel</td>"; $data .= "<td style='text-align:center'> $stile</td>"; $data .= "<td style='text-align:center'> $rail</td>"; $data .= "<td style='text-align:center'> $upsdescription</td>"; $data .= "<td style='text-align:center'> $itemtype</td>"; $data .= "<td style='text-align:center'>$uomlStyleGroup</td>"; } echo "<table><tr>"; echo date('l jS \of F Y h:i:s A'); echo "<th bgcolor=$bgcolor>$schedule<th><tr>"; echo "<th>PartID</th>"; echo "<th>OrderID</th>"; echo "<th>SorP</th>"; echo "<th>Serial</th>"; echo "<th>Panel</th>"; echo "<th>Stile</th>"; echo "<th>Rail</th>"; echo "<th>Description</th>"; echo "<th>ItemType</th>"; echo "<th>Style</th>"; echo $data; odbc_close($connect); ?> </body> </html> Quote Link to comment Share on other sites More sharing options...
Barand Posted February 6, 2015 Share Posted February 6, 2015 (edited) Add another <td>..</td> containing a checkbox. Give each checkbox a value which is the primary key of the row (a unique id). EG <td><input class="cb" type='checkbox' name='status[]' value='123'></td> Use JS to submit an AJAX request on click of the checkbox which will then run a php script containing UPDATE wip_master SET status=10 WHERE id = $id and then set the row colour to red. Edited February 6, 2015 by Barand Quote Link to comment Share on other sites More sharing options...
kat35601 Posted February 6, 2015 Author Share Posted February 6, 2015 echo "<td><input class='cb' type = 'checkbox' name='Scan[]' id='$serial' value='<?echo ['id']; ?>' </input></td>"; I want to use serial as the id but I did not do it right.What am I doing wrong here.thanks for the help Quote Link to comment Share on other sites More sharing options...
Barand Posted February 6, 2015 Share Posted February 6, 2015 If $serial is unique, use that as the value. I used ID as a generic meaning the unique identifier for each row as i do not know what your table looks like Quote Link to comment Share on other sites More sharing options...
kat35601 Posted February 6, 2015 Author Share Posted February 6, 2015 echo"<td><input class='cb' type='checkbox' name='short[]' value='$serial' </input></td>"; if(isset($_POST['short'])) { $short = 1; $update=odbc_exec($connect,$sql_short); $sql_short="update wip_master set status='3' where uompScheduleNumber='$schedule' and serial='$serial'"; if(!$update){ exit("Error in SQL"); I can't get it figured out please point out my errors...Thanks Quote Link to comment Share on other sites More sharing options...
CroNiX Posted February 6, 2015 Share Posted February 6, 2015 echo"<td><input class='cb' type='checkbox' name='short[]' value='$serial' </input></td>"; That's not a valid HTML input. There is no closing > at the end in the input, and you have </input> instead (which there is no such thing) Quote Link to comment Share on other sites More sharing options...
kat35601 Posted February 11, 2015 Author Share Posted February 11, 2015 I still can't get it to update with the check box. What step am I missing? <html> <head> <title>Status Screen</title> </head> <body> <p> Status Screen </p> <?php $schedule=$_POST["schedule"]; $connect =odbc_connect("orbe","sa","Jazz2008"); $serial=''; $short = ""; $red = ""; $prepaint =""; if(!$connect) { exit("Connection Failed: " . $connect); } $sql="SELECT uompscheduleColor,jmaPartID,ompSalesOrderID, uomlSorP,serial,rail,panel,stile,upsdescription,itemtype,uomlStyleGroup FROM WIP_master where uompScheduleNumber='$schedule' and status='2' and itemtype <> 'FR' Order By uomlSorP,uomlStyleGroup,itemtype,jmaPartID " ; $result =odbc_exec($connect,$sql); if(!$result){ exit("Error in SQL"); } echo "<table><tr>"; echo "<th>$schedule<th><tr>"; echo "<th>PartID</th>"; echo "<th>OrderID</th>"; echo "<th>SorP</th>"; echo "<th>Serial</th>"; echo "<th>Rail</th>"; echo "<th>Panel</th>"; echo "<th>Description</th>"; echo "<th>ItemType</th>"; echo "<th>Stile</th>"; echo "<th>Short</th>"; echo "<th>Red</th>"; while (odbc_fetch_row($result)) { $bgcolor= odbc_result($result, "uompscheduleColor"); $jmaPartID= odbc_result($result, "jmaPartID"); $ompSalesOrderID= odbc_result($result, "ompSalesOrderID"); $uomlSorP= odbc_result($result, "uomlSorP"); $serial= odbc_result($result, "serial"); $rail= odbc_result($result, "rail"); $panel= odbc_result($result, "panel"); $stile= odbc_result($result, "stile"); $upsdescription= odbc_result($result, "upsdescription"); $itemtype = odbc_result($result, "itemtype"); $uomlStyleGroup = odbc_result($result, "uomlStyleGroup"); echo "<tr><td bgcolor=$bgcolor >$jmaPartID</td>"; echo "<td style='text-align:center'>$ompSalesOrderID</td>"; echo "<td style='text-align:center'>$uomlSorP</td>"; echo "<td style='text-align:center'>$serial</td>"; echo "<td style='text-align:center'> $panel</td>"; echo "<td style='text-align:center'> $stile</td>"; echo "<td style='text-align:center'> $upsdescription</td>"; echo "<td style='text-align:center'> $itemtype</td>"; echo "<td style='text-align:center'>$uomlStyleGroup</td>"; echo "<td style='text-align:center'>$short</td>"; echo "<td style='text-align:center'>$red</td>"; echo "<td style='text-align:center'>$prepaint</td>"; echo"<td><input class='cb' type='checkbox' name='short[]' value='$serial'> </td>"; if(isset($_POST['short'])) $short = 1; $update=odbc_exec($connect,$sql_short); $sql_short="update wip_master set status='9' where uompScheduleNumber='$schedule' and serial='$serial'"; if(!$update); { exit("Error in SQL"); } odbc_close($connect); ?> </body> </html> Quote Link to comment Share on other sites More sharing options...
CroNiX Posted February 11, 2015 Share Posted February 11, 2015 It doesn't look like you have error reporting turned on, or you'd receive a notice that $sql_short isn't defined (since you used it just BEFORE you defined it in your odbc_exec()). $update=odbc_exec($connect,$sql_short); //This needs to come BEFORE you try to use it above!! $sql_short="update wip_master set status='9' where uompScheduleNumber='$schedule' and serial='$serial'"; Still have a way to go, but before continuing on it would be best to turn error reporting ON so you SEE the errors so you can fix them. Otherwise you're just shooting blind. Quote Link to comment Share on other sites More sharing options...
kat35601 Posted February 11, 2015 Author Share Posted February 11, 2015 Ok error reporting is on and I have some what working page. Just know working update box. but I think I am close. so whats next please. <html> <head> <title>Status Screen</title> </head> <body> <p> Status Screen </p> <?php $schedule=$_POST["schedule"]; $connect =odbc_connect("orbe","sa","Jazz2008"); $serial=''; $short = ""; $red = ""; $prepaint =""; if(!$connect) { exit("Connection Failed: " . $connect); } $sql="SELECT uompscheduleColor,jmaPartID,ompSalesOrderID, uomlSorP,serial,rail,panel,stile,upsdescription,itemtype,uomlStyleGroup FROM WIP_master where uompScheduleNumber='$schedule' and status='2' and itemtype <> 'FR' Order By uomlSorP,uomlStyleGroup,itemtype,jmaPartID " ; $result =odbc_exec($connect,$sql); if(!$result){ exit("Error in SQL"); } echo "<table><tr>"; echo "<th>$schedule<th><tr>"; echo "<th>PartID</th>"; echo "<th>OrderID</th>"; echo "<th>SorP</th>"; echo "<th>Serial</th>"; echo "<th>Rail</th>"; echo "<th>Panel</th>"; echo "<th>Description</th>"; echo "<th>ItemType</th>"; echo "<th>Stile</th>"; echo "<th>Short</th>"; echo "<th>Red</th>"; $sql_short="update wip_master set status='9' where uompScheduleNumber='$schedule' and serial='$serial'"; while (odbc_fetch_row($result)) { $bgcolor= odbc_result($result, "uompscheduleColor"); $jmaPartID= odbc_result($result, "jmaPartID"); $ompSalesOrderID= odbc_result($result, "ompSalesOrderID"); $uomlSorP= odbc_result($result, "uomlSorP"); $serial= odbc_result($result, "serial"); $rail= odbc_result($result, "rail"); $panel= odbc_result($result, "panel"); $stile= odbc_result($result, "stile"); $upsdescription= odbc_result($result, "upsdescription"); $itemtype = odbc_result($result, "itemtype"); $uomlStyleGroup = odbc_result($result, "uomlStyleGroup"); echo "<tr><td bgcolor=$bgcolor >$jmaPartID</td>"; echo "<td style='text-align:center'>$ompSalesOrderID</td>"; echo "<td style='text-align:center'>$uomlSorP</td>"; echo "<td style='text-align:center'>$serial</td>"; echo "<td style='text-align:center'> $panel</td>"; echo "<td style='text-align:center'> $stile</td>"; echo "<td style='text-align:center'> $upsdescription</td>"; echo "<td style='text-align:center'> $itemtype</td>"; echo "<td style='text-align:center'>$uomlStyleGroup</td>"; echo "<td style='text-align:center'>$short</td>"; echo "<td style='text-align:center'>$red</td>"; echo "<td style='text-align:center'>$prepaint</td>"; echo"<td><input class='cb' type='checkbox' name='short[]' value='$serial'> </td>"; } if(isset($_POST['short'])){ $short = 1; } $update=odbc_exec($connect,$sql_short); if(!$result){ exit("Error in SQL"); } ?> </body> </html> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.