 |
|
โค็ด
Code (PHP)
<?php
$con = mysqli_connect("localhost", "root", "", "coffee");
$str = "SELECT * FROM listproduct;" ;
$obj = mysqli_query($con, $str);
$Result = mysqli_fetch_array($obj);
?>
<table class="table table-striped">
<thead>
<tr>
<th>ID สินค้า</th>
<th>ชื่อสินค้า</th>
<th>ราคาสินค้า (บาท)</th>
<th>รูปสินค้า</th>
<th>การจัดการ</th>
</tr>
</thead>
<tbody>
<?php
while($Result = mysqli_fetch_array($obj))
{
?>
<tr>
<td><div align="rigth"><?php echo $Result["id_product"];?></div></td>
<td><?php echo $Result["name_product"];?></td>
<td><?php echo $Result["price_product"];?></td>
<td><?php echo $Result["pic_product"];?></td>
<td><?php echo $Result["id_p"];?></td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
</div>
ฐานข้อมูล
Code (SQL)
-
-- Table structure for table `listproduct`
--
CREATE TABLE `listproduct` (
`id_p` int(11) NOT NULL,
`name_product` text NOT NULL,
`price_product` int(11) NOT NULL,
`pic_product` text NOT NULL,
`id_product` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Dumping data for table `listproduct`
--
INSERT INTO `listproduct` (`id_p`, `name_product`, `price_product`, `pic_product`, `id_product`) VALUES
(1, 'ๅ/-ๅ/-ๅ', 213, '213', 123),
(2, 'CHOCOLATE BANANA CAKE', 120, '222', 222),
(3, 'BANOFMII', 115, '333', 333),
(4, 'CREPE CAKE', 160, '444', 444),
(5, 'test', 155, '213', 332),
(7, 'ๅ/ๅ122', 0, '121', 121212),
(8, '1212', 1212, '', 2112);
--
-- Indexes for dumped tables
--
--
-- Indexes for table `listproduct`
--
ALTER TABLE `listproduct`
ADD PRIMARY KEY (`id_p`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `listproduct`
--
ALTER TABLE `listproduct`
MODIFY `id_p` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=9;COMMIT;

Tag : HTML, HTML5
|
|
 |
 |
 |
 |
Date :
2017-08-24 23:27:58 |
By :
bankzab17691 |
View :
798 |
Reply :
4 |
|
 |
 |
 |
 |
|
|
|
 |