user1868565
user1868565

Reputation: 151

PHP mysql leaving out rows

So I am having issues with the first row of the database being left out, not sure as to why yet. Here is the code in a nutshell, leaving out the connection part and such.

$tickets="tickets";
$sql_ticket="SELECT * FROM $tickets WHERE username='$user'";
$ticket_query=mysql_query($sql_ticket);
$ticket_data=mysql_fetch_assoc($ticket_query);
while($ticket_data=mysql_fetch_assoc($ticket_query)){
// echoing in tables
}

Upvotes: 0

Views: 70

Answers (1)

Marcin Orlowski
Marcin Orlowski

Reputation: 75629

Remove this line:

$ticket_data=mysql_fetch_assoc($ticket_query);

as you are fetching 1st row outside of your loop. Corrected code should be:

$tickets="tickets";
$sql_ticket="SELECT * FROM $tickets WHERE username='$user'";
$ticket_query=mysql_query($sql_ticket);
while($ticket_data=mysql_fetch_assoc($ticket_query)){
   // echoing in tables
}

Upvotes: 4

Related Questions