Jump to content

Recommended Posts

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>

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.