James Harvey
James Harvey

Reputation: 1

Pulling Data from Database into Drop Down List

I'm making an adjustment to a php page and would like the end user to be able to select "name and email" from drop down lists. The data would be coming from the mySQL database.

I have managed to get this to work partially, however there must be something doing a "verification" because when all the data on the page has been selected and the end user tries to submit the page, the end user gets the message that the email address is not valid, when in fact it is 100% valid.

The part I changed in relation to this was, the end user used to have to manually type their email address, now they can select it from the drop down, however now it is telling us that the address is incorrect.

<select name="email" <?php if (in_array('email',$_SESSION['iserror'])) {echo ' class="isError" ';} elseif (in_array('email',$_SESSION['isnotice'])) {echo ' class="isNotice" ';} ?> >

<?php

if (!empty($_GET['catid']))

{

    $_SESSION['as_email'] = intval( hesk_GET('catid') );

}



$result = hesk_dbQuery('SELECT * FROM `'.hesk_dbEscape($hesk_settings['db_pfix']).'users` ORDER BY `id` ASC');

while ($row=hesk_dbFetchAssoc($result))

{

    if (isset($_SESSION['as_email']) && $_SESSION['as_email'] == $row['id']) {$selected = ' selected="selected"';}

    else {$selected = '';}

    echo '<option value="'.$row['id'].'"'.$selected.'>'.$row['email'].'</option>';

}



?>

</select></td>

What am I doing wrong or what do I have wrong? I'm sure someone else has come across this before. Would really appreciate some help.

Thanks

Upvotes: 0

Views: 168

Answers (1)

sifile
sifile

Reputation: 3

you missing else {}

if (in_array('email',$_SESSION['iserror'])) {
    echo ' class="isError" ';
} elseif (in_array('email',$_SESSION['isnotice'])) {
    echo ' class="isNotice" ';
} else {
    // something
}

Upvotes: 0

Related Questions