Mailing List Archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[tlug] echo > dropdown



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

Home Page Mailing List Linux and Japan TLUG Members Links