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