How to differentiate data to be read between two tables when username and password is passed

50
February 11, 2019, at 3:40 PM

I am using volley in my mobile development login and instead of one table, I used two.

At first I was having trouble because my login process only shows the data of the client. When I put on my username and password as client, it does show but when I use an username and password from the stylist, still a client's data shows. Now I discovered it's from my main menu's problem because I have a php code for reading details and what is there is only reading the client's table. What I am needing help for now is how to correctly read the data of the two tables and pass it for my main menu?

This is my readDetail.php

<?php 
if($_SERVER['REQUEST_METHOD'] == 'POST'){
$id = $_POST['id'];
require_once 'connect.php';
$sql = "SELECT * FROM client WHERE client_id=$id";
$response = mysqli_query($conn, $sql);
//HOW CAN I ALSO SELECT FROM STYLIST AND GO INSIDE THE QUERY FOR PASSING THE DATA? MY SQL QUERY IS ONLY FOR CLIENT AND THIS IS WHY I ONLY GET DATA FROM CLIENT. CAN SOMEONE POINT ME OUT WHAT TO QUERY TO ALSO PASS FOR THE STYLIST DATA?
$result = array();
$result['read'] = array();
if(mysqli_num_rows($response) === 1){
    if($row = mysqli_fetch_assoc($response)){
    $h['name']          = $row['name'];
    $h['phone_number']  = $row['phone_number'];
    $h['gender']        = $row['gender'];
    $h['address']       = $row['address'];
    $h['occupation']    = $row['occupation'];
    $h['birth_date']    = $row['birth_date'];
    $h['user_type']     = $row['user_type'];
    $h['image']         = $row['photo'];
    array_push($result["read"], $h);
    $result["success"] = "1";
    $result["message"] = "success";
    echo json_encode($result);
    }
}else{
    $result["success"] = "0";
    $result["message"] = "$sql";
    echo json_encode($result);
}

}

?>

Hoping to be helped out as soon as possible

Answer 1

This has been solved by also adding a usertype to each of my tables. also passing to their parameters and bringing if statements into it so it defines what table to open :) hihi

READ ALSO
Avoid inserting duplicate data in csv with PHP

Avoid inserting duplicate data in csv with PHP

I store data into a csv file by this:

51
Why can&#39;t I connect to database in xampp? [on hold]

Why can't I connect to database in xampp? [on hold]

I have read all the answers relating to this issue but i couldn't come up with any solutionI have changed config

51
PHP and GEOHASH: how to use GeoHash to calculate distance between 2 points?

PHP and GEOHASH: how to use GeoHash to calculate distance between 2 points?

I understood that GEOHASH allows to hash (lat,long) into a String

78