The Select query I am using is not working.. Can Somebody Guide me to the Correct way?
- by Parth
I am using the Select query as
SELECT id, ordering FROM `jos_menu` WHERE ordering='".$rec['ordering'] -'1' ."' AND parent = '0'
Here I need all the records whose ordering is less than 1 of the selected record's order($rec['ordering'] = getting from other select query )  when I am trying to echo the query I am not getting complete statement but getting only this -1' AND parent = '0'
here is the whole snippet
$where = ' WHERE (id = ' . implode( ' OR id = ', $cid ) . ')';//Pranav Dave Coded
    echo $selquery = "SELECT id, ordering FROM `jos_menu`".$where;          //Pranav Dave Coded
        $db->setQuery( $selquery );//Pranav Dave Coded
        $record = $db->loadAssocList(); //Pranav Dave Coded
    if ($model->orderItem($id, -1)) {
    echo "<pre>";
    print_r($model);
    /*exit;*/
    //echo $updorderup = mysql_escape_string($model->_db->_sql);//Pranav Dave Coded
        foreach($record as $rec)//Pranav Dave Coded
        {
            echo $aboverow = "SELECT id, ordering FROM `jos_menu` WHERE ordering='".$rec['ordering'] -'1' ."' AND parent = '0'";
            $db->setQuery( $aboverow );
        $above = $db->loadAssoc();
        echo "<pre>";
    print_r($above);
                    }//end of foreach
                 }//end of if
Please suggest me where I am getting wrong.....