I read about the function on php.net and this has not yet answered my question. I know newbies in C, and I just started using php. Usually in C, if you have to do a while loop, there must be some condition to push the loop to the point where it will no longer be valid:
while (x >= 10) { printf("..."; printf("x \n"; x++; }
However, in my php script that I use for the pm messaging system, I have a while loop as follows:
while($row2 = mysql_fetch_array($query))
and then:
{ echo "<table border=1>"; echo "<tr><td>"; echo "Message #: "; echo $row['id']; echo "</td></tr>"; echo "<tr><td>"; echo "To: "; echo $row['to']; echo "</td></tr>"; echo "<tr><td>"; echo "From: "; echo $row['from']; echo " "; echo "</td></tr>"; echo "<tr><td>"; echo "Message: "; echo $row['message']; echo "</td></tr>"; echo "</br>"; ?> <form action="<?php echo $_SERVER['PHP_SELF']?>" method="post"> <table border="0"> <tr><td colspan=2></td></tr> <tr><td></td><td> <input type="hidden" name="id" maxlength="32" value = "<?php echo $row['id']; ?>"> </td></tr> <tr><td colspan="2" align="right"> <input type="submit" name="delete" value="Delete PM # <?php echo $row['id']; ?>"> </td> <td colspan="2" align="right"> <input type="submit" name="reply" value="Reply to <?php echo $row['from']; ?>"> </td></tr> </table> <?php } ?>
How exactly this work, from the C-background, it would seem, almost the same, would remain in the same place, printing the same "array selection" "string" from the same "query $" every time we go through the loop ....
Is there a way to write this to better understand the logical understanding of what is happening? as the saying goes:
$i=0; while ($row = ($i+mysql_fetch_array($query)) { ... ... $i++;}
I know that probably doesn't work, but how does this function increase? And is there a way to write it where it really will have some kind of increment visible in the code?
thanks
source share