0

Sir, i have a little problem regarding my queries.. I try to display data from two different table using left outer join. but I found some error.. here's my code please check and tell me what is wrong..

f(isset($_GET['id'])){

            $id = preg_replace('#[^0-9]#i','',$_GET['id']);

            $result = mysql_query("SELECT A.cus_id, A.complaint, A.admin, A.datetime, B.firstname, B.email FROM tbl_complaint A LEFT OUTER JOIN tbl_customer B WHERE cus_id = '$id' ORDER BY datetime DESC ");      
            echo "<center><h4>Response</h4></center>";
            echo "<div class='row' style='width:700px; height:200px; border:1px solid #CCC; overflow-y:scroll;'>";
            while($row = mysql_fetch_array($result))
          {
            $complaint          =   $row['complaint'];
            $cus_id             =   $row['cus_id'];
            $datetime           =   $row['datetime'];
            $admin              =   $row['admin']; 
            $firstname_email    =   $row['firstname'].'&nbsp;'.$row['email'];
            echo "<div>";

            if(empty($admin)) {
                //nothing to show
            }
            else{
            echo"<div><p class='csr-msg' >$admin</p></div><br>";

            }//if empty condition                                   
            echo"<p class='user-msg'>$complaint</p></div><br>";
            }//while
            echo "</div>";
}
        mysql_close();

please help thnx..

2
Contributors
3
Replies
12
Views
3 Years
Discussion Span
Last Post by markii.borabon
0

here is the error:

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\monique-designs\ADMIN\reponse-to-customer.php on line 96

I think it is on part of WHERE cus_id='$id'

but im not really sure.. please help..

0

Resource variable $result is null. You need to verify the value of id and also the result of SQL statement.

$result = mysql_query("...... ");      
if($result) {
  while($row = mysql_fetch_array($result)) {
    ...
  }
}

Important: Do not use mysql_* extension. Always use MySqlI or PDO.

0

thank sir for your response .. and the result was no error but also there is no output..

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.