How to keep form items selected after post request?
Posted
by Ole Jak
on Stack Overflow
See other posts from Stack Overflow
or by Ole Jak
Published on 2010-04-05T11:08:39Z
Indexed on
2010/04/05
11:13 UTC
Read the original article
Hit count: 258
I have a simple html form. On php page. A simple list is placed on form. I submit this form (selected list items) to this page so it gives me page refresh. I want items which were POSTED to be selected after form was submited. How to do such thing?
For my form I use such code:
<form action="FormPage.php" method="post">
<select id="Streams" class="multiselect ui-widget-content ui-corner-all" multiple="multiple" name="Streams[]">
<?php
$query = "
SELECT s.streamId, s.userId, u.username
FROM streams AS s
JOIN user AS u ON s.userId = u.id
LIMIT 0 , 30
";
$streams_set = mysql_query($query, $connection);
confirm_query($streams_set);
$streams_count = mysql_num_rows($streams_set);
while ($row = mysql_fetch_array($streams_set)){
echo '<option value="' , $row['streamId'] , '"> ' , $row['username'] , ' (' , $row['streamId'] ,')' ,'</option> ';
} ?>
</select>
<br/>
<input type="submit" class="ui-state-default ui-corner-all" name="submitForm" id="submitForm" value="Play Stream from selected URL's!"/>
</fieldset>
</form>
© Stack Overflow or respective owner