-3

I get this error Notice: Undefined index: pharmacy.Name in C:\xampp\htdocs\RAU\courses.php on line 17 Notice: Undefined index: delivery.Phone in C:\xampp\htdocs\RAU\courses.php on line 19 Notice: Undefined index: delivery.Address in C:\xampp\htdocs\RAU\courses.php on line 21

 <link rel="stylesheet" href="style1.css">
    <?php  
    $servername = "localhost";
        $userrname = "root";
        $password = "";
        $dbname = "bless";
        $conn = new mysqli($servername, $userrname, $password ,$dbname);
        if ($conn->connect_error) {
            die("Connection failed: " . $conn->connect_error);
        }
    $sqlq="SELECT pharmacy.name,delivery.phone,delivery.address FROM delivery INNER JOIN pharmacy ON delivery.Pharmacy_id = pharmacy._id";
    $rslt=$conn->query($sqlq) ;
    $roww = $rslt->fetch_assoc();

    echo "<br>";
    echo "<br>";
    echo "<td>" . $roww['pharmacy.name'] ;
    echo "<br>";
        echo"<td>". $roww['delivery.phone'];
    echo "<br>";
        echo"<td>". $roww['delivery.address'];
    echo "<br>";
    ?>

1 Answers1

0

When selecting tables in a MySQL query, the name prefixing the column name, is the table:

'table name'.'column name'

It returns the column name, but it tells MySQL which table to take the column data from in case of ambiguity. It is a safe practice for joins, but when only selecting from one table, it defaults to that table.

Use

$roww['name']
$roww['phone']
$roww['address']
Ice76
  • 1,143
  • 8
  • 16
  • yea it worked but it didn't print all query results! – Takla Gerguis Jul 24 '17 at 20:13
  • It worked as it was coded to work - fetch one result row. You only executed it once. Read up on it here: [link](http://php.net/manual/en/mysqli-result.fetch-assoc.php) You called it once. If you need all the rows, then you need to loop through – Ice76 Jul 24 '17 at 20:23