It is impossible to build a multidimensional array. There are two MySQL tables: lost , history_lots .
An array is created from the first table. And in the second table we have to check if we really have such a lot, and if it is, then we find the ID in the array and set the my key to true . This is the very end of the array. Now, respectively, at the end everywhere "my":"false" .
My code is:
$rows = array(); $query = "SELECT * FROM cs_lots WHERE active_lot='1'"; $res2 = mysql_query($query) or die(mysql_error()); $query = "SELECT DISTINCT id_lot FROM cs_lots_history WHERE user_steamid='".$_SESSION['steamid']."'"; $result1 = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($res2)) { $rows []= array( 'id' => $row['id'], 'inv_id' => $row['inv_id'], 'inv_assets' => $row['inv_assets'], 'name' => $row['inv_name'], 'inv_image' => $row['inv_image'], 'inv_rarity' => $row['inv_rarity'], 'inv_color' => $row['inv_color'], 'inv_type' => $row['inv_type'], 'inv_price' => $row['inv_price'], 'price_ticket' => $row['price_ticket'], 'maxUsers' => $row['places'], 'nowUsers' => $row['now_places'], 'my' => false ); } The array view itself:
LOTS = [{"id":"166","inv_id":"989","inv_assets":"3432669422","name":"Redline ","inv_image":"image","inv_rarity":"Field-Tested","inv_color":"d32ce6","inv_type":"1","inv_price":"2105.97","price_ticket":"14","maxUsers":"240","nowUsers":"1","my":false}, {"id":"167","inv_id":"929","inv_assets":"3551634073","name":"Hyper Beast ","inv_image":"image","inv_rarity":"Battle-Scarred","inv_color":"eb4b4b","inv_type":"1","inv_price":"924.43","price_ticket":"8","maxUsers":"180","nowUsers":"0","my":false}, {"id":"168","inv_id":"1104","inv_assets":"3313740799","name":"Asiimov ","inv_image":"image","inv_rarity":"Battle-Scarred","inv_color":"eb4b4b","inv_type":"1","inv_price":"1495.00","price_ticket":"13","maxUsers":"180","nowUsers":"19","my":false}, {"id":"169","inv_id":"847","inv_assets":"3603670527","name":"Jaguar ","inv_image":"image","inv_rarity":"Battle-Scarred","inv_color":"eb4b4b","inv_type":"1","inv_price":"2711.65","price_ticket":"13","maxUsers":"320","nowUsers":"8","my":false}, {"id":"170","inv_id":"1100","inv_assets":"3313741398","name":"Asiimov ","inv_image":"image","inv_rarity":"Field-Tested","inv_color":"eb4b4b","inv_type":"1","inv_price":"2756.70","price_ticket":"16","maxUsers":"260","nowUsers":"10","my":false}, {"id":"171","inv_id":"899","inv_assets":"3551642235","name":"Atomic Alloy ","inv_image":"image","inv_rarity":"Factory New","inv_color":"d32ce6","inv_type":"1","inv_price":"862.50","price_ticket":"8","maxUsers":"180","nowUsers":"1","my":false}]; How can I get the result from the $result1 and compare it with the ID key in the array?
For example, if $result1_row['id_lot'] = $row['id'] - then at the end of the array body we write my:true .