开发者

populate select box with data from mysqltable

开发者 https://www.devze.com 2023-03-07 05:01 出处:网络
How to populate select box with data from mysql table, and then move that value from one page to another.

How to populate select box with data from mysql table, and then move that value from one page to another. I did a small coding, and i was able to get all the values from table, but i cant move those value to other page.

$query1="SELECT  * FROM seat_no WHERE seatno NOT IN(SELECT seatno FROM check_in_desk)";
$result1 = mysql_query($query1);

<select name="txt_seatno">
 <?php

while($nt=mysql_fetch_array($result1))
{
echo "<option value=$nt[id]>$nt[sea开发者_如何学编程tno]</option>";
}
</select>
?>


Can you just lookup the values on the page where you need them? If not, you could pass the data as a GET or POST variable, and then use this to generate the select box options on the new page.


There's two ways I can think of;

1) append the value to the url, so it'd be;

echo '<a href="page.php?id=' . $nt[id] . '">' . $nt[seatno] . '</a>';

and in the receiving page, you'd put;

$id = (int) $_GET['id'];

2) Or you could simply use this; http://www.w3schools.com/html/tryit.asp?filename=tryhtml_select2

(dropdown menu)

(btw; your < /select> should come after ?>)

0

精彩评论

暂无评论...
验证码 换一张
取 消