什么时候不应该工作?

时间:2014-06-16 08:13:53

标签: php mysql database where

在我开始之前,我已经查看了相关的答案,但我无法弄明白

您好,我正在尝试仅使用formtype ='Question1'中的数据来获取值 值在列表格类型下的数据库中作为Question1,它是一个无线电选项值,它是我用于将信息重定向到一个页面的3个值之一,因此我必须在每个页面上执行此操作以获取该特定信息。我的问题是,为什么不选择包含Question1的值?它根本不抓取任何东西,但如果我摆脱WHERE它抓住所有信息就好了(我只想抓住包含Question1的那个)。为什么是这样?它没有显示SELECT的任何错误,所以我不知道我做错了什么。

我已连接到数据库

<?php $db_name = 'submissions';
$db_user = 'root';
$db_pass = '';
$db_host = 'localhost';
mysql_connect("localhost", $db_user, $db_pass) or die(mysql_error());
mysql_select_db("submissions") or die(mysql_error());
$query1 = mysql_query("SELECT actual_quote,poster,formtype FROM data WHERE formtype = 'Question1'");   
$info = mysql_fetch_array($query1); 
while($info = mysql_fetch_array($query1)){
echo ' 
<div class="wrapper">
<div class="submissions">
<div class="logo-logo"><h2>Questions.</h2>
<div class="checkboxes">'.$info['formtype'].'
</div>

</div>
<div class="top-submit">
&#8220'. $info["actual_quote"] . '&#8221;
</div>
<div class="poster">- '. $info["poster"].'
<div class = "like">
<a href = "javascript:countClicksLike();" class = "btn btn-large" style =     "color:green;">Like</a>
<p id = "like" style = "color:green;">0</p>
</div>
<div class = "dislike">
<a href = "javascript:countClicks();" class = "btn btn-large" style = "float:right;   color:red;">Dislike</a>
<p id = "dis" style = "color:red;">0</p>
</div>
</div>
<!-- use select to get the items to stay on the page-->

</div>
</div>
</div>
';
}

?>

有什么建议吗?

1 个答案:

答案 0 :(得分:0)

修正这些行:

$link = mysql_connect("localhost", $db_user, $db_pass) or die(mysql_error());
mysql_select_db("submissions",$link) or die(mysql_error());
$query1 = mysql_query("SELECT actual_quote,poster,formtype FROM data WHERE formtype = 'Question1'",$link);   
//delete this-> $info = mysql_fetch_array($query1);   ?
while($info = mysql_fetch_array($query1)){
相关问题