stfc_boy
07-14-2007, 01:54 PM
Hi Guys,
Here's my database which shows which type of cards have been issued to a football player in my database:
http://www.sloughtownfc.net/cards.jpg
The below script looks through all of my records in my database and outputs the type of card issued to each player (stats_id):
<?php
$databaseInfo = mysql_query("SELECT * From player_stats") or die(mysql_error());
// Update the new values in the database
if(isset($_POST['Submit']))
{
for($i = 0; $i < count($_REQUEST['bks']) ; $i++)
{
$result = mysql_query("Update player_stats set cards ='".$_REQUEST['bks'][$i]."' WHERE stats_id=".$_REQUEST['id'][$i]) OR DIE(mysql_error());
}
} //end of post
?>
<?php while ($databaseArray = mysql_fetch_array($databaseInfo)){ ?>
<input name="bks[]" type="text" id="bks" value="<?php echo $databaseArray['cards']?>" size="36" />
<?php } // end of while loop ?>
<input type="submit" name="Submit" value="Submit" class="button">
<input type="reset" name="Reset" value="Reset" class="button"></td>
</form>
</body>
</html>
And this works great, and as you can see each value in the database holds the word yellow or red or nothing. So on this line where it outputs the data from the database
<input name="bks[]" type="text" id="bks" value="<?php echo $databaseArray['cards']?>" size="36" />
I want to change the form element to a dropdown menu rather than a input box.
With the value in the database automatically selected ie yellow or red or nothing (which says the words please select)
And then have the option to change those values for each record?
Hope that's clearer - can you help?
Thanks
Chris
Here's my database which shows which type of cards have been issued to a football player in my database:
http://www.sloughtownfc.net/cards.jpg
The below script looks through all of my records in my database and outputs the type of card issued to each player (stats_id):
<?php
$databaseInfo = mysql_query("SELECT * From player_stats") or die(mysql_error());
// Update the new values in the database
if(isset($_POST['Submit']))
{
for($i = 0; $i < count($_REQUEST['bks']) ; $i++)
{
$result = mysql_query("Update player_stats set cards ='".$_REQUEST['bks'][$i]."' WHERE stats_id=".$_REQUEST['id'][$i]) OR DIE(mysql_error());
}
} //end of post
?>
<?php while ($databaseArray = mysql_fetch_array($databaseInfo)){ ?>
<input name="bks[]" type="text" id="bks" value="<?php echo $databaseArray['cards']?>" size="36" />
<?php } // end of while loop ?>
<input type="submit" name="Submit" value="Submit" class="button">
<input type="reset" name="Reset" value="Reset" class="button"></td>
</form>
</body>
</html>
And this works great, and as you can see each value in the database holds the word yellow or red or nothing. So on this line where it outputs the data from the database
<input name="bks[]" type="text" id="bks" value="<?php echo $databaseArray['cards']?>" size="36" />
I want to change the form element to a dropdown menu rather than a input box.
With the value in the database automatically selected ie yellow or red or nothing (which says the words please select)
And then have the option to change those values for each record?
Hope that's clearer - can you help?
Thanks
Chris