我是PHP和MySQL的新手,我正在尝试编写一个代码,其中显示列value
列attribute_id = 64
的所有值。这就是我所写的内容,但我似乎无法展示它:
<?
mysql_connect ("localhost","cpsdev_mage1","**********");
mysql_select_db ("cpsdev_mage1");
$sql = "select 'value' from mage_catalogsearch_fulltext
WHERE 'Attribute_id' = 64";
$result = mysql_query ($sql) or die($myQuery."<br/><br/>".mysql_error());
while($row = mysql_fetch_array($result))
{
echo $row['value'];
}
?>
答案 0 :(得分:1)
试试这个: -
$sql = "select value from mage_catalogsearch_fulltext WHERE Attribute_id = 64";
答案 1 :(得分:0)
试试这段代码 -
<?php
mysql_connect ("localhost","cpsdev_mage1","**********");
mysql_select_db ("cpsdev_mage1");
$sql = "select value from mage_catalogsearch_fulltext WHERE Attribute_id = 64";
$result = mysql_query ($sql) or die($myQuery."<br/><br/>".mysql_error());
while($row = mysql_fetch_array($result,MYSQL_ASSOC))
{
echo $row['value'];
}
?>
我添加了什么 -
<?
更改为<?php
。mysql_fetch_array($result,MYSQL_ASSOC)
。答案 2 :(得分:0)
<?php // instead of <?
mysql_connect ("localhost","cpsdev_mage1","**********");
mysql_select_db ("cpsdev_mage1");
$sql = "SELECT value FROM mage_catalogsearch_fulltext
WHERE Attribute_id = 64"; // <------------ removed un-needed single quotes
$result = mysql_query ($sql) or die("<br/><br/>".mysql_error()); // removed '$myQuery'
while($row = mysql_fetch_array($result))
{
echo $row['value'];
}
?>
答案 3 :(得分:0)
$sql = "select value from mage_catalogsearch_fulltext WHERE Attribute_id = 64";
此外,您的代码应以<?php
而不是<?
答案 4 :(得分:0)
作为问题的解决方案,请尝试执行以下查询
$sql = "select value from mage_catalogsearch_fulltext
WHERE 'Attribute_id' = 64";
在sql查询列中不需要用引号括起来。 并且还喜欢使用php完整标签而不是短标签,因为在某些服务器中,短标签可能被设置为关闭,这可能会在不同的服务器环境中产生问题