MySQl database+php substring and query

I have this code but I do not know why it does not work.
I wrote this code for 2 tables in my database to get some values from some column of these tables.

It is like as this that my users have this possibility of using 2 users or Id number to enter the page.
The code should compare the user with “ ” and the Id number with “ ”. then showing the results in Jason format.

The important fact is that for the Id number the cell of the table contains other information I need just the first 6 numbers.

User = 109119911
Id number = 122323 from the whole array 122323 Express Lane, Sarasota, FL 34238 USA,


\header(‘Access-Control-Allow-Origin: *’);
\header(‘Content-Type: application/json; charset=utf-8’);
$pU = $_GET[‘user’] ?? null;
// $pUser = $_GET[‘user’] ||$_GET[‘ID’] ?? null; //user for user and ID for Id number

if (\is_null($pUser) || $pUser === ‘’) {
header(‘HTTP/1.0 403 Forbidden’);
echo \json_encode([‘e’ => ‘invalid’]);

$query = ‘SELECT
table1.F as usID, Table1.*, Table1.q as q, table2.S,substring(S,1,6) as
FROM table1
LEFT JOIN table2 ON (table1.F = table2.F)
WHERE P = "’ . mysqli_real_escape_string($mysqli, $pU) . '" ';

$ham = $mysqli->query($query);

$data = [];
while ($row = $ham->fetch_array()) {
$data[] = [
‘usId’ => $row[‘userID’],
‘fad’ => (int) $row[‘ID’],
‘q’ => !!$row[‘q’],
‘k’ => !!$row[‘k’],
‘T’ => !!$row[‘T’],
‘Sq’ => substr($row[‘Sq’]),
// ‘Sq’ => substr($row[‘Sq’], 0, 5),

echo \json_encode($data);

With so many thanks,

What should this mean for anyone?

I mean, I am here to request for an expert correction.
I wrote lots of possible codes but still unsuccessful. If my explanation is not clear let me know where exactly then I will explain that more.

Sponsor our Newsletter | Privacy Policy | Terms of Service