Ok here is my code:

			<?php
			echo "<option>username".$username."</option>";
			$result1 = mysql_query("SELECT id FROM users WHERE username = '$username'");
			$myrow1 = mysql_fetch_array($result1);
			$user_id = $myrow1['id'];
			echo "<option>userid".$user_id."</option>";
			$result2 = mysql_query("SELECT acct_id FROM user_access WHERE user_id = $user_id");
			while ($myrow2 = mysql_fetch_array($result2)) {
				$acct_id = $myrow2['acct_id'];
				echo "<option>acctid".$acct_id."</option>";

			$result3 = $mysql_query("SELECT place FROM zones WHERE id = '$acct_id'");
			$myrow3 = $mysql_fetch_array($result3);

			echo "<option>acctid".$acct_id."</option>";
			$acctplace = $myrow3['place'];
		    echo "<option>acctname".$acctplace."</option>";
		} ?>
		</select>
        <input class="blue" type="submit" name="submit_view_account" value="View">
    </td>
<tr>

some of the stuff in there is for debugging purposes. I get everything up to the:

				$result3 = $mysql_query("SELECT place FROM zones WHERE id = '$acct_id'");
				$myrow3 = $mysql_fetch_array($result3);

If I take those lines out it works fine but if I have it in there it stops after the first $acct_id is displayed and nothing else after this code works either. Can someone tell me what I'm doing wrong and what to do to fix it?

    Bah don't mind me I found my $mysql_fetch_array mistake 😃

      $result3 = $mysql_query("SELECT place FROM zones WHERE id = '$acct_id'");
      $myrow3 = $mysql_fetch_array($result3);

      The $'s before the functions shouldn't be there.
      ie. mysql_query not $mysql_query

        You shouldnt have a Query within the loop it has too many unnessacary calls to the database.

          Write a Reply...