wobuck Posted November 22, 2010 Share Posted November 22, 2010 I generate php form lines from a database but cannot work out how to recover the text fields for lines 1, 2 & 4 using get or post - can anyone help? The url string below(get to see what is happening) contains titles BF and SG in lines 1 and 2 for the field name 'book' and then TG for line 4 but no title for line 3: http://localhost/test/test.php ?book%5BArray%3F%5D=BF&row_count=Array%3F &book%5BArray%3F%5D=SG&row_count=Array%3F &book%5BArray%3F%5D=&row_count=Array%3F &book%5BArray%3F%5D=TG&row_count=Array%3F Link to comment https://forums.phpfreaks.com/topic/219474-recovery-of-datafields-from-a-special-get-form/ Share on other sites More sharing options...
AbraCadaver Posted November 22, 2010 Share Posted November 22, 2010 WHAT?!?! Link to comment https://forums.phpfreaks.com/topic/219474-recovery-of-datafields-from-a-special-get-form/#findComment-1138033 Share on other sites More sharing options...
Pikachu2000 Posted November 22, 2010 Share Posted November 22, 2010 Ummmm . . . You might want to try to clarify your problem a little bit. Or a lot, actually. Link to comment https://forums.phpfreaks.com/topic/219474-recovery-of-datafields-from-a-special-get-form/#findComment-1138059 Share on other sites More sharing options...
wobuck Posted November 22, 2010 Author Share Posted November 22, 2010 Apologies, I have not explained my issue very well. I am using the 'print' command within a php form to display a number of lines from a database so that I can then enter more data against the displayed lines as <Input type=text> The command lines looks like this: print("<form id=\bookform\" action=\"book.php\" method=\"get\">"); while($row = mysql_fetch_row($result)) { print("<td><input type=\"text\" style=\"width: 60px\" name=\"book[$row?]\"></td>"); print("<td><INPUT TYPE=\"hidden\" name=\"row_count\" value=\"$row?"></INPUT></td>"); } print("<td><input value=\"UPDATE BOOKS\" type=\"Submit\"></td></tr>"); I then try to retrieve the entered data from the form in the book.php program thus: $book = $_GET[book']; $row_count = $_GET['row_count']; $row=0; while ($row<$row_count) { echo('<tr><td><font face="Arial" size="2"><strong>*'.book[$row_count].'*</strong></font></td></tr>'); $row++; } Nothing appears to be retrieved to echo? I have tried both post and get Link to comment https://forums.phpfreaks.com/topic/219474-recovery-of-datafields-from-a-special-get-form/#findComment-1138072 Share on other sites More sharing options...
Pikachu2000 Posted November 22, 2010 Share Posted November 22, 2010 Is that the actual code you're using? What is in the raw html when you do a 'View Source'? Link to comment https://forums.phpfreaks.com/topic/219474-recovery-of-datafields-from-a-special-get-form/#findComment-1138075 Share on other sites More sharing options...
wobuck Posted November 22, 2010 Author Share Posted November 22, 2010 I extracted the raw code for the 1st line: <input type="text" style="width: 60px" name="book[Array?]"> <INPUT TYPE="hidden" name="row_count" value="Array?"></INPUT> Link to comment https://forums.phpfreaks.com/topic/219474-recovery-of-datafields-from-a-special-get-form/#findComment-1138080 Share on other sites More sharing options...
wobuck Posted November 22, 2010 Author Share Posted November 22, 2010 Problem resolved!! I was using $row which was also being used to extract the database records. Once I declared another variable data started being passed correctly after using a foreach statement in the receiving php program. Link to comment https://forums.phpfreaks.com/topic/219474-recovery-of-datafields-from-a-special-get-form/#findComment-1138108 Share on other sites More sharing options...
AbraCadaver Posted November 22, 2010 Share Posted November 22, 2010 Why not do away with the counting altogether? foreach($_GET['book'] as $book) { echo('<tr><td><font face="Arial" size="2"><strong>*'.$book.'*</strong></font></td></tr>'); } Link to comment https://forums.phpfreaks.com/topic/219474-recovery-of-datafields-from-a-special-get-form/#findComment-1138148 Share on other sites More sharing options...
wobuck Posted November 23, 2010 Author Share Posted November 23, 2010 Yes, much cleaner! Many Thanks Link to comment https://forums.phpfreaks.com/topic/219474-recovery-of-datafields-from-a-special-get-form/#findComment-1138240 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.