Updating a records in a mysql database
Posted: Tue Jul 18, 2006 6:17 am
feyd | Please use
manage-friends.php
What happens is that if I have more than 1 "friend" showing to be reviewed only 1 of them get's changed even when a radio button for each has been selected and also it does not update them with the value of the redio button, it just makes the field empty.
Is anyone able to help, I hope I've made it so you can understand but appreciate that it can be a bit confusing when I try to explain some things
Cheers
Wardy
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hi guys, I have a bti of a problem and was hoping for a bit of help if possible (well and you can understand my problem).
I have a page called "friends.php" that lists the name of users who have tried to add you to their friends list.
Before the people are added the user has to either accept or decline them by selecting the relevant radio button (radio buttom to accept has a value of 2 and button to decline has a value of 3). The radio button names are the "frienduserid".
A user could have a number of frieds to add or decline all in 1 go but I am for some reason having trouble getting this to work despite knowing it should be relatively simple
friends.phpCode: Select all
echo("<form method=\"post\" action=\"manage-friends.php\">");
echo("<table>");
while($row = mysql_fetch_array($result)){
if ($bgcolor == "#FFFFFF"){
$bgcolor = "#FFFFFF";
}else{
$bgcolor = "#FFFFFF";
}
echo("<tr bgcolor=".$bgcolor.">\n<td>");
echo("<td width=".$tdwidth." bgcolor=".$bgcolor2.">");
echo("<font face=".$font.">");
echo('<a href="../poker/user.php?username=' . $row["friendusername"] . '">' . $row["friendusername"] . '</a>');
echo("<td width=".$tdwidth." bgcolor=".$bgcolor3.">");
echo('<input type="radio" name="' . $row["frienduserid"] . '" value="2">');
echo("<td width=".$tdwidth." bgcolor=".$bgcolor4.">");
echo('<input type="radio" name="' . $row["frienduserid"] . '" value="3">');
}
echo "<br>";
echo "<input type=\"submit\" name=\"Submit\" value=\"SAVE\"/>";
echo("</table>");
echo ("</form>");Code: Select all
$userid = intval($_SESSION['userid']); // get it from the session and make sure its an integer
// now let's save the information
$result = mysql_query("UPDATE friends SET verified='$frienduserid' WHERE userid='$userid' AND frienduserid='$frienduserid2'");
if($result == 0) die("Error Updating Friends. MySQL said: " . mysql_error());
echo("New information saved");Is anyone able to help, I hope I've made it so you can understand but appreciate that it can be a bit confusing when I try to explain some things
Cheers
Wardy
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]