0

I need assistance in understanding how to work with 2 tables from a database. I tried writing the code like this but it did not work. It works in MySQL but not in php. I am new coder trying to learn, but I am stuck any help would be appreciated. first and last name are on 1 table. Price is on another table.

Also I am getting this error

mysql_fetch_array() expects parameter 1 to be resource

index.php

 <?php
    include ('db.php');
    $sql='SELECT * FROM `user_info` ,`customer_order` WHERE user_info.user_id=customer_order.uid';

            $run_query=mysqli_query($conn,$sql);


        if(! $run_query ) {
          die('Could not get data: ' . mysql_error());
       }

       while($row = mysql_fetch_array($run_query, MYSQL_ASSOC)) {
          echo "First Name:{$row['first_name']}  <br> ".
                "Last Name:{$row['last_name']}  <br>".
                "price:{$row['price]}  <br>";

            }
Mike J
  • 15
  • 3

1 Answers1

1

I made a mistake and mixed up MySQL with mysqli I fixed the issue and it is working thanks from Don't panic.

<?php
include ('dbconnect.php');
$sql='SELECT * FROM `user_info` ,`customer_order` WHERE user_info.user_id=customer_order.uid';

        $run_query=mysqli_query($conn,$sql);


    if(! $run_query ) {
      die('Could not get data: ' . mysqli_error());
   }

   while($row = mysqli_fetch_array($run_query, MYSQLI_ASSOC)) {
      echo "name:{$row['first_name']}  <br> ".
            "Last:{$row['last_name']}  <br> ";

        }
Mike J
  • 15
  • 3