$i=0;
while ($row=mysql_fetch_assoc()) {
if ($i==0) echo "First"
$i++;
}
Access directly to mysqli pointer? a php class like's Iterator?
Thanks.
$i=0;
while ($row=mysql_fetch_assoc()) {
if ($i==0) echo "First"
$i++;
}
Access directly to mysqli pointer? a php class like's Iterator?
Thanks.
If you're trying to use the first element for something special, then maybe something like:
$row=mysql_fetch_assoc();
//do stuff to first row
do {
//do stuff to all rows (including the first)
} while ($row=mysql_fetch_assoc());
Otherwise I have no idea what the question is and I'm not a PHP guy...
I’d use this:
if ($row = mysql_fetch_assoc()) {
// process first item
while ($row = mysql_fetch_assoc()) {
// process following items
}
}
Do not have any method for know exactly position in all moment?
for example java iterator implements next or hasNext(), if !hasNext() the item is the last.
$first = true;
while ($row=mysql_fetch_assoc()) {
if ($first) echo "First"
$first = false;
}
well, if i understand your question correctly, you want the first row and then iterate through the others:
$row = mysql_fetch_assoc(); // $row contains first row
while ($row = mysql_fetch_assoc()) { // loop through the rest of the rows
}