So I made a query like this
global $connection;
$query = "SELECT *
FROM streams ";
$streams_set = mysql_query($query, $connection);
confirm_query($streams_set);
in my DB there are filds
ID, UID, SID, TIME (all INT type exept time)
So I am triing to print query relult into form
<form>
<select class="multiselect" multiple="multiple" name="SIDs">
<?php
global $connection;
$query = "SELECT *
FROM streams ";
$streams_set = mysql_query($query, $connection);
confirm_query($streams_set);
$streams_count = mysql_num_rows($streams_set);
for ($count=1; $count <= $streams_count; $count++) {
echo "<option value=\"{$count}\"";
echo ">{$count}</option>";
}
?>
</select>
<br/>
<input type="submit" value="Submit Form"/>
</form>
How to print out as "option" "values" SID's from my sql query?
while ($row = mysql_fetch_array($streams_set)) {
echo '<option value="'.$row['SID'].'">'.$row['SID'].'</option>';
}
<form>
<select class="multiselect" multiple="multiple" name="SIDs">
<?php
global $connection;
$query = "SELECT *
FROM streams ";
$queryResult = mysql_query($query, $connection);
while($row = mysql_fetch_assoc($queryResult)) {
echo '<option value="'. $row["id"] .'">'. $row["title"] .'</option>';
}
?>
</select>
<br/>
<input type="submit" value="Submit Form"/>
</form>
You just have to replace the id
and title
index with your appropriate fields.
or mysql_fetch_object()
Ole Jak,看看PHP的mysql_fetch_array http://php.net/manual/zh/function.mysql-fetch-array.php ,这是您需要在while循环中执行的操作:-)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.