How does mysql_fetch_assoc store rows from a query?

Posted on 2008-10-24
Medium Priority
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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment

Accepted Solution

raminhos earned 1500 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

765 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