2014-06-16 115 views
-1

之前,我開始我已經看過了相關的答案,但我不能算出這個應該在哪裏工作?

你好,我想從formtype =「問題1」 值取只用數據的值是根據列的數據庫formtype爲Question1,它是一個無線電選項值,它是我用來將信息重定向到一個頁面的三個值之一,所以我必須在每個頁面上執行此操作以獲取該特定信息。我的問題是,爲什麼不選擇包含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

首先糾正你的連接,如mysql_select_db(「意見書」,$ con_object) – Sadikhasan

+1

不跟你的錯誤,但請看看庫MySQLi或PDO的數據庫處理的mysql_ *功能已棄用 –

+0

當您執行查詢時,phpMyAdmin會顯示什麼內容? –

回答

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)){