将db字段分配给具有动态构建的var名称的变量 [英] assign db fields to variables with dynamically built var names
问题描述
我需要将数据库数据存储在变量中,以便我可以使用它。
请在下面查看我在脚本中尝试做的事情....
如果你回复这些东西就行了。这意味着如果我回到$ row [''a5];我得到了我想要的数据,但我无法将数据存储在可维护的数据中。
我需要的东西从$ a1到$ a18,然后在每个商店中来自数据库名称a5中一个字段的数据。
谢谢
[PHP]
<? php
$ con = mysql_connect(" localhost"," *****"," ******");
if (!$ con)
{
die(''无法连接:''。mysql_error());
}
mysql_select_db(" *******",$ con);
$ result = mysql_query(" SELECT * FROM hole ORDER BY a5);
while($ row = mysql_fetch_array($ result))
{
$ a1 = $ row [''a5''];
$ a2 = $ row [''a5'']; ///////需要给出第二个结果
$ a3 = $ row [''a5'']; ///////需要给出第三个结果
}
echo"< img name = \" Hole \" SRC = \" $ a1.jpg\"宽度= \" 32\"高度= \" 32\" alt = \" Hole \">" ;;
mysql_close($ con);
?>
[/ PHP]
Hi,
I need to store database data in variables so I can work with it.
Please se below what I am trying to do in my script....
If you echo the stuff out is work fine. Meaning if I go echo $row[''a5]; I get the data I want but I can''t get the data to store in a vairable.
I need something that goes from $a1 to $a18 and in each of then store the data from one field in the database name a5.
Thanks
[PHP]
<?php
$con = mysql_connect("localhost","*****","******");
if (!$con)
{
die(''Could not connect: '' . mysql_error());
}
mysql_select_db("*******", $con);
$result = mysql_query("SELECT * FROM hole ORDER BY a5");
while($row = mysql_fetch_array($result))
{
$a1 = $row[''a5''];
$a2 = $row[''a5'']; /////// needs to give second result
$a3 = $row[''a5'']; /////// needs to give third result
}
echo "<img name=\"Hole\" src=\"$a1.jpg\" width=\"32\" height=\"32\" alt=\"Hole\">";
mysql_close($con);
?>
[/PHP]
推荐答案
row [''a5];我得到了我想要的数据,但是我无法将数据存储在可维护的数据中。
我需要的东西来自
row[''a5]; I get the data I want but I can''t get the data to store in a vairable.
I need something that goes from
a1到
a18然后在每个中存储数据库名称a5中的一个字段的数据。
谢谢
[PHP]
<?php
a18 and in each of then store the data from one field in the database name a5.
Thanks
[PHP]
<?php
这篇关于将db字段分配给具有动态构建的var名称的变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!