Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jan 2010
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Using variables to find postback information

    So I have made an online bread order form. Basically the type of bread, the price, and a quantity box is generated from a mysql database. From there the user hits order and it is processed.

    What I am trying to do is generate a receipt for the user so they can review what they ordered. So I have once again generated another dynamic table - however this time I want the quantity textbox to get the postback values from the quantity textbox on the page before. I was trying something like this:

    <?php $count = 0; do {
    $count = $count + 1;
    $breadq = "breadq" + $count;
    ?>

    Than heres the column with the quanitity textbox

    <td bgcolor="#FFFFCC"><span style="border-bottom-style: solid; border-bottom-width: 1px"> Qty</span><span style="border-bottom-style: solid; border-bottom-width: 1px">
    <input name="qty" id="qty" value="<?php echo $_POST["breadq"+$count]; ?>" size="7" />
    </span></td>


    Any suggestions? Heres the entire code for the table

    <table border="0" cellpadding="0" cellspacing="3">

    <?php $count = 0; do {
    $count = $count + 1;
    $breadq = "breadq" + $count;
    ?>
    <tr>
    <td width="171" align="right" bgcolor="#FFFFCC"><span style="border-bottom-style: solid; border-bottom-width: 1px"> <span style="text-align: left"></span>
    <input name="breadb<?php echo $row_bread['ID']; ?>" readonly="True" id="breadb[]" value="<?php echo $row_bread['bread']; ?>" size="20" />
    </span><br />
    <span class="small"><?php echo $row_bread['notes']; ?></span></td>
    <td bgcolor="#FFFFCC">$<span style="border-bottom-style: solid; border-bottom-width: 1px">
    <input name="breadp<?php echo $row_bread['ID']; ?>" readonly="True" id="breadp[]" value="<?php echo $row_bread['price']; ?>" size="3" />
    </span></td>
    <td bgcolor="#FFFFCC"><span style="border-bottom-style: solid; border-bottom-width: 1px"> Qty</span><span style="border-bottom-style: solid; border-bottom-width: 1px">
    <input name="qty" id="qty" value="<?php echo $_POST["breadq"+$count]; ?>" size="7" />
    </span></td>
    <td width="61" bgcolor="#FFFFCC"><input name="breadslice[]" readonly="true" type="checkbox" id="breadslice[]" value="Sliced" />
    Sliced</td>
    </tr>
    <?php } while ($row_bread = mysql_fetch_assoc($bread)); ?>
    </table>

  • #2
    Regular Coder
    Join Date
    Dec 2009
    Location
    UK
    Posts
    495
    Thanks
    0
    Thanked 58 Times in 58 Posts
    Try changing
    PHP Code:
    <?php echo $_POST["breadq"+$count]; ?>
    to
    PHP Code:
    <?php echo $_POST["breadq"]+$count?>
    My site: JayGilford.com
    Resources:
    PHP Pagination Class | Getting all page links | Handling PHP Errors properly
    If you like a users help, show your appreciation with the rep and thanks buttons :)


  •  

    Posting Permissions

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