
Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[tlug] echo > dropdown
- Date: Thu, 10 Feb 2005 00:21:08 +0900
- From: Ahmed Sarwar <qqw99xk9@example.com>
- Subject: [tlug] echo > dropdown
- References: <87wty8bfm9.fsf@example.com><000901c4a951$d7c7b0d0$6501a8c0@example.com><005501c4a9ec$9edf3220$7400a8c0@example.com><20041004084910.GD2120@example.com><005c01c4a9f1$82655cf0$7400a8c0@example.com>
Hello, can someone please tell me how to put the following "echo" to
the "dropdown list".
<?php
pg_connect("dbname=address host=localhost") or die("Couldn't Connect");
$query = "SELECT * FROM address";
$query = pg_query($query);
while($row = pg_fetch_array($query,NULL,PGSQL_ASSOC))
{
echo "Name: ".$row['name']."<br />";
}
function db_createlist($linkID,$default,$query,$blank)
{
if($blank)
{
print("<option select value=\"0\">$blank</option>");
}
$resultID = pg_exec($linkID,$query);
$num = pg_numrows($resultID);
for ($i=0;$i<$num;$i++)
{
$row = pg_fetch_row($resultID,$i);
if($row[0]==$default)$dtext = "selected";
else $dtext = "";
print("<option $dtext value=\"$row[0]\">$row[1]</option>");
}
}
?>
<select name="select">
<?php
// default is 0, no entry will be selected.
db_createlist($linkID,0,
"select id,description from list","Please select one ...");
?>
</select>
Home |
Main Index |
Thread Index