我想使用 where id= 'x'
从数据库表中选择一行。
问题是我希望能够动态更改“x”,因此如果我需要选择 id=“y”
的行,我希望能够在另一个中加载 y行并从该行读取它。
抱歉我的英语不好。
<?php
$id = a field from another table
$result = mysqli_query($con,"SELECT * FROM text where id= '$id'");
while($row = mysqli_fetch_array($result))
{
echo $row['text_area'];
}
?>
最佳答案
试试这段代码:
<?php
$result1 = mysqli_query($con,"SELECT * FROM id_val");
while($row1 = mysqli_fetch_assoc($result1)){
$result = mysqli_query($con,"SELECT * FROM text where id= '{$row1['value']}'");
while($row = mysqli_fetch_assoc($result))
{
echo $row['text_area'];
}
}
?>
关于mysql - 从数据库中选择 id 等于变量的内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39311270/