SitePoint Sponsor |
|
User Tag List
Results 1 to 5 of 5
Thread: accessing while loop variables
-
Jul 25, 2001, 10:31 #1
accessing while loop variables
PHP Code:<font class="main_header">Tips » <?php echo "HI" ?>:</font><br><br>
<table border="0" bgcolor="#000000" cellpadding="4" cellspacing="1" align="left">
<?
while ($row = mysql_fetch_array($result))
{
mysql_select_db("main");
$username_result = safe_query("SELECT username FROM user WHERE userid='".$row["userid"]."'");
extract(mysql_fetch_array($username_result));
print " <tr>\n";
print " <td bgcolor=\"#ABABAB\" align=\"left\"><font class=\"standard\">Author:</font></td>\n";
print " <td bgcolor=\"#ABABAB\" align=\"left\"><font class=\"standard\"><a href=\"/forums/member.php?s=&action=getinfo&userid=".$row["userid"]."\">".$username."</font></a> <font class=\"standard\"> ".$row["date"]."</font></td>\n";
print " </tr>\n";
print " <tr>\n";
print " <td bgcolor=\"#BCBCBC\" align=\"left\"><font class=\"standard\">Zone:</font></td>\n";
print " <td bgcolor=\"#BCBCBC\" align=\"left\"><font class=\"standard\">".stripslashes($row["zone"])."</font></td>\n";
print " </tr>\n";
print " <tr>\n";
print " <td valign=\"top\" bgcolor=\"#ABABAB\" align=\"left\"><font class=\"standard\">Tip:</font></td>\n";
print " <td valign=\"top\" bgcolor=\"#ABABAB\" align=\"left\"><font class=\"standard\">".stripslashes($row["tip"])."</font></td>\n";
print " </tr>\n";
print " <tr>\n";
print " <td bgcolor=\"#BCBCBC\" align=\"left\"> </td>\n";
print " <td bgcolor=\"#BCBCBC\" align=\"left\"> </td>\n";
print " </tr>\n";
}
?>
</table>
-
Jul 25, 2001, 11:13 #2
- Join Date
- Jul 2001
- Location
- Wolverhampton, UK
- Posts
- 81
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
ermmmmmmmm, you can use mysql_fetch_array($result) and then after that you can reset the array to the first element by:
a) mysql_data_seek($resul, 0); or
b) dammit i can't remember it, but there is another one you can use... //what is it?????? grrrrrrrr
beachball
-
Jul 25, 2001, 12:02 #3
- Join Date
- Jul 2001
- Location
- Wolverhampton, UK
- Posts
- 81
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
the other is reset($row) if it's $row = mysql_fetch_array($result); but this might not work :S
beachball
-
Jul 25, 2001, 13:15 #4
The data seek worked! So it just returned to the front of the array, since I guess it was starting at the 2nd when I was using it in the loop?
-
Jul 25, 2001, 15:02 #5
- Join Date
- Jul 2001
- Location
- Wolverhampton, UK
- Posts
- 81
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
yeah, mysql_data_seek($result, $number) moves the internal array pointer (what element it is currnetly on) of the result set $result to element $number in the array...
summin' like that neway
beachball
Bookmarks