In my table I have A B C D,
[syntax=php]
$mysql->query("
SELECT
`name`
FROM `categories` ORDER BY `name` ASC
");
$mysql->fetch($row);
$return = array();
while ($mysql->fetch($row)){
$return[] = $row;
}
return $return;
[/syntax]
and then,
[syntax=php]
foreach($rows as $row) {
echo $row['name'];
echo "<br />";
}
[/syntax]
but here is the weird thing, it only echoes B C D and if I change the order to DESC it echoes C B A I never run into this problem before
Fetches all but one?!
Re: Fetches all but one?!
Can you post, like, the entire code? That'd make it easier to understand.
At least, for me it would. Idk about anyone else…
At least, for me it would. Idk about anyone else…
Re: Fetches all but one?!
[syntax=php]
if($_GET['category'] === "all") {
$mysql->query("
SELECT
`name`
FROM `categories` ORDER BY `name` ASC
");
$mysql->fetch($row);
$return = array();
while ($mysql->fetch($row)){
$return[] = $row;
}
return $return;
}
[/syntax]
[syntax=php]
$categories = new Categories;
$rows = $categories->GetCategories();
foreach($rows as $row) {
echo $row['name'];
echo "<br />";
}
[/syntax]
if($_GET['category'] === "all") {
$mysql->query("
SELECT
`name`
FROM `categories` ORDER BY `name` ASC
");
$mysql->fetch($row);
$return = array();
while ($mysql->fetch($row)){
$return[] = $row;
}
return $return;
}
[/syntax]
[syntax=php]
$categories = new Categories;
$rows = $categories->GetCategories();
foreach($rows as $row) {
echo $row['name'];
echo "<br />";
}
[/syntax]
Re: Fetches all but one?!
Try removing that first fetch statement, so that you only keep the one in the while loop.
Please check out my CodeCanyon items.
Re: Fetches all but one?!
Dear god I'm blind!
How could I not see that
How could I not see that
Re: Fetches all but one?!
Well you just said you are blind, so...
Please check out my CodeCanyon items.