Hi,
I am trying to develop a code that will allow user to update field name using <select></select> HTML command, and it appear that I am having difficult time finding a tutorial or example out there. I am a beginner of PHP Programmer so it is clearly that I do not know if it can be done or not?
For argument's sake, let's say that I am trying to develop a code that would allow you to assign team to ranking #. Instead of inputting/editting team name every time you want to update Top 25, it would be much easier to use drop-down menu with <select>.
Can this be done? The code I wrote, it seems that I have to write "SELECT" command using mysql_query for each <select> command like this:
<?php
include 'conn.php';
include 'opendb.php';
// select the database
mysql_select_db( 'rankdata' );
?>
<table width="600" cellpadding="0" cellspacing="0" border="0">
<tr>
<td>
<table width="300" cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="text">#1:</td>
<td><select><?php
$query ="SELECT * FROM ncaa";
$result =mysql_query($query) or die(mysql_error());
while ($row =mysql_fetch_array($result)){
echo "<option ".$row["team_name"].">".$row["team_name"]."</option>";
}
?></select></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td class="text">#2:</td>
<td><select><?
$query ="SELECT * FROM ncaa";
$result =mysql_query($query) or die(mysql_error());
while ($row =mysql_fetch_array($result)){
echo "<option ".$row["team_name"].">".$row["team_name"]."</option>";
}
?></select></td>
</tr>
</table>
Is there a way to write "SELECT" code on top of the page and use $row["team_name"] for each <select><option> code??
About the "UPDATE" code, this is what I have:
<?php
$query ="UPDATE ncaa SET seed='$newseed' WHERE team_name='$team_name'";
mysql_query($query);
?>
Where should I insert it? On the top or along with each #? The original plan was to assign 25 teams and submit once so it would update 25 teams at once to save time rather than to assign and submit individually.
My table reads like this:
Table name: ncaa
Value: id, team_name, seed, rec_win, rec_lose
text: 1, PHPTeam, seed, 1, 1
Note: "seed" was put there so it wouldn't display result until the team is assigned to ranking #.
I hope that you understand what I am trying to say? :bemused: My english is not great, but I hope you understood and thank you in advance for your answer.