Hi I’m having an issue with a small php script. I am trying to get my user to change the status of a “job” so I am having to use option and post.
I can get the option answer but not the id. So how do I pass the id to then new script bellow are the scripts.
<?php
$conx; //connection object to the server
$comd;//instance of a command object
$sql; //string variable to hold the SQL commands
$itemsAdded; //numeric var to hold num records added to table (1 or 0)
$dbpath;
$db = realpath("../Database/iceserv.mdb");
$conn = new COM('ADODB.Connection') or exit('Cannot start ADO.');
$connStr = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=$db";
$conn->Open($connStr);
$sql = "SELECT callback.*, status.stat_disc AS Status
FROM callback INNER JOIN status ON callback.callback_STATID = status.stat_ID";
$rs = $conn->Execute($sql);
if (!$rs) {exit("Error in SQL");}
echo "<form method='post' action='../scripts/update_stat.php' id='status' name='status'><table><tr>";
echo "<th> Cutomer ID</th>";
echo "<th>Customer First Name</th>";
echo "<th>Customer Surname</th>";
echo "<th>Customer Phone Number</th>";
echo "<th>Customer Reason For Callback</th>";
echo "<th>Callback Status</th>";
echo "<th>Change Status</th>";
echo "<th></th>";
while (!$rs->EOF) {
$callid=$rs->Fields['callback_ID']->Value;
//echo $callid;
$fname=$rs->Fields['callback_fname']->Value;
$sname=$rs->Fields['callback_sname']->Value;
$phone=$rs->Fields['callback_phnum']->Value;
$reason=$rs->Fields['callback_reason']->Value;
$status=$rs->Fields['Status']->Value;
echo "<tr><td align='center'>$callid</td>";
echo "<td align='center'>$fname</td>";
echo "<td align = 'center'>$sname</td>";
echo "<td align = 'center'>$phone</td>";
echo "<td align = 'center'>$reason</td>";
echo "<td align = 'center'>$status</td>";
//echo "<td align = 'center'><input type='text' name='calledid' value = '$callid'></td>";
echo"<td align = 'center'><select name ='status' size='1'>
<option value =''>Choose status</option>
<option value ='1'>Open </option>
<option value ='2'>Waiting Qoute</option>
<option value ='3'>Closed </option></td>
</select>";
echo "<td><input type='submit' name='submit_btn' id='submit_btn' value='Update' class='submit_btn1'</input></td></tr></table></form>";
exit;
}
?>
So the above script is calling and pulling the information from the database
<?php
//variable listing and usage
$conx; //connection object to the server
$comd;//instance of a command object
$sql_comd; //string variable to hold the SQL commands
$itemsAdded; //numeric var to hold num records added to table (1 or 0)
$dbpath;
$db = realpath("../Database/iceserv.mdb");
$conn = new COM('ADODB.Connection') or exit('Cannot start ADO.');
$connStr = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=$db";
$conn->Open($connStr);
$id = $_POST['callid'];
echo "ID is " +$id;
$option= $_POST['status'];
$sql_comd="UPDATE callback
SET callback_STATID=$option
WHERE callback_ID=$id
";
$conn->Execute($sql_comd);
//$result = null;
$conn = null;
header('Location: ../admin/callback.php');
?>
The above script is trying to update the table but the id is not passing through so how do I get the ID to be passed to the script?
Please ask if ive been unclear
You can set the value of the select like:
<option value ='{$callid}|1'>Open </option>and then explode by “|” to split the resultlist($id,$option)=explode("|",$_REQUEST['status'])