我需要在我的数据输入页面中添加另一个下拉菜单,并想出一种在两个表中显示日期的方法,但它在每个表中都加倍,即显示艺术家下拉菜单:
将 N 添加到 X
将 N 添加到 X
空气
Air
Amon Tobin
Amon Tobin
等。
贡献者下拉显示:
乔吹
乔吹
迪克一团
迪克一团
等。
这是我将表格数据翻倍的地方:
SELECT artists.id, artists.artists_name, contributors.id, contributors.contributors_name FROM artists, contributors ORDER BY artists.artists_name, contributors.contributors_name";
这里是上下文:
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO news (artistid, contributorid, title, blog_entry, rating) VALUES (%s, %s, %s, %s, %s)",
GetSQLValueString($_POST['artistid'], "text"),
GetSQLValueString($_POST['contributorid'], "text"),
GetSQLValueString($_POST['title'], "text"),
GetSQLValueString($_POST['blog_entry'], "text"),
GetSQLValueString($_POST['rating'], "text"));
mysql_select_db($database_em, $em);
$Result1 = mysql_query($insertSQL, $em) or die(mysql_error());
$insertGoTo = "add_post.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
mysql_select_db($database_em, $em);
$query_listPosts = "SELECT artists.id, artists.artists_name, contributors.id, contributors.contributors_name FROM artists, contributors ORDER BY artists.artists_name, contributors.contributors_name";
$listPosts = mysql_query($query_listPosts, $em) or die(mysql_error());
$row_listPosts = mysql_fetch_assoc($listPosts);
$totalRows_listPosts = mysql_num_rows($listPosts);
?>
这是我在页面中呈现它的方式:
<p>
<label for="artistid">Artist:</label>
</p>
<p><select name="artistid">
<option value="0">Not registered</option>
<?php
do {
?>
<option value="<?php echo $row_listPosts['id']?>"><?php echo $row_listPosts['artists_name']?></option>
<?php
} while ($row_listPosts = mysql_fetch_assoc($listPosts));
$rows = mysql_num_rows($listPosts);
if($rows > 0) {
mysql_data_seek($listPosts, 0);
$row_listPosts = mysql_fetch_assoc($listPosts);
}
?>
</select></p>
<p>
<label for="contributorid">Contributor:</label>
</p>
<p><select name="contributorid">
<option value="0">Not registered</option>
<?php
do {
?>
<option value="<?php echo $row_listPosts['id']?>"><?php echo $row_listPosts['contributors_name']?></option>
<?php
} while ($row_listPosts = mysql_fetch_assoc($listPosts));
$rows = mysql_num_rows($listPosts);
if($rows > 0) {
mysql_data_seek($listPosts, 0);
$row_listPosts = mysql_fetch_assoc($listPosts);
}
?>
</select></p>
虽然我现在可以处理这种加倍,但当我向我的数据输入页面添加更多下拉列表时,它会成为一个问题,所以任何想法如何解决这个问题,以便每个下拉只有一个数据实例而不是加倍会不胜感激。