Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You already assigned the first row to <code>$row_rs_jobboards11</code>, so when you call <code>$row_rs_cms11 = mysql_fetch_assoc($rs_jobboards11)</code> in your do/while loop, it's starting at the second row in the table. </p> <p>Using a do/while instead of a while doesn't make any difference, but using different variable names does make a difference.</p> <p><strong>Update, to explain the difference between while, do/while, and, making sure your variable names are correct.</strong></p> <p>While loop, which works:</p> <pre><code>while ($row_rs_cms11 = mysql_fetch_assoc($rs_jobboards11)) { echo '&lt;tr&gt;'; //stuff here echo '&lt;/tr&gt;'; } </code></pre> <p>do/while loop, which also works</p> <pre><code>$row_rs_cms11 = mysql_fetch_assoc($rs_jobboards11); do { echo '&lt;tr&gt;'; //stuff here echo '&lt;/tr&gt;'; } while ($row_rs_cms11 = mysql_fetch_assoc($rs_jobboards11)); </code></pre> <p>Note that the $row variable matches. If you leave out the first call, it will still work, but you'll get an extra (empty) before any content is outputted. If you set the variable to a different name (and use a mysql_fetch_* call), the internal database pointer is set to the second row in the table. Consequently, you miss the first row in the table, because it's set to a different (unused) variable.</p> <p>Moral of the story:</p> <p>You can use either a while or a do/while loop, you just have to make sure that</p> <ul> <li>If you are using a do/while, the row variable must be created <em>prior</em> to entering the loop. And,</li> <li>Make sure your variable names match!</li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload