Wednesday, 15 April 2015

PHP Form select correctly populates MySQL values, does not with simple PHP echo -



PHP Form select correctly populates MySQL values, does not with simple PHP echo -

i have php select dynamically populates based on mysql recordset , uses in_array value identify , select value(s) found in database this:

<select name="staffsetselection[]" size="5" multiple="multiple" id="staffsetselection"> <option <?php if ($totalrows_staffsetid == 0) { echo "selected"; } ?> value="">choose staff set</option> <?php { ?> <option <?php if (in_array($row_staffsetchoices['empnumber'], $staffsetids)) { echo "selected"; } ?> value="<?php echo $row_staffsetchoices['empnumber'] ?>"><?php echo $row_staffsetchoices['empfirstname'] ?></option><?php } while ($row_staffsetchoices = mysql_fetch_assoc($staffsetchoices)); $rows = mysql_num_rows($staffsetchoices); if ($rows > 0) { mysql_data_seek($staffsetchoices, 0); $row_staffsetchoices = mysql_fetch_assoc($staffsetchoices); } ?> </select>

instead of displaying selected values in form alternative select i'd display them text.

i've tried utilize in_array 1 time again in simple php echo not display info , there no errors in apache log.

this i've tried:

<?php if(in_array($row_staffsetchoices['empnumber'], $staffsetids)) echo $row_staffsetchoices['empfirstname']?>

i think forgot brackets, seek way:

<?php if(in_array($row_staffsetchoices['empnumber'], $staffsetids)) { echo $row_staffsetchoices['empfirstname']; } ?>

php mysql

No comments:

Post a Comment