Dark Prince Posted February 21, 2012 Share Posted February 21, 2012 in a while loop the first query row is not shown only the ones following after , the loop is an html table Link to comment Share on other sites More sharing options...
HartleySan Posted February 22, 2012 Share Posted February 22, 2012 Sorry, Dark Prince, but I cannot understand what you are asking. Are you saying that you made a query to the database and results were returned, but for whatever reason, the first row of the results cannot be assigned to your $row variable? And to clarify the last part of your question, are you trying to output your DB results to an HTML table? Link to comment Share on other sites More sharing options...
Dark Prince Posted February 22, 2012 Author Share Posted February 22, 2012 Yes and Yes you did understand right while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { $bg = ($bg=='#eeeeee' ? '#ffffff' : '#eeeeee'); echo '<tr bgcolor="' . $bg . '"> I ran the query manually in mysql and it shows the first results, but when viewed in a browser in html table format the first result is not returned only the ones following after. Link to comment Share on other sites More sharing options...
rob Posted February 22, 2012 Share Posted February 22, 2012 Sounds like it could be an issue with the HTML markup, have you inspected the markup? Anything else would just be guessing, since there's so little code. Link to comment Share on other sites More sharing options...
Larry Posted February 22, 2012 Share Posted February 22, 2012 Dark Prince, you've been posting here long enough that it's about time you start following the forum guidelines. Look at this original post. How is anyone supposed to answer that? You don't provide any code. You don't say what versions you're using. You don't say what debugging steps you've taken and what the results were. You need to read the forum guidelines before you post again and you need to abide by them if you want help. Link to comment Share on other sites More sharing options...
HartleySan Posted February 23, 2012 Share Posted February 23, 2012 Thanks for cracking the whip, Larry. Dark Prince, rob is right in that you have provided little to nothing for us to help you with. Whenever I'm debugging, I start things off simple. For example, in this case, the problem is that you're not getting the first value, right? As such, before I bother trying to write an HTML table, etc., I'd be trying to figure out what's up with the value. For example, I might write the following for loop: while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { echo $row['DB-column-name-here'] . '<br>'; } Also, it just occurred to me that when you said "first result", you might be referring to the first item in the $row array, and not the first set of results output to $row. Long story short, I suspect that since you're using "MYSQLI_ASSOC", either your putting the wrong string within the brackets after $row, or for some reason, you are infact getting the correct results back, but you're not outputting them to the screen properly. Link to comment Share on other sites More sharing options...
Larry Posted February 23, 2012 Share Posted February 23, 2012 Well, you and Rob have been great for trying to help, and I try to give people as much slack/time to learn as is reasonable, but to put up an initial post like this one, having already posted 61 times, that's ridiculous. Link to comment Share on other sites More sharing options...
HartleySan Posted February 23, 2012 Share Posted February 23, 2012 Agree. I don't know how you're able to keep your cool sometimes. I do think it's great that you actively participate in your own book forums though. That's a rarity, and a real selling point. Link to comment Share on other sites More sharing options...
Larry Posted February 24, 2012 Share Posted February 24, 2012 Thanks for saying so! And thanks for helping out. It makes my job so much easier! Link to comment Share on other sites More sharing options...
Recommended Posts