article

Tuesday, May 4, 2010

PHP MYSQL - List Records from database with select box

PHP MYSQL - List Records from database with select box




<select name="cat" class="m_heading" id="cat"?>
<?php
mysql_connect("localhost", "db_user", "db_passwd") or die(mysql_error());
mysql_select_db("db_name") or die(mysql_error());

$result = mysql_query("SELECT * FROM cats WHERE status='1' && type='videos'")
or die(mysql_error());
// keeps getting the next row until there are no more to get
while($row = mysql_fetch_array( $result )) {
$catid = $row['id'];
$catname = $row['name'];
echo "$catname";
}
?>
</select?>

Related Post