passing query data to different rows of input text boxes

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • backups2007
    New Member
    • Jul 2007
    • 92

    passing query data to different rows of input text boxes

    I want to be able to pass rows of queried data to rows of input text boxes. As the example below shows, I have come up with this incomplete solution. But this code only passes the data to the first row. I need to be able to pass it to all the rows.

    [PHP]

    <input type="text" name="prod_id1" ><input type="text" name="qty1">
    <input type="text" name="prod_id2" ><input type="text" name="qty2">
    <input type="text" name="prod_id3" ><input type="text" name="qty3">
    <input type="text" name="prod_id4" ><input type="text" name="qty4">
    <input type="text" name="prod_id5" ><input type="text" name="qty5">

    <?
    $query = "SELECT * FROM product_contain er";

    prod_id = $query['prod_id'];
    qty = $query['qty'];

    ?>
    [/PHP]

    Does anybody have a better solution that what I have come up? Or do you have any other enhancement to this code? Please reply to my post. Thank you.
  • rpnew
    New Member
    • Aug 2007
    • 189

    #2
    Originally posted by backups2007
    I want to be able to pass rows of queried data to rows of input text boxes. As the example below shows, I have come up with this incomplete solution. But this code only passes the data to the first row. I need to be able to pass it to all the rows.

    [PHP]

    <input type="text" name="prod_id1" ><input type="text" name="qty1">
    <input type="text" name="prod_id2" ><input type="text" name="qty2">
    <input type="text" name="prod_id3" ><input type="text" name="qty3">
    <input type="text" name="prod_id4" ><input type="text" name="qty4">
    <input type="text" name="prod_id5" ><input type="text" name="qty5">

    <?
    $query = "SELECT * FROM product_contain er";

    prod_id = $query['prod_id'];
    qty = $query['qty'];

    ?>
    [/PHP]

    Does anybody have a better solution that what I have come up? Or do you have any other enhancement to this code? Please reply to my post. Thank you.
    Hi,
    You mean to say that... you are querying the database and the result you want to output in the TEXT boxes you've made. Is that what you want?? If yes try the following..

    [PHP]
    $query = "SELECT * FROM product_contain er";
    $result=mysql_q uery($query);
    while(list($prd ,$qty)=mysql_fe tch_array($resu lt))
    {
    echo "<input type='text' name='prod_id' value='$prd'><i nput type='text' name='qty1' value='$qty'>";
    }
    [/PHP]
    Now if you want to pass this text boxes' value to another page on submiting the page then you can make the name as array.. that is name='prod_id[]' or if you want to use different name as you've done in your example you can use counter.
    Just post back with your query.

    Regards,
    RP

    Comment

    • backups2007
      New Member
      • Jul 2007
      • 92

      #3
      Thanks for your reply but that's not what I want to do. As what I wrote on my post, I want to be able to pass queried data to rows of input text boxes.

      To add up to that, the queried data is displayed on a popup window that contains a combo list box. When the user clicks on, say for example a receipt number, the data is then passed to the parent form and automatically fills in the fields. As seen on my example above, the rows of textboxes are to be filled with data as well.

      Could the query be in some way converted to an array and then passed to the rows?

      Comment

      • backups2007
        New Member
        • Jul 2007
        • 92

        #4
        I re-read your reply and your idea actually can be a solution. but there's still a problem. I want the query data to be passed to rows of textboxes using a popup list box.

        the names of the texboxes are almost similar. the only difference they have is that they are numbered.

        Comment

        • rpnew
          New Member
          • Aug 2007
          • 189

          #5
          Originally posted by backups2007
          I re-read your reply and your idea actually can be a solution. but there's still a problem. I want the query data to be passed to rows of textboxes using a popup list box.

          the names of the texboxes are almost similar. the only difference they have is that they are numbered.
          Hi,
          well even i dont have much idea on how to send the data from the popup box back to the parent window.. If you have done something in this regards and having problem with that post back that code snap so that we can work with that to find your solution

          Regards,
          RP

          Comment

          Working...