Re: enhanced_list_box, 2 tables from a database

From: Date: Wed, 07 Nov 2007 12:32:07 +0000
Subject: Re: enhanced_list_box, 2 tables from a database
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-264174@lists.php.net to get a copy of this message
Dear kNish, first of all i have formated your PHP Code it looks better now. <?php echo "<tr>\n"; echo " <td height=\"33\">&nbsp;</td>\n"; echo " <td width=\"14%\" class=\"style3\">Artist</td>\n"; $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>'; echo "</tr>\n"; echo "<tr>\n"; echo " <td height=\"33\">&nbsp;</td>\n"; echo " <td width=\"14%\" class=\"style3\">Project</td>\n"; $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>'; ?> After i had check your code, my php interpreter shows me an fatal error on the browser. "kNish" <singhai.nish@gmail.com> schrieb im Newsbeitrag news:81bfef2e0711070041p1a2ed9b3p4b972a5c985a7e8f@mail.gmail.com...
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> . . . . .


« previous php.general (#264174) next »