enhanced_list_box, 2 tables from a database
| From: | kNish | Date: | Wed, 07 Nov 2007 08:41:13 +0000 |
| Subject: | enhanced_list_box, 2 tables from a database | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-264169@lists.php.net to get a copy of this message | ||
Hi,
A newbie question. I have more than one table to access from a database.
When I use the code as below, it gives no response on the web page.
What may I do to run more than one table from the same database into the
script.
BRgds,
kNish
.
.
.
.
<tr>
<td height="33"> </td>
<td width="14%" class="style3">Artist</td>
<?php
$options = mysql_query("SELECT artist_name FROM artist");
$options=mysql_fetch_array($options);
echo '<td>';
enhanced_list_box(array(
'table' => 'artist',
'value_field' => 'artist_name'));
function enhanced_list_box($options){
$sql = "select " . $options['value_field'];
$sql .= " from " . $options['table'];
$result = mysql_query($sql)or die("error in SQL");
echo '<select name="', $options['value_field'],'"
size="1">';
while ($row = mysql_fetch_array($result, MYSQL_NUM))
echo '<option value="' . $row[0] . '">' . $row[0] .
'</option>';
echo '</select>';
}
echo '</td>';
?>
</tr>
<tr>
<td height="33"> </td>
<td width="14%" class="style3">Project</td>
<?php
$options = mysql_query("SELECT project_name FROM project");
$options=mysql_fetch_array($options);
echo '<td>';
enhanced_list_box(array(
'table' => 'project',
'value_field' => 'project_name'));
function enhanced_list_box($options){
$sql = "select " . $options['value_field'];
$sql .= " from " . $options['table'];
$result = mysql_query($sql)or die("error in SQL");
echo '<select name="', $options['value_field'],'"
size="1">';
while ($row = mysql_fetch_array($result, MYSQL_NUM))
echo '<option value="' . $row[0] . '">' . $row[0] .
'</option>';
echo '</select>';
}
echo '</td>';
?>
</tr> <http://www.php.net/a>
.
.
.
.
.