gospabode2 Posted May 16, 2011 Share Posted May 16, 2011 Hello, I am new to PHP and am trying to build a couple of webpages that when the first is submitted, posts to the next webpages, and the PHP recieves it, then accesses the database according to the posted variables and displays the information in a form. I have gotten this to work on other pages, so I don't see what the issue is. I am not getting any results on the next page. Only a white screen. I think there must be some error in the semantics somewhere, but I, for the life of me, cannot figure it out. Please Help! In essence, here's what it is: First Page: <form action="editchild2.php" method="post"> <input type="checkbox" name="checkbox[]" value="' . $row['IDa'] . '"/> <input type="submit" value="Update Child" /> Receiving Page: <?php mysql_connect("database","table","password") or die(mysql_error()); mysql_select_db("table") or die(mysql_error()); $IDa = $_POST['checkbox']; $result = mysql_query("SELECT * FROM orphans WHERE IDa='$IDA'") or die(mysql_error()); mysql_fetch_array($result) or die(mysql_error()); $outputtable = ''; while($row = mysql_fetch_array($result)){ $idas = $row['IDa']; $firstname = $row['FirstName']; $lastname = $row['LastName']; $birthdate = $row['Birthdate']; $gender = $row['Gender']; $sponsorcount = $row['SponsorCount']; $createdon = $row['Created_On']; $changedon = $row['Changed_On']; $descip = $row['Despcription']; $pictureone = $row['PictureOne']; $picturetwo = $row['PictureTwo']; $picturethree = $row['PictureThree']; $picturefour = $row['PictureFour']; $picturefive = $row['PictureFive']; $outputtable .= '<tr>' . '<td>ID#: </td>' . '<td><input type="text" name="IDa" value="' . $idas . '" readonly="readonly"/></td>' . '</tr>' . '''<tr>' . '<td>First Name: </td>' . '<td><input type="text" name="FirstName" value="' . $firstname . '" /></td>' . '</tr>' . '<tr>' . '<td>Last Name: </td>' . '<td><input type="text" name="LastName" value="' . $lastname . '" /></td>' . '</tr>' . '<tr>' . '<td>Birth Date: </td>' . '<td><input type="text" name="BirthDate" value="' . $birthdate . '" /></td>' . '</tr>' . '<tr>' . '<td>Gender: </td>' . '<td><input type="text" name="Gender" value="' . $gender . '" /></td>' . '</tr>' . '<tr>' . '<td>Sponsor Count: </td>' . '<td><input type="text" name="SponsorCount" value="' . $sponsorcount . '" /></td>' . '</tr>' . '<tr>' . '<td>Created On: </td>' . '<td><div id="calendarDiv"></div><input type="text" name="Created_On" readonly="readonly" value="' . $createdon . '" /></td>' . '</tr>' . '<tr>' . '<td>Updated On: </td>' . '<td><div id="calendarDiv"></div><input type="text" name="Changed_On" class="calendarSelectDate" value="' . $changedon . '"/></td>' . '<tr>' . '<td>Description: </td>' . '<td><textarea name="Description" cols="25" rows="10"value="' . $descrip . '"></textarea></td>' . '</tr>' . '<tr>' . '<td>Picture #1: </td>' . '<td><input type="text" name="PictureOne" value="' . $pictureone . '"/></td>' . '</tr>' . '<tr>' . '<td>Picture #2: </td>' . '<td><input type="text" name="PictureTwo" value="' . $picturetwo . '" /></td>' . '</tr>' . '<tr>' . '<td>Picture #3: </td>' . '<td><input type="text" name="PictureFour" value="' . $picturethree . '"/></td>' . '</tr>' . '<tr>' . '<td>Picture #4: </td>' . '<td><input type="text" name="PictureFour" value="' . $picturefour . '"/></td>' . '</tr>' . '<tr>' . '<td>Picture #5: </td>' . '<td><input type="text" name="PictureFive" value="' . $picturefive . '"/></td>' . '</tr>' . '<tr>' . '<td><input type="submit" />'; } ?> <!Doctype html> <html> <head> <!--Stylesheets and Stuff--> </head> <body> <!--Divs and Paragraphs--> <form action="updatechild.php" method="post"> <table border="0"> <?php print "$outputtable"; ?> </table> </form> <!--/Divs and Paragraphs--> </body> </html> Whoops: Edited to Fix Stupid Mistakes. Quote Link to comment https://forums.phpfreaks.com/topic/236587-post-help/ Share on other sites More sharing options...
DavidAM Posted May 16, 2011 Share Posted May 16, 2011 <input type="checkbox" name="checkbox[]" value="' . $row['IDa'] . '"/> $IDa = $_POST['checkbox']; mysql_query("SELECT * FROM orphans WHERE IDa='$IDA'") You are defining the field as an array, but then referencing it as if it were a string. Without seeing the rest of your code, I suspect you need to reference the first element of the array: $IDa = $_POST['checkbox'][0]; or change the checkbox so it does not create an array field: <input type="checkbox" name="checkbox" value="' . $row['IDa'] . '"/> Quote Link to comment https://forums.phpfreaks.com/topic/236587-post-help/#findComment-1216244 Share on other sites More sharing options...
gospabode2 Posted May 16, 2011 Author Share Posted May 16, 2011 Thanks DavidAM, That fixed a whole lot of issues, although I still have a couple of questions, if you don't mind. I copied the below method of printing it out from another tutorial, and was wondering if there is an issue with this code specifically, because when I insert it, everything goes white, but when I replace it with: $outputtable .= "hello"; Everything works great. Here is the code, I am wondering about: $outputtable = '<tr>' . '<td>ID#: </td>' . '<td><input type="text" name="IDa" value="' . $idas . '" readonly="readonly"/></td>' . '</tr>' . '''<tr>' . '<td>First Name: </td>' . '<td><input type="text" name="FirstName" value="' . $firstname . '" /></td>' . '</tr>' . '<tr>' . '<td>Last Name: </td>' . '<td><input type="text" name="LastName" value="' . $lastname . '" /></td>' . '</tr>' . '<tr>' . '<td>Birth Date: </td>' . '<td><input type="text" name="BirthDate" value="' . $birthdate . '" /></td>' . '</tr>' . '<tr>' . '<td>Gender: </td>' . '<td><input type="text" name="Gender" value="' . $gender . '" /></td>' . '</tr>' . '<tr>' . '<td>Sponsor Count: </td>' . '<td><input type="text" name="SponsorCount" value="' . $sponsorcount . '" /></td>' . '</tr>' . '<tr>' . '<td>Created On: </td>' . '<td><div id="calendarDiv"></div><input type="text" name="Created_On" readonly="readonly" value="' . $createdon . '" /></td>' . '</tr>' . '<tr>' . '<td>Updated On: </td>' . '<td><div id="calendarDiv"></div><input type="text" name="Changed_On" class="calendarSelectDate" value="' . $changedon . '"/></td>' . '<tr>' . '<td>Description: </td>' . '<td><textarea name="Description" cols="25" rows="10"value="' . $descrip . '"></textarea></td>' . '</tr>' . '<tr>' . '<td>Picture #1: </td>' . '<td><input type="text" name="PictureOne" value="' . $pictureone . '"/></td>' . '</tr>' . '<tr>' . '<td>Picture #2: </td>' . '<td><input type="text" name="PictureTwo" value="' . $picturetwo . '" /></td>' . '</tr>' . '<tr>' . '<td>Picture #3: </td>' . '<td><input type="text" name="PictureFour" value="' . $picturethree . '"/></td>' . '</tr>' . '<tr>' . '<td>Picture #4: </td>' . '<td><input type="text" name="PictureFour" value="' . $picturefour . '"/></td>' . '</tr>' . '<tr>' . '<td>Picture #5: </td>' . '<td><input type="text" name="PictureFive" value="' . $picturefive . '"/></td>' . '</tr>' . '<tr>' . '<td><input type="submit" />'; Quote Link to comment https://forums.phpfreaks.com/topic/236587-post-help/#findComment-1216253 Share on other sites More sharing options...
DavidAM Posted May 16, 2011 Share Posted May 16, 2011 You have an extra set of single-quotes at the start of the second row. $outputtable = '<tr>' . '<td>ID#: </td>' . '<td><input type="text" name="IDa" value="' . $idas . '" readonly="readonly"/></td>' . '</tr>' . '''<tr>' . // <<RIGHT HERE But must likely the problem is that you don't have a table tag. You need to start a table with <TABLE> and end it with </TABLE>. Quote Link to comment https://forums.phpfreaks.com/topic/236587-post-help/#findComment-1216257 Share on other sites More sharing options...
gospabode2 Posted May 16, 2011 Author Share Posted May 16, 2011 The Extra Quotes was IT! I was looking all over for something like that, but after a while of looking at your own code, everything lookes fine. I had the </table> inside of the document, I just didn't show it because it wasn't the PHP code I was worried about, but great eyes! You have been a tremendous help. Quote Link to comment https://forums.phpfreaks.com/topic/236587-post-help/#findComment-1216259 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.