Page 2 of 2 First 12
  • Jump to page:
    #16
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2009
    Posts
    19
    Rep Power
    0
    Originally Posted by BarryG
    You could use the building_id as the index of your array of building_id, price and rent instead of letting php assign them as 0,1,2 ....

    Then if the rent checkbox with the building id index exists, then the box was checked.
    PHP Code:
    <?php
    while ($row mysql_fetch_array($result2)){
    $b_id $row['building_id'];
    echo 
    "<form action=\"processpage.php\" method=\"post\">";
    echo 
    "<tr>";
    echo 
    "<td><input type=\"hidden\" value=\"$b_id\" name=\"building_id[$b_id]\">$row['building']</td>";
    echo 
    "<td>{$row['apt']}</td>";
    echo 
    "<td><input name=\"uprice[$b_id]\" type=\"text\" size=\"5\" value=\""htmlspecialchars($row['price'] ) ."\" /> </td>";
    echo 
    "<td>{$row['bedroom']}</td>";
    echo 
    "<td>{$row['movein']}</td>"
    echo 
    "<td><input type=\"checkbox\" name=\"rent[$b_id]\" value=\"yes\"></td>";
    echo 
    "</tr>";
    }
    echo 
    "</table>";
    ?>
    <p><input type="submit" value="Update"><p>
    </form>
    You get the value and key of each element with a
    PHP Code:
    foreach ($_POST['building_id'] as $building => $b_id) {
       
    // $b_id is the index for the $_POST['price'][$b_id] and the rent checkbox
    // do stuff with each element

    thanks. i used that logic but just made it different.

    PHP Code:
     <td><input type="checkbox" name="urent[]" value="[B][highlight=""]<?php echo $row['prim'][/highlight];[/B?>"></td>
  2. #17
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2009
    Posts
    19
    Rep Power
    0
    i used that logic but just made it different. seemed simple this way.

    just changed the value of checkbox to the primary id.

    value="<?php echo $row['prim']; ?>

    PHP Code:
     <td><input type="checkbox" name="urent[]" value="<?php echo $row['prim']; ?>"></td>

    Thanks Barry. I was racking my head on this.

    Originally Posted by BarryG
    You could use the building_id as the index of your array of building_id, price and rent instead of letting php assign them as 0,1,2 ....

    Then if the rent checkbox with the building id index exists, then the box was checked.
    PHP Code:
    <?php
    while ($row mysql_fetch_array($result2)){
    $b_id $row['building_id'];
    echo 
    "<form action=\"processpage.php\" method=\"post\">";
    echo 
    "<tr>";
    echo 
    "<td><input type=\"hidden\" value=\"$b_id\" name=\"building_id[$b_id]\">$row['building']</td>";
    echo 
    "<td>{$row['apt']}</td>";
    echo 
    "<td><input name=\"uprice[$b_id]\" type=\"text\" size=\"5\" value=\""htmlspecialchars($row['price'] ) ."\" /> </td>";
    echo 
    "<td>{$row['bedroom']}</td>";
    echo 
    "<td>{$row['movein']}</td>"
    echo 
    "<td><input type=\"checkbox\" name=\"rent[$b_id]\" value=\"yes\"></td>";
    echo 
    "</tr>";
    }
    echo 
    "</table>";
    ?>
    <p><input type="submit" value="Update"><p>
    </form>
    You get the value and key of each element with a
    PHP Code:
    foreach ($_POST['building_id'] as $building => $b_id) {
       
    // $b_id is the index for the $_POST['price'][$b_id] and the rent checkbox
    // do stuff with each element

Page 2 of 2 First 12
  • Jump to page:

IMN logo majestic logo spyfu logo threadwatch logo seochat tools logo