Hello, so I got a json from server:
I build a variable with the json answers with the data.
$myitemnames[]
$myitemsquantity[]
$whatever[]
If I output my projects $myitemsname I get codes insted of the names.
wqerqwet
qweqwet
qwezxxz
So I have made a table in mysql with the codes and the names since I named them I know what the codes translate to.
ID | itemcode | itemname
1 | wqerqwet | Silver Chairs
2 | qweqwet | Black Metal Chairs
3 | qwezxxz | White Chairs
I output all the data from the json in a foreach loop to an html table:
item | stock | whatever
wqerqwet | 2 | etc
qweqwet | 1 | etc
qweqwet | 5 | etc
The problem I have is I don’t know how to use the code to search the mysql database I made, and search the value in the column next to it(the item name)and replace this value in the html table for the code.
I’ve been trying to test and make a code with one Item to test it but still haven’t got the result I want, I’m kinda of lost.
$item = "qwetqwe";
require_once 'connection.php';
$stmt = $pdo->prepare("SELECT itemcode FROM codestable WHERE $item=?");
$stmt->execute([$item]);
$result = $stmt->fetch();
if(array_search($item, $result))
{
echo "Match found";
} else {
echo "Not found";
}