0
我有一些代碼,從MySQL數據庫拉數據一切都拉大,日期,變量等。我有的問題是唯一的整數是每次返回0。整數從MySQL總是返回0
while($row = mysqli_fetch_array($result)) {
$fufilled = "1";
$flag = $row['flag'];
$shopnumb = $row['Shopnumb'];
$shoptype = $row['Shop_type'];
...
$shoptype
和$shopnumb
都返回正確但每次的內容,即使數據庫中有1,1,1,1,0爲5行時間$標誌返回0
CREATE TABLE `Shop_data` (
`Shopnumb` int(15) NOT NULL AUTO_INCREMENT COMMENT 'shop id number',
`flag` tinyint(1) NOT NULL DEFAULT '1' COMMENT '1=unread 0=read',
`CID` int(15) NOT NULL COMMENT 'Client this shop belongs to',
`SID` varchar(50) DEFAULT NULL COMMENT 'identifys which survey to use',
`comp_date` date DEFAULT NULL COMMENT 'Completion Date',
`sched_date` date DEFAULT NULL COMMENT 'Scheduled shop date',
`shop_comp` smallint(1) NOT NULL DEFAULT '0' COMMENT 'shopper submitted report',
`edit_comp` smallint(1) NOT NULL DEFAULT '0' COMMENT 'Report has been edited',
`return_shop` smallint(1) NOT NULL DEFAULT '0' COMMENT 'return report to shopper for editing',
`report_comp` smallint(1) NOT NULL DEFAULT '0' COMMENT 'report ready for client',
`Shop_type` varchar(50) DEFAULT NULL,
`Shoploc` varchar(100) DEFAULT NULL,
`shop_cost` decimal(10,2) DEFAULT NULL COMMENT 'Normal or adjusted cost of shop',
`shop_reimb` decimal(10,2) DEFAULT NULL COMMENT 'Shopper reimburstment cost',
`shop_pay` decimal(10,2) DEFAULT NULL COMMENT 'Total cost',
`shopper_assign` varchar(200) DEFAULT NULL COMMENT 'Identifys which shopper assigned',
PRIMARY KEY (`Shopnumb`),
UNIQUE KEY `Shopnumb` (`Shopnumb`)
) ENGINE=MyISAM AUTO_INCREMENT=2252 DEFAULT CHARSET=latin1
我的查詢
SELECT * FROM Shop_data WHERE CID='".$_SESSION['CID']."' AND report_comp='1' AND DATEDIFF(CURDATE(), comp_date) <".$lengthoftime." ORDER BY comp_date DESC;
就像我說的,除了標誌
我一切恢復大˚F聲明
if ($flag = '0') {
echo "<td align=\"center\"> </td>";
} else {
echo "<td align=\"center\"> <img align=\"middle\" src=\"/images/flag.png\"> </td>";
}
固定 如果($標記== 0){
您需要提供更多的信息 - 'SHOW CREATE TABLE yourtable;',你正在運行的查詢,並運行在mysql客戶端,查詢的結果將是一個良好的開端... – 2012-07-27 02:15:47
同時確認它返回「0」而不是「NULL」,並確認索引在數組中(isset($ row ['flag']))。當轉換爲一個整數時,所有的都會顯示「0」,但是會有所不同,並給出了不同的線索。 – Robbie 2012-07-27 02:22:21
接下來的調試,「print_r($ row);」因爲這顯示了實際的行數據。如果這是0,那麼它在數據庫中爲0。如果它在數組中是「1」,那麼你在其他地方將它改爲「0」。 – Robbie 2012-07-27 02:26:26