srhino Posted October 30, 2007 Share Posted October 30, 2007 I am new to PHP and I figured out how to update my database using my form...Now I want my form to fill in the text boxes with the information thats already stored in the database. How can I do this? Here is my update form so far. AM I ON THE RIGHT TRACK? and what do I need to do? THANKS <?php $con = mysql_connect("localhost","xxx", "xxx") or die('Sorry could not connect to database at this time'); mysql_select_db("tennis", $con)or die('Sorry, could not connect to database'); $query = "SELECT matchid, playera, playerb, set1a, set1b, set2a, set2b, set3a, set3b, set4a, set4b, set5a, set5b from tennis1 order by matchid"; $result = mysql_query($query) or die('Sorry, could not get tournaments at this time'); if (mysql_num_rows($result) ==0){ echo "<h3> Sorry, There are no tournaments at this time, please try back later.</h3>";} else { while($row=mysql_fetch_array($result, MYSQL_ASSOC)) { $matchid = $row['matchid']; $playera = $row['playera']; $playerb = $row['playerb']; $set1a = $row['set1a']; $set1b = $row['set1b']; $set2a = $row['set2a']; $set2b = $row['set2b']; $set3a = $row['set3a']; $set3b = $row['set3b']; $set4a = $row['set4a']; $set4b = $row['set4b']; $set5a = $row['set5a']; $set5b = $row['set5b']; }}?> <form action="index.php" method="post"> <table width="100%" border="1"> <tr><td colspan="6"><h2>Enter New Scoring</h2></td></tr> <tr><td colspan="2" align="center">Matchid:<input type= "text" size="40" name="matchid"></td> <td colspan="2" align="center">Teama:<input type= "text" size="40" name="teama"></td> <td colspan="2" align="center">Teamb:<input type= "text" size="40" name="teamb"></td></tr> <tr><td>Playera:<input type="text" size="40" name="playera"></td> <td>set1a:<input type="text" size="5" name="set1a"></td> <td>set2a:<input type="text" size="5" name="set2a"></td> <td>set3a:<input type="text" size="5" name="set3a"></td> <td>set4a:<input type="text" size="5" name="set4a"></td> <td>set5a:<input type="text" size="5" name="set5a"></td></tr> <tr><td>Playerb:<input type="text" size="40" name="playerb"></td> <td>set1b:<input type="text" size="5" name="set1b"></td> <td>set2b:<input type="text" size="5" name="set2b"></td> <td>set3b:<input type="text" size="5" name="set3b"></td> <td>set4b:<input type="text" size="5" name="set4b"></td> <td>set5b:<input type="text" size="5" name="set5b"></td></tr> <TR><TD colspan="6" align="center"><input type="submit" value="Submit"> <input type="hidden" name="content" value="update"></TD></TR> </table></form> Link to comment https://forums.phpfreaks.com/topic/75364-solved-need-help-with-update-and-php-forms/ Share on other sites More sharing options...
rajivgonsalves Posted October 30, 2007 Share Posted October 30, 2007 here you go <td>set1a:<input type="text" size="5" name="set1a" value="<?=$set1a?>"></td> and so on for all the fields Link to comment https://forums.phpfreaks.com/topic/75364-solved-need-help-with-update-and-php-forms/#findComment-381158 Share on other sites More sharing options...
srhino Posted November 1, 2007 Author Share Posted November 1, 2007 Thanks, I was close but not close enough I really appreciate your help. Link to comment https://forums.phpfreaks.com/topic/75364-solved-need-help-with-update-and-php-forms/#findComment-382937 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.