Select Query Not working second time on the same page...
my_page.php
require_once 'self_class.php';
$user = new USER();
$under_id = "0";
$get_categories_main = $user->runQuery('SELECT * FROM category WHERE Under LIKE :under ORDER BY Id ASC ');
$get_categories_main->bindParam(':under',$under_id);
$get_categories_main->execute();
if(isset($_GET['both'])){
echo "Both";
while($fetch_category_main=$get_categories_main->fetch(PDO::FETCH_ASSOC))
{
echo $fetch_category_main['Id'].") ".$fetch_category_main['Name']."<br />";
}
}
echo "Main";
while($fetch_category_main=$get_categories_main->fetch(PDO::FETCH_ASSOC))
{
echo $fetch_category_main['Id'].") ".$fetch_category_main['Name']."<br />";
}
When I visit my_page.php the result of the page is:
Main
Id) Name
Id) Name
Id) Name
Id) Name
Id) Name
........
Great! the results are as expected...
When I visit my_page.php?both the result of the page is:
Both
Id) Name
Id) Name
Id) Name
Id) Name
Id) Name
........
OOOPS! the results are not as expected...
Expected Result is:
Both
Id) Name
Id) Name
Id) Name
Id) Name
Id) Name
........
Main
Id) Name
Id) Name
Id) Name
Id) Name
Id) Name
........
Select Query Not working second time on the same page...