0

hi guys!
I got a problem when I want to display the array from the database and rank it. can someone fixed this problem:-

<?php
session_start();
include "mysql.php";
// you have already opened your db connection

$report_status = isset($_REQUEST['reportTotal']) ? $_REQUEST['reportTotal'] :"";

//$query = mysql_query("SELECT * FROM `supplier_report` "
//. "WHERE `report_value` = '" . $_SESSION['reportTotal'] ."'";
     $q= "select * from supplier_report where report_value='" .$_SESSION['reportTotal']."'" "order by report_value desc";
$result=mysql_query($q) or die(mysql_error());
$rank = 0;
$points = 0;
$rankIncrement = 1;
while ($user=mysql_fetch_array($result))
{
    if ($user['report_value'] == $points)
    {
        $rankIncrement;
    }
    else
    {
        $rank += $rankIncrement;
        $rankIncrement = 1;
    }

    echo "$rank";
	echo "<br>{$user['report_value']}</br>";
 
}
mysql_close();
?>

I got the error message which is:-
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''Array order by report_value desc' at line 1.

is it because I used array? but I notice this problem when I put the session. can someone give me the right syntax include the session?

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by just_me
0
$q= "select * from supplier_report where report_value='" .$_SESSION['reportTotal']."'" "order by report_value desc";

Why do you have " " after the value?

This should be:

$q= "select * from supplier_report where report_value='" .$_SESSION['reportTotal']."' order by report_value desc";
0

oh! yes..
sorry about that. that's after i'm tried to fix the problem.
I run the syntax that u gave it to me.
Now, there is nothing displayed in the screen.
is it my coding error in anywhere?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.