enhanced_list_box, 2 tables from a database

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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">&nbsp;</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">&nbsp;</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>
.
.
.
.
.

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux