I try to create dropdown list with informations from title column in sql table, but never succeeds.

My connection and query is good. Can somebody to help me with this?

mysql_connect();
mysql_select_db(
);
$query = mysql_query("SELECT title FROM test");

Thanks!

Try This:

echo '
<select name="title" id="title">
';
$query = mysql_query("SELECT title FROM test");
while($row = mysql_fetch_array( $result )) {
$opt = $row['title'];
echo '  <option value="'.$opt.'">' .$opt. '</option>
';
}
  echo '</select>

I've been using PDO for a while, so I hope this is right.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.