Php 通过一个查询获取多个值
Php 通过一个查询获取多个值,php,sql,where,Php,Sql,Where,+----+-----------+-----+ | ID | name |price| +----+-----------+-----+ | 1 |dest_tahiti| 10 | | 2 |dest_bora | 20 | | ...| ... | ... | +----+-----------+-----+ 我想在name=。。。对于与mysqli\u fetch\u数组相同的查询? 您可以帮助我吗?您可以将名称作为输出包含在查询中。然后迭代返回的行,
+----+-----------+-----+
| ID | name |price|
+----+-----------+-----+
| 1 |dest_tahiti| 10 |
| 2 |dest_bora | 20 |
| ...| ... | ... |
+----+-----------+-----+
我想在name=。。。对于与mysqli\u fetch\u数组相同的查询?
您可以帮助我吗?您可以将名称作为输出包含在查询中。然后迭代返回的行,构建一个数组,其中索引是名称,值是价格 $price=选择名称,从“大溪地目的地”、“博拉目的地”中名称所在的费率中选择价格; $price\u result=mysqli\u query$connect$price; $prix_结果=[]; 当$row=mysqli\u fetch\u数组$price\u result时,mysqli\u ASSOC{ $prix_结果[$row['name']]=$row['price']; } echo$prix_result['dest_tahiti']; echo$prix_结果['dest_bora'];
$price="SELECT price FROM rates WHERE name IN('dest_tahiti','dest_bora', ...) ";
$price_prep= mysqli_query($connect,$price);
$price_result= mysqli_fetch_array($price_prep);
echo $prix_result["price"] //Just display price for dest_tahiti with WHERE = 'dest_tahiti';
echo $prix_result["price"] //Just display price for dest_bora with WHERE = 'dest_bora';