stfc_boy
06-26-2007, 09:45 PM
Hello All,
My first post! Wondering if someone can kindly help me with this as i'm rally stuck!
I have some data from a MYSQL database:
http://www.sloughtownfc.net/statistics.jpg
Now I’d like to edit the data in this database so I need do two things:
1) Place the values in this database in the appropriate from elements within my form below
2) Edit and UPDATE those details in the database
Now to be blatantly honest I have not got the foggiest how to do this as I’m not sure how the implode function works and how foreach works using UPDATE and GET. Here’s my INSERT script. Can anyone please help as to how I can achieve this where match_id=1.
<?php
if(isset($_POST['Submit']))
{
$match_id=mysql_insert_id();
if(!isset($_GET['match_id']))
{ $match_id = $_GET['match_id'];
foreach($_REQUEST['r'] as $position => $row)
{ $row = implode("', '",$row);
$result = mysql_query("Insert into player_stats(position,name,goals,match_id)
values('$position','$row','$match_id')");
}
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Player stats</title>
</head>
<body>
<form name="statistics" method="post" action="">
<table width="100%">
<tr>
<td width="33%">Player</td>
<td width="33%">Name</td>
<td width="33%">Goals</td>
</tr>
<tr>
<td width="33%">Goalkeeper:</td>
<td width="33%"><input name="r[goalkeeper][name]" type="text"></td>
<td width="33%"><input name="r[goalkeeper][goals]" type="text" /></td>
</tr>
<tr>
<td width="33%">Player Two</td>
<td width="33%"><input name="r[player_two][name]" type="text" /></td>
<td width="33%"><input name="r[player_two][goals]" type="text" /></td>
</tr>
<tr>
<td width="33%">Player Three</td>
<td width="33%"><input name="r[player_three][name]" type="text" /></td>
<td width="33%"><input name="r[player_three][goals]" type="text" /></td>
</tr>
<tr>
<td width="33%">Player Four</td>
<td width="33%"><input name="r[player_four][name]" type="text" /></td>
<td width="33%"><input name="r[player_four][goals]" type="text" /></td>
</tr>
<tr>
<td width="33%">Player Five</td>
<td width="33%"><input name="r[player_five][name]" type="text" /></td>
<td width="33%"><input name="r[player_five][goals]" type="text" /></td>
</tr>
</table>
<input type="submit" name="Submit" value="Submit"/>
</form>
</body>
</html>
Thank you so much. If anyone could help it would be fantastic
Chris
My first post! Wondering if someone can kindly help me with this as i'm rally stuck!
I have some data from a MYSQL database:
http://www.sloughtownfc.net/statistics.jpg
Now I’d like to edit the data in this database so I need do two things:
1) Place the values in this database in the appropriate from elements within my form below
2) Edit and UPDATE those details in the database
Now to be blatantly honest I have not got the foggiest how to do this as I’m not sure how the implode function works and how foreach works using UPDATE and GET. Here’s my INSERT script. Can anyone please help as to how I can achieve this where match_id=1.
<?php
if(isset($_POST['Submit']))
{
$match_id=mysql_insert_id();
if(!isset($_GET['match_id']))
{ $match_id = $_GET['match_id'];
foreach($_REQUEST['r'] as $position => $row)
{ $row = implode("', '",$row);
$result = mysql_query("Insert into player_stats(position,name,goals,match_id)
values('$position','$row','$match_id')");
}
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Player stats</title>
</head>
<body>
<form name="statistics" method="post" action="">
<table width="100%">
<tr>
<td width="33%">Player</td>
<td width="33%">Name</td>
<td width="33%">Goals</td>
</tr>
<tr>
<td width="33%">Goalkeeper:</td>
<td width="33%"><input name="r[goalkeeper][name]" type="text"></td>
<td width="33%"><input name="r[goalkeeper][goals]" type="text" /></td>
</tr>
<tr>
<td width="33%">Player Two</td>
<td width="33%"><input name="r[player_two][name]" type="text" /></td>
<td width="33%"><input name="r[player_two][goals]" type="text" /></td>
</tr>
<tr>
<td width="33%">Player Three</td>
<td width="33%"><input name="r[player_three][name]" type="text" /></td>
<td width="33%"><input name="r[player_three][goals]" type="text" /></td>
</tr>
<tr>
<td width="33%">Player Four</td>
<td width="33%"><input name="r[player_four][name]" type="text" /></td>
<td width="33%"><input name="r[player_four][goals]" type="text" /></td>
</tr>
<tr>
<td width="33%">Player Five</td>
<td width="33%"><input name="r[player_five][name]" type="text" /></td>
<td width="33%"><input name="r[player_five][goals]" type="text" /></td>
</tr>
</table>
<input type="submit" name="Submit" value="Submit"/>
</form>
</body>
</html>
Thank you so much. If anyone could help it would be fantastic
Chris