Results 1 to 2 of 2

Thread: Updating Multiple records

  1. #1
    Join Date
    Jun 2007
    Posts
    1

    Updating Multiple records

    Here is my situation we have a helpdesk database and I am currently updating our support web site that uses the data in this database. I have a column called Tech and we sometimes will assign calls as unassigned until a specific tech takes them. What I would like to do is have a page that displays all calls marked as unassigned and be able to assign multiple calls at once to a tech. Here is how I was thinking of doing this, by having code that displays each record, then inserting a check box by each record and have one drop down list at the top of the page that lists each tech. When a check box is checked and a tech is selected the submit would update that record. I know how to diplay the records, but what I can't figure out is how to associate each checkbox with each different record when the number of records displayed changes based on the data. Thanks for your help.

  2. #2
    Join Date
    Jan 2006
    Location
    Michigan
    Posts
    394
    Here's a snippet of code for doing it.
    PHP Code:
    <table>
    <tr>
      <td>&nbsp;</td>
      <th>Title</th>
      <th>Description</th>
      <th>Status</th>
    </tr>
    <?php
    $result 
    mysql_query("SELECT ID, title, description, status FROM tasks");
    while (
    $row mysql_fetch_assoc($result))
      echo <<<HTML
    <tr>
      <td><input type="checkbox" name="job_
    {$row['ID']}" /></td>
      <td>
    {$row['title']}</td>
      <td>
    {$row['description']}</td>
      <td>
    {$row['status']}</td>
    </tr>
    HTML;
    ?>
    </table>
    As you can see, all you have to do is give the checkbox a guaranteed unique name. Then, when the user submits the form you just need to filter the $_POST array for indexes that start with 'job_'. I'm pretty sure you can handle the rest. Any questions let me know.
    FYI the mysql_ set of functions probably should be replaced with the mysqli_ counterparts if possible for better forward compatibility. I'm just not familiar with the mysqli version since I've been using frameworks.
    Last edited by bjk2007; 18 Jul 2007 at 05:58 PM.
    Co-founder Aedis IT www.aedisit.com
    Registered Linux User #445070 counter.li.org
    Zend Certified Engineer - CIW Professional - CompTIA Linux+ - CompTIA Network+

Similar Threads

  1. Multiple AJAX requests
    By Luis in forum Client & Server Side Scripting (PHP, ASP, JavaScript)
    Replies: 0
    Last Post: 07 Mar 2006, 09:36 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •