0

I have a mysql query as below -

    $id_order_last="15";
    $id_order[]=array();
    $sql1="SELECT * FROM `ps_orders` WHERE `id_order`> 
    $id_order_last  order by `id_order`";
    echo $sql1;
    $result1= mysql_query($sql1);
    $cnt=1;
    while ($row = mysql_fetch_array($result1))
    {
        /*$id_order[$i]=$row['$id_order'];*/
        echo $row['$id_order']."<br />";
        $cnt++;
        echo $cnt."<br />";
}

As you can see i have the $id_order_last set 15 so it displaying the value as 15 when echoed. To check sql i echoed it and it display

SELECT * FROM `ps_orders` WHERE `id_order`> 15 order by `id_order`

So i get in the sql, run in phpmyadmin and the tuples which get returns was correct value. It show the good result means 17 and 18 which were in database. Which means the query is correct!

then it echoed 2 and 3 the cnt++ value while $row['$id_order'] is still empty only <br /> is shown up as space.

THough i also tried the for loop to print the whole things but it still not showing up?

$i=1;
for($i;$i<=$cnt;$i++)
{
    echo $id_order_last."<br />";
    echo $id_order[$i]."<br />";
    $id_order_last=$id_order[$i];
}

2 Answers 2

1
use echo $row['id_order'] in place of echo $row['$id_order']

remove $.
Sign up to request clarification or add additional context in comments.

1 Comment

though both gave same ans but i wan give this to some one new thanks u both of your for this help
1

Replace $row['$id_order'] to $row['id_order']

$id_order_last="15";
$sql1="SELECT * FROM `ps_orders` WHERE `id_order`> 
$id_order_last  order by `id_order`";
echo $sql1;
$result1= mysql_query($sql1);
$cnt=1;
while ($row = mysql_fetch_array($result1))
{
    $id_order[]=$row['id_order'];
    echo $row['id_order']."<br />";
    $cnt++;
    echo $cnt."<br />";
}

echo "<pre />";
print_r($id_order);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.