我想从数据库表中选择一行,使用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'];
}
?>
答案 0 :(得分:0)
试试这段代码:
<?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'];
}
}
?>