How does mysql_fetch_assoc store rows from a query?

Posted on 2008-10-24
Last Modified: 2013-12-13
I am using Dreamweaver's built in functionality to create a drop down list from a MySQL query.  The problem I have is that if I try to duplicate the list on the same page, only the first instance is filled with info from the query.  It may have something to do with the way "mysql_fetch_assoc" counts through the rows.  Can someone please explain how this works and how I can create multiple lists from the one query?  Thanks.
// The following is a couple snippets from my page:
mysql_select_db($database_gw2000Connect, $gw2000Connect);
$query_getAllNames = "SELECT * FROM users";
$getAllNames = mysql_query($query_getAllNames, $gw2000Connect) or die(mysql_error());
$row_getAllNames = mysql_fetch_assoc($getAllNames);
$totalRows_getAllNames = mysql_num_rows($getAllNames);
<select name="entryToApply">
  <?php do { ?>
  <option value="<?php echo $row_entriesToApply['invoiceNum']; ?>">
    <?php echo $row_entriesToApply['invoiceNum']; ?>
  <?php } while ($row_entriesToApply = mysql_fetch_assoc($entriesToApply)); ?>

Open in new window

Question by:CheeserTheAverage
1 Comment

Accepted Solution

raminhos earned 500 total points
ID: 22801384
mysql_select_db($database_gw2000Connect, $gw2000Connect);
$sql = "SELECT * FROM users";
$qry = mysql_query($sql);
while ($row = mysql_fetch_array($qry)){
  $entries[] = $row_entriesToApply['invoiceNum'];
$select = "<select name='entryToApply'>";
foreach ($entries as $a){
  $select .= "<option value='$a'>$a</option>";
$select .= "</select>";
$select1 = "<select name='entryToApply2'>";
foreach ($entries as $b){
  $select1 .= "<option value='$b'>$b</option>";
$select1 .= "</select>";
/// and continue...

Open in new window


Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Part of the Global Positioning System A geocode ( is the major subset of a GPS coordinate (, the other parts being the altitude and t…
This article discusses how to create an extensible mechanism for linked drop downs.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now