|
|
|
สอบถามครับ มันขึ้นข้อมูลซ้ำกันทั้ง ๆ ที่ไม่มีข้อมูลและไม่เข้าเงื่อนไข |
|
|
|
|
|
|
|
ปัญหาคือ กรอบหมายเลข 6 และ 7 มันขึ้นชื่อเรื่องซ้ำกับกรอบแรก(หมายเลข 5) ทั้ง ๆ ที่ไม่มีข้อมูล
Code (PHP)
<div id="menu8" class="tab-pane fade">
<?php
$machine = $db->prepare('SELECT mType,mName,maintaince,id,inuse, SUBSTRING(mName,-2,2) AS substr
FROM tbl_machine
WHERE mType = 10
ORDER BY substr ASC');
$machine->execute();
?>
<?php
$i = 0;
while($row = $machine->fetch(PDO::FETCH_ASSOC)) {
// $m_id = $row['id'];
// $status = 'Y';
// $log = $db->prepare('SELECT Id,machine_id
// FROM tbl_logs
// WHERE machine_id = :m_id AND status = :status
// ORDER BY Id DESC');
// $log->bindParam(':m_id',$m_id,PDO::PARAM_STR);
// $log->bindParam(':status',$status,PDO::PARAM_STR);
// $log->execute();
// $r = $log->fetch(PDO::FETCH_ASSOC);
// $logs_id = $r['Id'];
// $mat = $db->prepare('SELECT title,barcode
// FROM tbl_material
// WHERE logs_id = :logs_id
// ORDER BY Id DESC');
// $mat->bindParam(':logs_id',$logs_id,PDO::PARAM_STR);
// // $mat->bindParam(':status',$status,PDO::PARAM_STR);
// $mat->execute();
// $r_mat = $mat->fetch(PDO::FETCH_ASSOC);
//print_r($r_mat);
?>
<div class="col-sm-2 col-md-2" style="padding-top: 1cm;" >
<div class="thumbnail">
<?php
$disabled = '';
if ($row['maintaince'] <> 0) {//เผื่อมีสถานะอื่นที่ไม่ใช่ 1
$pic = 'image/installation-icon.jpg';
$disabled = 'disabled';
$text = 'ชำรุด';
$alert = 'danger';
}
else if ($row['inuse'] == 1) {
$m_id = $row['id'];
$status = 'Y';
$log = $db->prepare('SELECT Id,machine_id
FROM tbl_logs
WHERE machine_id = :m_id AND status = :status
ORDER BY Id DESC');
$log->bindParam(':m_id',$m_id,PDO::PARAM_STR);
$log->bindParam(':status',$status,PDO::PARAM_STR);
$log->execute();
$r = $log->fetch(PDO::FETCH_ASSOC);
$logs_id = $r['Id'];
$mat = $db->prepare('SELECT title,barcode,call_on
FROM tbl_material
WHERE logs_id = :logs_id
ORDER BY Id DESC');
$mat->bindParam(':logs_id',$logs_id,PDO::PARAM_STR);
// $mat->bindParam(':status',$status,PDO::PARAM_STR);
$mat->execute();
$r_mat = $mat->fetch(PDO::FETCH_ASSOC);
// print_r($r_mat);
$call_on = $r_mat['call_on'];
$call = $db->prepare('SELECT result_callno,result_time
FROM tbl_result
WHERE result_callno = :call_on ');
$call->bindParam(':call_on',$call_on,PDO::PARAM_STR);
$call->execute();
$r_call = $call->fetch(PDO::FETCH_ASSOC);
$pic = 'image/User-Computer.png';
$text = 'คืน';
$alert = 'warning';
$in = 'return';
}
else {
$pic = 'image/My-Computer-icon.png';
$text = 'ยืม';
$alert = 'primary';
$in = 'add';
}
?>
<img src="<?=$pic?>" alt="...">
<div class="caption">
<h5><?=$row['mName'];?></h5>
<p><?=$r_mat['call_on'];?></p>
<p class="text-primary"><?=$r_mat['title'];?></p>
<p class="text-primary"><?=$r_call['result_time'];?></p>
<p><a href="Machineborrowform.php?action=<?=$in;?>&&id=<?=$row['id'];?>&&inuse=<?=$row['inuse'];?>" class="btn btn-<?=$alert?>" role="button" <?=$disabled?> > <?=$text?></a><!-- <a href="javascript:if(confirm('ยืนยันการคืนทรัพยากร \r\n<?=$row['mName'] ?>')==true){window.location='return.php?id=<?=$row['id'];?>&&inuse=<?=$row['inuse'];?>';}" class="btn btn-default" role="button" <?=$a?> <?=$b?> >คืน</a> --></p>
</div>
</div>
</div>
<?php
$i++;
}
?>
</div>
Tag : PHP, MySQL, HTML/CSS, Ajax, jQuery
|
|
|
|
|
|
Date :
2015-09-18 20:54:19 |
By :
littlebeer |
View :
1180 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ใน else กำหนดค่าว่างให้กับตัวแปรข้อมูลด้วยครับ มันจำของเก่า
|
|
|
|
|
Date :
2015-09-19 16:45:01 |
By :
NewbiePHP |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 04
|