<?php include "mysql_connect.php";?>
<html>
<head>
<title>PHP MySQL กับการตั้งค่า TABINDEX : SUNZANDESIGN.BLOGSPOT.COM</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" href="css/bootstrap.min.css">
<style>
.highlight {
background-color: #FFFF88;
}
.red{
color : red;
}
.blue{
color : blue
}
</style>
</head>
<body>
<div class="container">
<div class="header clearfix">
<h3 class="text-muted">
<span class="blue">PHP MySQL</span> การตั้งค่า
<span class="red">TABINDEX</span>
: SUNZANDESIGN.BLOGSPOT.COM </h3>
</div>
<br/>
<div class="row">
<?php
$data = array();
$sql = "SELECT * FROM product ";
//echo $sql;
if ($result = $conn->query($sql)) {
while($row = $result->fetch_array(MYSQLI_ASSOC)){
$data[] = $row;
}
/* free result set */
$result->close();
}
$conn->close();
?>
<table class="table table-bordered">
<thead>
<tr>
<th>รหัส</th>
<th>ชื่อ</th>
<th>จำนวน</th>
<th>ราคา</th>
<th>รูปภาพ</th>
<th>หมายเหตุ</th>
</tr>
</thead>
<tbody>
<?php
foreach($data as $row){
?>
<tr>
<td><?php echo $row['ProductID'];?></td>
<td><?php echo $row['ProductName'];?></td>
<td>
<input class="qty"
value="<?php echo $row['Qty'];?>" /></td>
<td>
<input class="price"
value="<?php echo number_format($row['Price'],2);?>" />
</td>
<td><input value="<?php echo $row['Picture'];?>" /></td>
<td><textarea></textarea></td>
</tr>
<?php }?>
</tbody>
</table>
</div>
</div><!-- container -->
<footer class="footer">
<br/><br/>
<div class="container">
<i>ติดตามความเคลื่อนไหวได้ที่ :: <a href='https://www.facebook.com/ToBeDeveloper'>https://www.facebook.com/ToBeDeveloper</a></i>
</div>
</footer>
</div> <!-- /container -->
<script src="js/jquery.min.js"></script>
<script src="js/highlight.js"></script>
<script>
$('input.price, input.qty').each(function(index) {
var tabindex = index + 1;
$(this).attr("tabindex", tabindex);
alert('SET TABINDEX : ' + index);
$(this).addClass('red');
});
</script>
</body>
</html>
ตัวอย่าง ผลลัพธ์ที่ได้จากการจองในฐานข้อมูล ตาราง tb_room สร้างตารางรายชื่อห้องประชุม สำหรับ id นั้นเป็น Primarykey จะกำหนดให้สร้างอัตโนมัติ ทุกครั้งที่เราเพิ่มชื่อห้องประชุมใหม่ -- -- Database: `tobedev_example` -- -- -------------------------------------------------------- -- -- Table structure for table `tb_room` -- CREATE TABLE IF NOT EXISTS `tb_room` ( `id` int(11) NOT NULL, `name` varchar(30) NOT NULL ) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8; -- -- Dumping data for table `tb_room` -- INSERT INTO `tb_room` (`id`, `name`) VALUES (1, 'ห้องประชุม 1'), (2, 'ห้องประชุม 2'), (3, 'ห้องประชุม 3'), (4, 'ห้องประชุม 4'), (5, 'ห้องประชุม 5'); -- -- Indexes for dumped tables -- -- -- Indexes for table `tb_room` -- ALTER TABLE `tb_room` ADD PRIMARY KEY (`id`); -- -- AUTO_INCREMENT for dumped tables -- -- -- AUTO_INCREMENT for table `tb_room` -- ALTER TABLE `tb_room` MODIFY `i...
ความคิดเห็น
แสดงความคิดเห็น