user3527721
user3527721

Reputation: 3

DropDown Menu echo error

I am attempting to create a drop-down menu within a booking system that lists the events from my SQL database,

This is the code I have written:

$SQL = "SELECT * from Events";
$exeSQL = mysql_query($SQL);
while($arrayEvents = mysql_fetch_array($exeSQL));
{
    echo"<li><a href=$arrayEvents['eventName']</a></li>";
}

As I am new to PHP I was wondering how I can improve this and prevent the error:

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/unix/student10/w1284519/public_html/STF/DropDown.php on line 26

Line 26 is from where echo is written

EDIT: The error has been fixed thanks to your help but the code only displays three bulletpoints, how could I fix this?

Thank you in advance for your help!

Upvotes: 0

Views: 66

Answers (3)

meda
meda

Reputation: 45490

echo"<li><a href=$arrayEvents['eventName']</a></li>";

Is a list not a dropdown, change to this:

echo "<select>";
while($arrayEvents = mysql_fetch_array($exeSQL))
{
    echo"<option> $arrayEvents['eventName']</option>";
}
echo "</select>";

Upvotes: 0

Unamata Sanatarai
Unamata Sanatarai

Reputation: 6637

echo"<li><a href=" . $arrayEvents['eventName'] . "</a></li>";

or

echo"<li><a href={$arrayEvents['eventName']}</a></li>";

will fix the ECHO error part

Upvotes: 0

John Conde
John Conde

Reputation: 219804

You have an errant semi-colon:

while($arrayEvents=mysql_fetch_array($exeSQL)); <-HERE

Remove it

Upvotes: 1

Related Questions