Hi everyone,
I'm wondering if you could help me with what is starting to give me a bit of a headache. I am trying to create a league table and then store this information in a database. However I am struggling a bit with it. So far I have the following code....
echo '<form action="#" method="post">';
echo '<table>';
echo '<tr>';
echo '<td>Position</td>';
echo '<td>Club Name</td>';
echo '<td>Ply</td>';
echo '<td>Won</td>';
echo '<td>Drw</td>';
echo '<td>Lst</td>';
echo '</tr>';
echo '<tr>';
echo '<td><input type="hidden" name="row[1]" value="1"> <input type="text" name="position[1]" maxlength="50" /></td>';
echo '<td><input type="text" name="clubName[1]" maxlength="50" /></td>';
echo '<td><input type="text" name="played[1]" maxlength="50" /></td>';
echo '<td><input type="text" name="won[1]" maxlength="50" /></td>';
echo '<td><input type="text" name="draw[1]" maxlength="50" /></td>';
echo '<td><input type="text" name="lost[1]" maxlength="50" /></td>';
echo '</tr>';
echo '<tr>';
echo '<td><input type="hidden" name="row[2]" value="2"> <input type="text" name="position[2]" maxlength="50" /></td>';
echo '<td><input type="text" name="clubName[2]" maxlength="50" /></td>';
echo '<td><input type="text" name="played[2]" maxlength="50" /></td>';
echo '<td><input type="text" name="won[2]" maxlength="50" /></td>';
echo '<td><input type="text" name="draw[2]" maxlength="50" /></td>';
echo '<td><input type="text" name="lost[2]" maxlength="50" /></td>';
echo '</tr>';
echo '<tr>';
echo '<td><input type="hidden" name="row[3]" value="3"> <input type="text" name="position[3]" maxlength="50" /></td>';
echo '<td><input type="text" name="clubName[3]" maxlength="50" /></td>';
echo '<td><input type="text" name="played[3]" maxlength="50" /></td>';
echo '<td><input type="text" name="won[3]" maxlength="50" /></td>';
echo '<td><input type="text" name="draw[3]" maxlength="50" /></td>';
echo '<td><input type="text" name="lost[3]" maxlength="50" /></td>';
echo '</tr>';
echo '<table>';
As you can see I have a table with some rows. Each row represents a position in the league table. I'll be using some javascript at a later date to control the addition of new rows.
What I want to do in php is loop through of the table's row and insert the position, club name, games played, wins, defeats and draws. Once that is done I want to go to the next row and repeat this step until all of the form fields have been done. I figured this would be a simple case of looping through all the form fields on the page but it doesn't seem quite that simple.
Feel free to change the html mark up if you think I'm going wrong there....
Appreciate any help. Been banging my head against the wall now for a few hours with this. Not sure I can see the wood for the trees now...