Как поймать несколько результатов в запросе PHP sql ⇐ Php
-
Anonymous
Как поймать несколько результатов в запросе PHP sql
I've got an API that checks with a sql database for a part number but there is one case where there are multiple part numbers for one SKU and when it gets that result it returns nothing on the UI, is there any way to choose one of the results? for now I had this
$squery ="SELECT part_no FROM parts where cb_master ='".$sku."'"; $res = mysqli_query($connectiondb, $squery); $i=0; $row = mysqli_fetch_assoc($resultado); $part = $row['part_no']; if(is_array($row)){ $check=0; while($check=1){ $fixQuery = "SELECT no_item FROM orderdet WHERE no_order = $order AND no_item = $part[$i]"; $arrayPart=mysqli_query( $connectiondb, $fixQuery); $i++; if($arrayPart!=''){ $parte=$arrayPart; $check=1; return $part; } } } i had a "limit 1" on the query but that didn't work, im stuck as to how to choose a single result (any of them would work), i'd be grateful for any ideas or help
Источник: https://stackoverflow.com/questions/781 ... -sql-query
I've got an API that checks with a sql database for a part number but there is one case where there are multiple part numbers for one SKU and when it gets that result it returns nothing on the UI, is there any way to choose one of the results? for now I had this
$squery ="SELECT part_no FROM parts where cb_master ='".$sku."'"; $res = mysqli_query($connectiondb, $squery); $i=0; $row = mysqli_fetch_assoc($resultado); $part = $row['part_no']; if(is_array($row)){ $check=0; while($check=1){ $fixQuery = "SELECT no_item FROM orderdet WHERE no_order = $order AND no_item = $part[$i]"; $arrayPart=mysqli_query( $connectiondb, $fixQuery); $i++; if($arrayPart!=''){ $parte=$arrayPart; $check=1; return $part; } } } i had a "limit 1" on the query but that didn't work, im stuck as to how to choose a single result (any of them would work), i'd be grateful for any ideas or help
Источник: https://stackoverflow.com/questions/781 ... -sql-query
Мобильная версия