Radio buttons, select menus, etc. in PHP
| From: | Jason Curole | Date: | Tue, 29 Apr 2003 15:59:45 +0000 |
| Subject: | Radio buttons, select menus, etc. in PHP | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-27431@lists.php.net to get a copy of this message | ||
Hello,
This is a more general PHP question: can someone point me to a good tutorial
on how to make these HTML selection devices work in PHP. I can make the
code below work, but I am not quite certain what I am doing (I understand
what¹s going on up to the if statement).
Thanks, Jason
function GetGenOpts ($aTableName, $column_name, $aCurSel = "")
{
/* Connecting, selecting database */
$link = mysql_connect("localhost", "root", "jewcrew")
or die("Could not connect");
print "Connected successfully";
mysql_select_db("oysterqtl", $link) or die("Could not select database");
/* Performing SQL query */
$aResult = "";
$aSQL = mysql_query("select distinct $column_name from $aTableName",
$link);
while ($this_column = mysql_fetch_array ($aSQL))
{
$aMother = $this_column[0];
$aID = $this_column[0];
if ($aID == $aCurSel)
{
$aResult .= "<option value=\"$aMother\"
selected>$aMother</option>";
}
else
{
$aResult .= "<option
value=\"$aMother\">$aMother</option>";
}
}
return $aResult;
}
--
Jason P. Curole, Postdoctoral Researcher
Bodega Marine Lab, University of California
Bodega Bay CA 94923
Office: (707) 875-2077
Lab: (707) 875-2076
Fax: (707) 875-2089
Shipping:
2099 Westshore Rd.