stig1 Posted October 2, 2008 Share Posted October 2, 2008 I have a table filled with data that I get returned from MySQL using the mysql_fetch_array() function. Within the table rows, I have an input box that I would like to set each value different. Eg. $qty[0], $qty[1], $qty[2]. And so on, until it reaches the end of the data range set. Is this possible? Simple? Any help most apprecaited. Link to comment https://forums.phpfreaks.com/topic/126712-probably-very-simple-answer-i-hope/ Share on other sites More sharing options...
CroNiX Posted October 2, 2008 Share Posted October 2, 2008 <?php while($qty = mysql_fetch_array($result)){ echo "<tr><td><input type=\"text\" value=\"" . $qty[0] . "\" /></td></tr>\n"; } or something close to that Link to comment https://forums.phpfreaks.com/topic/126712-probably-very-simple-answer-i-hope/#findComment-655383 Share on other sites More sharing options...
stig1 Posted October 2, 2008 Author Share Posted October 2, 2008 that would work for a dataset that only returns 1 row.. but say i have 5 or 10 rows of data. Link to comment https://forums.phpfreaks.com/topic/126712-probably-very-simple-answer-i-hope/#findComment-655385 Share on other sites More sharing options...
redarrow Posted October 2, 2008 Share Posted October 2, 2008 <?php $res=array("cat","dog","pig"); ?> <form method="POST" action="<?php echo $_SERVER['PHP_SELF'] ?>" "> <br> <?php foreach( $res as $r){ $replace=array("cat","pig",$r); $replace_with=array("mice","tigger",$r); $r=str_replace($replace,$replace_with,$r); ?> <input type="test" name="<?php echo $r; ?>" value="<?php echo $r;?>" > <?php } ?> <br> <input type="submit" name="submit" value="SEND!"> </form> Link to comment https://forums.phpfreaks.com/topic/126712-probably-very-simple-answer-i-hope/#findComment-655386 Share on other sites More sharing options...
Barand Posted October 2, 2008 Share Posted October 2, 2008 that would work for a dataset that only returns 1 row.. but say i have 5 or 10 rows of data. why do you think that? You will have to alter the [ 0 ] to the correct column offset for the qty value. Link to comment https://forums.phpfreaks.com/topic/126712-probably-very-simple-answer-i-hope/#findComment-655511 Share on other sites More sharing options...
stig1 Posted October 2, 2008 Author Share Posted October 2, 2008 How would I do that dynamic? Cause I couldn't put the values in manual, due to each table could have a different number of rows. Does the mysql_fetch_array function, have like an echo the array ID out? Link to comment https://forums.phpfreaks.com/topic/126712-probably-very-simple-answer-i-hope/#findComment-656008 Share on other sites More sharing options...
CroNiX Posted October 2, 2008 Share Posted October 2, 2008 What id are you talking about? The array index? I was only going by the example that you gave, $qty[0], $qty[1], $qty[2]... The code I posted will create that table row for each qty in the result array... Link to comment https://forums.phpfreaks.com/topic/126712-probably-very-simple-answer-i-hope/#findComment-656014 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.