By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,360 Members | 2,961 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,360 IT Pros & Developers. It's quick & easy.

passing query data to different rows of input text boxes

P: 92
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_container";

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.
Jan 24 '08 #1
Share this Question
Share on Google+
4 Replies


rpnew
100+
P: 188
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_container";

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_container";
$result=mysql_query($query);
while(list($prd,$qty)=mysql_fetch_array($result))
{
echo "<input type='text' name='prod_id' value='$prd'><input 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
Jan 24 '08 #2

P: 92
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?
Jan 25 '08 #3

P: 92
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.
Jan 28 '08 #4

rpnew
100+
P: 188
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
Jan 29 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.