Shawn Posted March 7, 2006 Share Posted March 7, 2006 Red highlight item.$query=mysql_query("select * from member");while (list($mno,$id,$pw,$nick,$team)=mysql_fetch_row($query)){ $mgoal=$_POST["goal$mno"]; $massist=$_POST["assist$mno"]; $attend=$_POST["attend$mno"]; if ($attend!="") { $attend="checked"; } $check=mysql_query("select * from record where matchid='$no' and mno='$mno'"); $row=mysql_num_rows($check); if ($row==0) $record="insert record (matchid,mno,mgoal,massist,attend) values ('$no','$mno','$mgoal','$massist','$attend')"; mysql_query($record); echo "a"; } else { $update="update record set mgoal='$mgoal',massist='$massist',attend='$attend' where matchid='$no' and mno='$mno'"; mysql_query($update); echo $no; }} Link to comment Share on other sites More sharing options...
Guest gahzinia Posted March 7, 2006 Share Posted March 7, 2006 if ($row==0) $record="insert record (matchid,mno,mgoal,massist,attend) values ('$no','$mno','$mgoal','$massist','$attend')"; mysql_query($record);Shouldn't it be$record = "insert into record (matchid,mno,mgoal,massist,attend) values ('$no','$mno','$mgoal','$massist','$attend')";?Also, what is the error that you're getting? Just taking a quick look at the code, why do ou have the top 2/3 all in the while loop? Indenting the code would help a lot in tracing it. Link to comment Share on other sites More sharing options...
Shawn Posted March 8, 2006 Author Share Posted March 8, 2006 Hi gahzinia.I have not get error message, it also can add 1 row, but the value of mgoal,massist,attend is 0,0,0. matchid and mno is no problem. Link to comment Share on other sites More sharing options...
sbrownii Posted March 8, 2006 Share Posted March 8, 2006 do the post variables actually exist?if you echo $mgoal, $massist and $attend right after this: $mgoal=$_POST["goal$mno"];$massist=$_POST["assist$mno"];$attend=$_POST["attend$mno"]; what do you get? Link to comment Share on other sites More sharing options...
Shawn Posted March 11, 2006 Author Share Posted March 11, 2006 Sorry for my late reply,I have a input page before. below is my script. THanks $list=mysql_query("select * from member");while (list($mno,$id,$pw,$nick,$team)=mysql_fetch_row($list)){ $check=mysql_query("select * from record where matchid='$no' and mno='$mno'"); list($rno,$matchid,$mno,$mgoal,$massist,$attend)=mysql_fetch_row($check); $mgoal=$mgoal; $massist=$massist; echo "<tr><td>$nick"; echo "<td><input type=text name=goal$mno size=1 maxlength=2 value=$mgoal>"; echo "<td><input type=text name=assist$mno size=1 maxlength=2 value=$massist>"; echo "<td><input type=checkbox name=attend$mno $attend>";} Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now