I have a SELECT statement (see below) that gets a few items from the mysql db and displays them.
I need the script to update the selected items as soon as they are selected with the agent variable so when another user runs the same script they only get records that have no agent assigned to them.
So essentially I need to run a update command but only on the records that have been fetched by that select statement.
$agent = $_GET['agent'];
$con = mysql_connect($host,$user,$pass);
$dbs = mysql_select_db($databaseName, $con);
$result = mysql_query("SELECT * FROM $tableName WHERE processed = '0' AND agent IS NULL LIMIT 5");
$array_data = array();
while ($row = mysql_fetch_array($result)){
$array_data[] = array($row[0], $row[1], $row[2], $row[3], $row[4]);
}
echo json_encode($array_data);
expand your while with this:
In your above select query you have to make sure the primary key is also fetched (maybe its
$row[0]). Then you can update the record by its primary key.