Forum Moderators: coopster
Like this.
----Name------
-----Jim------
-----Bob------ (SELECTED)
-----Joe------
but it would vary for the different users. Sorry if this is confusing.
$sql = "SELECT * FROM some_table WHERE user='$user'";
If you have a list of users then you will need to get the value of $user from that list. So when you GET or POST the form you will need to use the value your user provides.
You may want to use print_r [uk2.php.net] to find out what the value of the request with user is.
You may also need to post some of your code so that we can see how you are trying to fit this into your site.
Welcome to WebmasterWorld.
You may want me to explain a bit more, because this is for a game. Laff Points is the health and gags are weapons.
(session.php contains information for if the user is logged in or logged out and the username info)
I'll replace the link to "#" when I figure it out. I want it so that when it's being edited, it will have already selected the current values for gags and laff points. It automatically configures the owner, so that won't need to change.
<?php
include("include/session.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<style type="text/css">
a:link {text-decoration: none; color: blue;}
a:visited {text-decoration: none; color: blue;}
a:active {text-decoration: none; color: blue;}
a:hover {text-decoration: underline; color: blue;}body {font-family : Verdana, Geneva, Arial, Helvetica, sans-serif; background-image: url(images/bg.png);}
table.style {
border-width: 1px;
border-spacing: 2px;
border-style: solid;
border-color: gray;
border-collapse: separate;
background-color: white;
}</style>
<title>Dust Bunny Guild - Adding A Toon</title>
</head>
<body>
<div align="center"><table width='65%' class="style"><tr><td>
<h1>Editing Toon</h1>
<br>
Your Toons:
<table align="left" border="1" cellspacing="0" cellpadding="3"><tr><td><b>Owner:</b></td><td><b>Laff Points:</b></td><td><b>Gags:</b></td><td><b>Edit:</b></td></tr>
<br>
<?
$usr = $session->username;
$username="user";
$password="pass";
$database="dbname";mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM toons WHERE owner = '$usr'";
$result=mysql_query($query);$num=mysql_numrows($result);
mysql_close();
$i=0;
while ($i < $num) {$owner = mysql_result($result,$i,"owner");
$laff = mysql_result($result,$i,"laff");
$toonup = mysql_result($result,$i,"toonup");
$trap = mysql_result($result,$i,"trap");
$lure = mysql_result($result,$i,"lure");
$sound = mysql_result($result,$i,"sound");
$throw = mysql_result($result,$i,"throw");
$squirt = mysql_result($result,$i,"squirt");
$drop = mysql_result($result,$i,"drop");echo "<tr><td>$owner</td><td>$laff</td><td>
<img src=\"images/gags/tu/$toonup.gif\">
<img src=\"images/gags/tr/$trap.gif\">
<img src=\"images/gags/lu/$lure.gif\">
<img src=\"images/gags/so/$sound.gif\">
<img src=\"images/gags/pi/$throw.gif\">
<img src=\"images/gags/sq/$squirt.gif\">
<img src=\"images/gags/dr/$drop.gif\"></td><td><a href=\"#\"><div align=\"center\">X</div></a></tr>";$i++;
}
?></td></tr></table></div>
</body>
</html>
[edited by: McBlack at 9:41 pm (utc) on Jan. 21, 2008]
As the mysql_result only gets a single cell, so you are looping through to get results that may be easier to work with as an array.
What sort of a list are you after? A checkbox list so people can select there requirements, or something different.
Also could you run the query with fetching an array and just output the array (cut some of the information out if the array is very large, just leave the bits you are interested in), so we can see what is stored in each of those fields, as you will need to write some conditional statements into your code to mark the checkboxes selected and for that we need to know the values.