Note that there are some explanatory texts on larger screens.

plurals
  1. POUpdating Multiple SQL Rows
    primarykey
    data
    text
    <p>My setup is like this:</p> <p>Admin search for orders depending on say address, or client name. Once all they orders are displayed for the search criteria they entered, they can select the orders using check-boxes. The code below handles that:</p> <pre><code>&lt;form action="noJavaScript.php" name="theForm" method="post"&gt; &lt;table style="border: 1px solid black"&gt; &lt;?php while ($row = mysql_fetch_assoc($result)) { echo '&lt;tr&gt;&lt;td&gt;'; echo '&lt;input type="checkbox" name="selected[]" value="'.$row['order_number'].'"/&gt;'; echo '&lt;/td&gt;'; foreach ($row as $key =&gt; $value) echo '&lt;td&gt;'.htmlspecialchars($value).'&lt;/td&gt;'; echo '&lt;/tr&gt;'; } ?&gt; &lt;/table&gt; &lt;input type="submit" name="submit" value="Edit/Modify Order" onClick="document.theForm.action='modify.php'"&gt; &lt;input type="submit" name="submit" value="Clone Order" onClick="document.theForm.action='clone.php'"&gt; &lt;input type="submit" name="submit" value="Delete Order" onClick="document.theForm.action='deleteorder.php'"&gt; &lt;/form&gt; </code></pre> <p>What I am trying to accomplish is depending on how many orders they select, 1, 5, 10, All of them, When they click on the Delete Order button, I want all those orders they selected to be updated in the database. I'm not sure how to do that. I have tried the following: This is the code on my deleteorder.php page:</p> <pre><code>$id = array(); $id = $_POST['selected']; //Include database connection details require_once('config_order.php'); //Connect to mysql server $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); if(!$link) { die('Failed to connect to server: ' . mysql_error()); } //Select database $db = mysql_select_db(DB_DATABASE); if(!$db) { die("Unable to select database"); } //Create query $query = mysql_query("UPDATE PropertyInfo SET order_status = 'In-Active' WHERE `order_number` LIKE $id[0]"); </code></pre> <p>That doesn't work, as it only updates the value assigned to $id[0] and not all of the orders they might have selected.</p> <p>Any help would be greatly appreciated! Thanks</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload