将 pg_query 的结果放入 select 下拉框中
place the results of a pg_query into a select dropdown box
我是运行一个pg_query,它显示我创建的用户table的uid列中的所有数据。
我需要的是将结果显示在我创建的用户名select select 下拉框中,而不是在 html 页面上。我的代码如下:
<?php
include_once 'newheader.php' ;
?>
<!-- css for the page-->
<section class="main-container">
<div class="main-wrapper">
<h2 class="page_title">New User</h2>
</div>
<!-- dropdown list for all user names-->
<p>
What is your User Name?
<select name="Usernameselect">
<option value="">Select...</option>
<option value="uid">'$row[0]'</option>
</select>
</p>
</section>
<?php
// connect to database
$conn = pg_pconnect("host=localhost dbname=vcbv2 user=postgres");
if (!$conn) {
echo "An error occurred.\n";
exit;
}
// get all the uid from the uid column in users
$result = pg_query($conn, "SELECT uid FROM users");
if (!$result) {
// error message
echo "An error occurred.\n";
exit;
}
// dispaly on screen all uid data from users
while ($row = pg_fetch_row($result)) {
echo "$row[0]";
echo "<br />\n";
}
?>
任何帮助将不胜感激。
<?php
include_once 'newheader.php' ;
?>
<!-- css for the page-->
<section class="main-container">
<div class="main-wrapper">
<h2 class="page_title">New User</h2>
</div>
<!-- dropdown list for all user names-->
<p>
What is your User Name?
<select name="Usernameselect">
<option value="">Select...</option>
<?php
// connect to database
$conn = pg_pconnect("host=localhost dbname=vcbv2 user=postgres");
if (!$conn) {
echo "An error occurred.\n";
exit;
}
// get all the uid from the uid column in users
$result = pg_query($conn, "SELECT uid,name FROM users");
if (!$result) {
// error message
echo "An error occurred.\n";
exit;
}
// dispaly on screen all uid data from users
while ($row = pg_fetch_row($result)) {
echo '<option value="'.$row[0].'">'.$row[1].'</option>';
}
?>
</select>
</p>
</section>
我是运行一个pg_query,它显示我创建的用户table的uid列中的所有数据。 我需要的是将结果显示在我创建的用户名select select 下拉框中,而不是在 html 页面上。我的代码如下:
<?php
include_once 'newheader.php' ;
?>
<!-- css for the page-->
<section class="main-container">
<div class="main-wrapper">
<h2 class="page_title">New User</h2>
</div>
<!-- dropdown list for all user names-->
<p>
What is your User Name?
<select name="Usernameselect">
<option value="">Select...</option>
<option value="uid">'$row[0]'</option>
</select>
</p>
</section>
<?php
// connect to database
$conn = pg_pconnect("host=localhost dbname=vcbv2 user=postgres");
if (!$conn) {
echo "An error occurred.\n";
exit;
}
// get all the uid from the uid column in users
$result = pg_query($conn, "SELECT uid FROM users");
if (!$result) {
// error message
echo "An error occurred.\n";
exit;
}
// dispaly on screen all uid data from users
while ($row = pg_fetch_row($result)) {
echo "$row[0]";
echo "<br />\n";
}
?>
任何帮助将不胜感激。
<?php
include_once 'newheader.php' ;
?>
<!-- css for the page-->
<section class="main-container">
<div class="main-wrapper">
<h2 class="page_title">New User</h2>
</div>
<!-- dropdown list for all user names-->
<p>
What is your User Name?
<select name="Usernameselect">
<option value="">Select...</option>
<?php
// connect to database
$conn = pg_pconnect("host=localhost dbname=vcbv2 user=postgres");
if (!$conn) {
echo "An error occurred.\n";
exit;
}
// get all the uid from the uid column in users
$result = pg_query($conn, "SELECT uid,name FROM users");
if (!$result) {
// error message
echo "An error occurred.\n";
exit;
}
// dispaly on screen all uid data from users
while ($row = pg_fetch_row($result)) {
echo '<option value="'.$row[0].'">'.$row[1].'</option>';
}
?>
</select>
</p>
</section>