0

我对 PHP 和 MySQL 相当陌生,正在尝试编写一个代码,在其中显示列的所有valueattribute_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'];
}

?>
4

5 回答 5

1

尝试这个 :-

  $sql = "select value from mage_catalogsearch_fulltext WHERE Attribute_id = 64"; 
于 2012-10-30T12:09:15.557 回答
0

作为您的问题的解决方案,请尝试执行以下查询

          $sql = "select value from mage_catalogsearch_fulltext 
          WHERE 'Attribute_id' = 64"; 

在 sql 查询列中不需要用引号引起来。并且更喜欢使用 php 完整标签而不是短标签,因为在某些服务器中,短标签可能会设置为关闭,这可能会在不同的服务器环境中产生问题

于 2012-10-30T13:09:12.573 回答
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'];
}

?>

我补充的——

  1. 改为。<?_<?php
  2. 在查询中将“value”更改为value并将“Attribute_id”更改为Attribute_id 。
  3. 添加mysql_fetch_array($result,MYSQL_ASSOC).
于 2012-10-30T12:11:22.877 回答
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'];
  }

?>
于 2012-10-30T12:11:45.270 回答
0
$sql = "select value from mage_catalogsearch_fulltext WHERE Attribute_id = 64"; 

<?php您的代码也应该以not开头<?

于 2012-10-30T12:14:33.667 回答