ThaiSEOBoard.com

พัฒนาเว็บไซต์ => Programming => ข้อความที่เริ่มโดย: wristy032 ที่ 23 มีนาคม 2015, 21:22:10



หัวข้อ: มีเรื่องสงสัยกับการใช้ loop php ใน html ครับ
เริ่มหัวข้อโดย: wristy032 ที่ 23 มีนาคม 2015, 21:22:10
คือผมจะทำลูปอะครับตรงส่วนตารางด้านล่าง ผมใส่โค้ดแบบนี้ละมันเละอะครับ ถ้าผมจะทำloopต้องทำไงอะครับ รบกวนด้วยครับ

โค๊ด:
<!DOCTYPE html>
<html lang="en" class="no-js">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Sticky Table Headers Revisited | Demo 2</title>
<meta name="description" content="Sticky Table Headers Revisited: Creating functional and flexible sticky table headers" />
<meta name="keywords" content="Sticky Table Headers Revisited" />
<meta name="author" content="Codrops" />
<link rel="shortcut icon" href="../favicon.ico">
<link rel="stylesheet" type="text/css" href="css/normalize.css" />
<link rel="stylesheet" type="text/css" href="css/demo.css" />
<link rel="stylesheet" type="text/css" href="css/component.css" />
<!--[if IE]>
  <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body>
<div class="container">

<div class="component">
<h2>ผลประเมิน</h2>

<table>
<thead>
<tr>
<th>Sample ID</th>
<th>Reading #1</th>
<th>Reading #2</th>
<th>Reading #3</th>
<th>Reading #4</th>
<th>Reading #5</th>
</tr>
</thead>

<tbody>
<?php for($i=1;$i<=5;$i  ){
echo "<tr>";
echo "<th>Sample #1</th>";
echo "<td>52</td>";
echo "<td>40</td>";
echo "<td>9</td>";
echo "<td>47</td>";
echo "<td>31</td>";
echo "</tr>";

 } ?>

</tbody>
</table>

</div>

</div><!-- /container -->


</body>
</html>


หัวข้อ: Re: มีเรื่องสงสัยกับการใช้ loop php ใน html ครับ
เริ่มหัวข้อโดย: i3ankboy ที่ 23 มีนาคม 2015, 21:29:20
โค๊ด:
<?php 
for($i=1;$i<=5;$i++ ){
?>

<table style="width:100%">
  <tr>
    <td>Jill</td>
    <td>Smith</td>
    <td>50</td>
  </tr>
  <tr>
    <td>Eve</td>
    <td>Jackson</td>
    <td>94</td>
  </tr>
</table>
<?
}
?>
ลองดูครับ


หัวข้อ: Re: มีเรื่องสงสัยกับการใช้ loop php ใน html ครับ
เริ่มหัวข้อโดย: Kz ที่ 23 มีนาคม 2015, 21:30:38
for($i=1;$i<=5;$i++) คุณลืม $i++ ครับ


หัวข้อ: Re: มีเรื่องสงสัยกับการใช้ loop php ใน html ครับ
เริ่มหัวข้อโดย: wristy032 ที่ 23 มีนาคม 2015, 21:39:44
โค๊ด:
<?php 
for($i=1;$i<=5;$i++ ){
?>

<table style="width:100%">
  <tr>
    <td>Jill</td>
    <td>Smith</td>
    <td>50</td>
  </tr>
  <tr>
    <td>Eve</td>
    <td>Jackson</td>
    <td>94</td>
  </tr>
</table>
<?
}
?>
ลองดูครับ


ลองละมันขึ้นแค่นี้อะครับ
(http://image.ohozaa.com/i/91b/r7plKw.jpg) (http://image.ohozaa.com/view2/yeJWImPns3rQE3QB)


หัวข้อ: Re: มีเรื่องสงสัยกับการใช้ loop php ใน html ครับ
เริ่มหัวข้อโดย: wristy032 ที่ 23 มีนาคม 2015, 21:40:27
for($i=1;$i<=5;$i++) คุณลืม $i++ ครับ

ผมกลับไปดูละครับ ในโค้ดผมผมใส่แล้ว แต่ตอนก็อปมาไมไม่ขึ้นก้งงอยู่ครับ แหะๆ


หัวข้อ: Re: มีเรื่องสงสัยกับการใช้ loop php ใน html ครับ
เริ่มหัวข้อโดย: Kz ที่ 23 มีนาคม 2015, 21:50:36
for($i=1;$i<=5;$i++) คุณลืม $i++ ครับ

ผมกลับไปดูละครับ ในโค้ดผมผมใส่แล้ว แต่ตอนก็อปมาไมไม่ขึ้นก้งงอยู่ครับ แหะๆ

มันเละยังไงหรอครับ มีภาพประกอบไหมครับ


หัวข้อ: Re: มีเรื่องสงสัยกับการใช้ loop php ใน html ครับ
เริ่มหัวข้อโดย: wristy032 ที่ 23 มีนาคม 2015, 21:56:36
for($i=1;$i<=5;$i++) คุณลืม $i++ ครับ


ผมกลับไปดูละครับ ในโค้ดผมผมใส่แล้ว แต่ตอนก็อปมาไมไม่ขึ้นก้งงอยู่ครับ แหะๆ


มันเละยังไงหรอครับ มีภาพประกอบไหมครับ


นี่อะครับ
(http://image.ohozaa.com/i/909/b89RGv.jpg) (http://image.ohozaa.com/view2/yeK2KInyTm1BVEyX)


หัวข้อ: Re: มีเรื่องสงสัยกับการใช้ loop php ใน html ครับ
เริ่มหัวข้อโดย: Kz ที่ 23 มีนาคม 2015, 21:59:50
for($i=1;$i<=5;$i++) คุณลืม $i++ ครับ


ผมกลับไปดูละครับ ในโค้ดผมผมใส่แล้ว แต่ตอนก็อปมาไมไม่ขึ้นก้งงอยู่ครับ แหะๆ


มันเละยังไงหรอครับ มีภาพประกอบไหมครับ


นี่อะครับ
([url]http://image.ohozaa.com/i/909/b89RGv.jpg[/url]) ([url]http://image.ohozaa.com/view2/yeK2KInyTm1BVEyX[/url])

ผมรันปกติครับ :P
(http://upic.me/i/fg/u4zzz.png) (http://upic.me/show/55026020)



หัวข้อ: Re: มีเรื่องสงสัยกับการใช้ loop php ใน html ครับ
เริ่มหัวข้อโดย: wristy032 ที่ 23 มีนาคม 2015, 22:04:34
for($i=1;$i<=5;$i++) คุณลืม $i++ ครับ


ผมกลับไปดูละครับ ในโค้ดผมผมใส่แล้ว แต่ตอนก็อปมาไมไม่ขึ้นก้งงอยู่ครับ แหะๆ


มันเละยังไงหรอครับ มีภาพประกอบไหมครับ


นี่อะครับ
([url]http://image.ohozaa.com/i/909/b89RGv.jpg[/url]) ([url]http://image.ohozaa.com/view2/yeK2KInyTm1BVEyX[/url])

ผมรันปกติครับ :P
([url]http://upic.me/i/fg/u4zzz.png[/url]) ([url]http://upic.me/show/55026020[/url])



ง่ะ งั้นอาจเป็นเพราะส่วนข้างบนมั้งครับ ยังไงก้ขอบคุณมากๆครับ :wanwan017:


หัวข้อ: Re: มีเรื่องสงสัยกับการใช้ loop php ใน html ครับ
เริ่มหัวข้อโดย: ohmakung ที่ 08 เมษายน 2015, 11:53:47
<table>
               <thead>
                  <tr>
                     <th>Sample ID</th>
                     <th>Reading #1</th>
                     <th>Reading #2</th>
                     <th>Reading #3</th>
                     <th>Reading #4</th>
                     <th>Reading #5</th>
                  </tr>
               </thead>
               
               <tbody>
               <?php for($i=1;$i<=5;$i++ ){ ?>
                  <tr>
                  <td>Sample #1</td>
                  <td>52</td>
                  <td>40</td>
                  <td>9</td>
                  <td>47</td>
                  <td>31</td>
                  </tr>
               <?php } ?>   
               </tbody>
            </table>