have a selection menu created with php which is linked to a mysql database.
Now when I select an item in that menu, I want that from an other column in the same database the email is displayed in a text field. (for example: I select dave in the selection menu, I want his email address to be displayed in the text field.)
The code doesn't seem to work, all I get is a text field with array as text in it and not the email.
Here is the code, please help.
Code:
<?php
require(HESK_PATH . 'inc/database.inc.php');
hesk_dbConnect();
$sql = 'SELECT naam FROM `'.$hesk_settings['db_pfix'].'names`';
$result = hesk_dbQuery($sql);
while ($row=hesk_dbFetchAssoc($result))
{
if ($_SESSION['c_name'] == $row['id']) {$selected = ' selected="selected"';}
else {$selected = '';}
echo '<option value="'.$row['id'].'"'.$selected.'>'.$row['naam'].'</option>';
}
{
if( isset ($_POST['naam'])) {
}
$query = 'SELECT email FROM `'.$hesk_settings['db_pfix'].'names` WHERE email = '' . mysql_real_escape_string( $_POST['naam'] ) . ''';
$result = mysql_query( $query );
if( $result !== false )
{
if( mysql_num_rows( $result ) == 1 )
{
}
}
?>
and here the text field code:
Code:
<input type="text" name="email" size="40" maxlength="50" value="<?php echo stripslashes(hesk_input($_SESSION['c_email']));?>" />