Hello,
I have recently created a table where members of a guild have points attributed to there characters.
On the backend of this scorekeeping system i wanted a way to select a large number of characters (via check boxes) and add a set value to all of their existing respective scores.
here is my code that is supposed to handle the input from the first page:
[code]<?
$username=“";
$password="”;
$database="********";
mysql_connect(localhost,$username,$password);
mysql_select_db($database) or die( “Unable to select database”); // connects to db
$query=“SELECT * FROM dkp”;
$query2=“UPDATE dkp SET dkp
=’$ud_dkp’ WHERE id
=’$id’”;
$result=mysql_query($query); //run first quesry
$num=mysql_numrows($result); //count rows
$ud_val=$_POST[‘value’]; // grab a # from page before which we will be adding
// to characters selected on page before
$i=0;
while ($i < $num) { // loop through all the rows
$character=mysql_result($result,$i,“character”); // grab chacter name from db
$tempchar=$_POST[$character]; // grab the post data of character name from the page before
if ($tempchar){ // this character value is either selected (ture) or not (false)
// if it was selected it needs to be updated
$dkp=mysql_result($result,$i,“dkp”); // grab existing pt value
$ud_dkp=$ud_val+$dkp; // add set amt to existing
$id=mysql_result($result, $i,“id”); // grab character id
echo “$character updated to $ud_dkp
”;
mysql_query($query2); // run query 2
}
$i++;
}
mysql_close(); // close db connection
?>
[/code]
i run through this and it actually does echo only those i have selected and it does display their new ‘dkp’ as the correct updated amount, however when i goto a new page that simply outputs the data base, i see that nothing has changed.
the information isn’t being updated. i’ve tried using mysql_close() after the first query then opening a new connection for each addition but that also does not work.
if any of you could help me out i would be most appriciative.
thx~