SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    Your daddy. WALoeIII's Avatar
    Join Date
    Apr 2001
    Location
    USA
    Posts
    526
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Updating multiple entries based on 1 variable.

    PHP Code:
    if (isset($update_now)) {
        for (
    $i 0$i count($id); $i++) {
        
    // update based on $id[$i]
        
    safe_query("UPDATE tips set zone_id='".$zone_id."', tip='".htmlspecialchars($tip)."', verify='1' WHERE tip_id = '$id[$i]'");
        }

    I know this is wrong and it doesn't work. I have a list of check boxes next to various entries that are spit out of my databases. I can edit these entries, and I want those that are checked off to be updated in the database. The id variable is passed and the for loop goes through increasing its value and updating the table, the problem is that zone_id and tip are not matching tip_id.

    Question: I need to access the variables zone_id and tip in the array that is submitted, but I need them to correspond to the id they were submitted with. Uh... this is hard to explain... The array is sent through php with the values of the tip_id, zone_id and tip all together. The for loop goes through based on tip_id and runs the query, but I want to make sure the right zone_id and tip are inserted into the database.

    If you'd like you can contact me, as I can try to explain what I need better.

    AOL: Snoozy
    ICQ: 114248050

    Thanks!

  2. #2
    Your daddy. WALoeIII's Avatar
    Join Date
    Apr 2001
    Location
    USA
    Posts
    526
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    For reference...

    Here is the while loop that lets me check off the ones I want. I think this will clarify what I'm saying:

    PHP Code:
    <?php
            
    while ($row mysql_fetch_array($result))
                    {
    ?>
                <tr>
                    <td  bgcolor="#ABABAB" align="left"><font class="standard">Author:</font></td>
                    <td bgcolor="#ABABAB" align="left"><font class="standard"><?=$row["username"?></font></td>
                </tr>
                <tr>
                    <td bgcolor="#BCBCBC" align="left"><font class="standard">Zone:</font></td>
                    <td bgcolor="#BCBCBC" align="left"><font class="standard"><select name="zone_id">
                        <option>Choose Section</option>
                        <option value="0" <?php if($row["zone_id"]==0) {?>selected<?}?>>Other</option>
                        <option value="1" <?php if($row["zone_id"]==1) {?>selected<?}?>>29er</option>
                        <option value="2" <?php if($row["zone_id"]==2) {?>selected<?}?>>420</option>
                        <option value="3" <?php if($row["zone_id"]==3) {?>selected<?}?>>F/J</option>
                        <option value="4" <?php if($row["zone_id"]==4) {?>selected<?}?>>High School</option>
                        <option value="5" <?php if($row["zone_id"]==5) {?>selected<?}?>>Optimist</option>
                        <option value="6" <?php if($row["zone_id"]==6) {?>selected<?}?>>Laser/Laser Radial</option>
                        <option value="7" <?php if($row["zone_id"]==7) {?>selected<?}?>>Tactics</option>
                        <option value="8" <?php if($row["zone_id"]==8) {?>selected<?}?>>Line</option>
                        <option value="9" <?php if($row["zone_id"]==9) {?>selected<?}?>>Fiberglass/boat</option>
                    </select></font></td>
                </tr>
                <tr>
                    <td valign="top" bgcolor="#ABABAB" align="left"><font class="standard">Tip:</font></td>
                    <td valign="top" bgcolor="#ABABAB" align="left"><textarea name="updated_tip" cols="30" rows="7" wrap><?=stripslashes($row["tip"]) ?></textarea></td>
                </tr>
                <tr>
                    <td bgcolor="#BCBCBC" align="left"><font class="standard">Accept/Edit:</font></td>
                    <td bgcolor="#BCBCBC" align="left"><input type="checkbox" name="id[]" value="<?=$row["tip_id"?>"></td>
                </tr>
    <?php
                    
    }
    ?>

  3. #3
    Your daddy. WALoeIII's Avatar
    Join Date
    Apr 2001
    Location
    USA
    Posts
    526
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    HELP! I'm desparate!


Bookmarks

Posting Permissions

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