简体   繁体   English

PHP MySQL在另一行中包含一个行ID

[英]Php mysql include a row id in another row

I have a mysql database where i'd like to include the contents of a row in another row. 我有一个mysql数据库,我想在其中包含另一行的内容。 The content of all my rows is static html. 我所有行的内容都是静态html。 I am looking for something similar to the 'include' command. 我正在寻找类似于“ include”命令的内容。

This is an example: 这是一个例子:

Row 1=A
Row 2=fast
Row 3=red

In Row 4 i have the content 'car'. 在第4行中,内容为“汽车”。 I need to include the content of row 1, 2, and 3 before the content of row 4. Therefore the output would be A fast red car. 我需要在第4行的内容之前包含第1、2和3行的内容。因此,输出将是一辆红色快车。

Is this possible? 这可能吗? I only have one database, so there are not external references. 我只有一个数据库,所以没有外部引用。

My mysql knowledge is near zero. 我的MySQL知识几乎为零。 My programmer was lazy and copied all the same html to each row. 我的程序员很懒,将所有相同的html复制到每一行。 So now when i update i have to update the static html in many rows. 所以现在当我更新时,我必须在许多行中更新静态html。

Thanks 谢谢

You could simply do something like this: 您可以简单地执行以下操作:

$query = mysqli_query($database_connection, "SELECT * FROM table_name LIMIT 4");
while ($row = mysqli_fetch_array($query)) {

echo $row['column_name']; }

I hope this is what you mean. 我希望这就是你的意思。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM