Hello I am new to PHP and I am reading the book Build you own database driven website using PHP and MySQL. I am trying something on my own as an exercise from the book.

I sucessfully created a dropdown menu (using the <select><option> tags). I am pleased to see that it worked well. Now all I want is to display another field from the same record selected by the user from the list. I am sure it's simple.

So the idea is that I have 20 bible verses in my db made of three fields (an ID, a reference and the actual verse). For example ID=10, Ref=John 3:16, Verse=For God so loved the world ... life.

My code shows the Select box and a Show button below. When clicked I would like the complete verse to appear a few lines below the list. Choosing another verse would refresh the page and display only that other one.

I am a VBA programmer so I can understand quickly but this is just another planet!! Here is the sample code (I removed the unnecessary XHTLM stuff)

<p>Select a verse from the drop down list to read it.</p>
if (!$dbcnn) {
exit('<p>Unable to connect to database server</p>');

if (!mysql_select_db('b_verses')) {
exit('<p>Unable to locate Bible Verses database.</p>');

$result=mysql_query('SELECT verse_id, verse_ref FROM tblverses ORDER BY verse_ref');
if (!$result) {
exit('<p>Error performing query ' . mysql_error() . '.</p>');
} else {
echo "<form action=\"{$_SERVER['PHP_SELF']}\" method=\"post\">";

echo '<select name="verses">';
while($row = mysql_fetch_array($result)){
echo '<option value="' . $row['verse_id'] . '"> ' .
$row['verse_ref'] . '</option>';
} // while $row
echo '</select><br />';

echo '<input type="submit" value="Show"';
echo '<input type="hidden" value="submitted"';
echo '</form><p></p>';
} // end if $result

Thanks so much for anyone who wants to help me with this.