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..

Recommended Answers

All 3 Replies

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..

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.

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.