Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,030

HOME > PHP > PHP Forum > เราจะนำข้อมูลจากฐานข้อมูลมาโชว์ยังไงค่....รบกวนเซียน php ตอบด่วนค่ะ.....ขอบคุณค่ะ



 

เราจะนำข้อมูลจากฐานข้อมูลมาโชว์ยังไงค่....รบกวนเซียน php ตอบด่วนค่ะ.....ขอบคุณค่ะ

 



Topic : 022851

Guest




คือปัญหามีอยู่ว่า.......

ดิฉันทำบทเรียนโดยในบทเรียนสามารถเพิ่ม-ลบ-แก้ไขบทเรียนได้ค่ะ

แต่พอทำเสร็จแล้วดิฉันจะต้องนำข้อมูลในบทเรียนนั้นมาให้นักศึกษาเรียนในชั้นเรียนออนไลน์แต่ว่าดิฉันไม่รู้ว่าเวลาจะดึงเอาข้อมูลของแต่ละบทมานั้นต้องดึงอย่างไรและต้องสร้างฟอร์มแบบไหน

การที่จะให้เข้าไปเรียนทีละบทนั้น ก็ต้องมีหน้าหลักของนักศึกษาและในหน้าหลักก็ต้องมีบทเรียนแต่ละบทซึ่งดิฉันจะดึงเอาจากฐานข้อมูลที่ทำไว้นั้น ต้องทำอย่างไรค่ะ

รบกวนเซ๊ยนทั้งหลายช่วยแนะนำด่วนค่ะต้องใช้ด่วนค่ะ

ขอบคุณมากค่ะ


lessons.php...........อันนี้หน้าที่จะเข้าไปเพิ่มลบแก้ไข

<? session_start(); ?>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874">
</head>
<?
include("connect.php");
if(!session_is_registered("login_true")) {
// url=index.php คำสั่งนี้จะให้ไปหน้าที่จะต้องกรอก user,pwd ถ้าอยู่โฟล์เดอร์อื่นให้เรียกให้ถูก
echo"<br><br><br><br><br><br><center><img src='image/backlogin.gif'></center>";
echo "<meta http-equiv='refresh' content='5;url=index.php'>" ;
exit() ;
}

?>
<style>
a {font-size:12;color:#0000cc;}
a:link {color:#0000cc;text-decoration:none;}
a:hover {color:red;text-decoration:bold;}
a:visited {color:none;text-decoration:'none'}
</style>

<body>
<table width="97%" border="0" align="center" cellspacing="1" bgcolor="#666666">
<tr>
<td height="404" valign="top" bgcolor="#FFFFFF">
<div align="center"></div>
<div align="center">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" bordercolor="#FFFFFF" bgcolor="#FFFFFF">
<!--DWLayoutTable-->
<tr bgcolor="#FFFFFF">
<td width="766" >
<?php include'home.php'; ?>
</td>
</tr>
<tr valign="top" bgcolor="#FFFFFF">
<td ><!--DWLayoutEmptyCell-->&nbsp; </td>
</tr>
<tr>
<td height="364" colspan="2" valign="top" bgcolor="#FFFFFF"> <span class="style1"><span class="style10"><font color="#1D67F1" size="1" face="MS Sans Serif, Tahoma, sans-serif"><font color="#000000" size="2"><span class="style1"><font color="#4558AF" face="MS Sans Serif, Tahoma, sans-serif">
</font><span class="style10"><font color="#1D67F1" size="1" face="MS Sans Serif, Tahoma, sans-serif"><font color="#000000" size="2"><span class="style1"><font color="#4558AF" face="MS Sans Serif, Tahoma, sans-serif">
</font></span></font></font></span></span></font></font></span></span>
<table width="91%" border="0" align="center" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="15" height="13" valign="bottom"><img src="image/up-left2.jpg" width="15" height="13"></td>
<td width="9" valign="top" background="image/up3.gif">
<td width="666" valign="top" background="image/up3.gif">
<td width="7" valign="top" background="image/up3.gif">
<td width="15" valign="bottom"><img src="image/up-right2.jpg" width="15" height="13"></td>
</tr>
<tr>
<td height="273" background="image/left2.jpg">&nbsp;</td>
<td>&nbsp;</td>
<td valign="top"><div align="center">
<p><font size="2" face="MS Sans Serif, Tahoma, sans-serif"><img src="image/administrator1.gif" width="220" height="165"></font></p>
<p>
<table width="750" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#99CCFF">
<tr bgcolor="#d6dff7">
<td width="67" height="21"><div align="center"><font color="#0000FF" size="2" face="MS Sans Serif, Tahoma, sans-serif"><strong><font color="#0099FF">&nbsp;&nbsp;บทท</font></strong>ี่</font></div></td>
<td width="452" height="21"><div align="center"><font color="#0099FF" size="2" face="MS Sans Serif, Tahoma, sans-serif"><strong>ชื่อบทเรียน</strong></font></div></td>
<td width="167"><div align="center"><font color="#0099FF" size="2" face="MS Sans Serif, Tahoma, sans-serif"><strong>&nbsp;บทเรียน</strong></font></div></td>
</tr>
<?php
$sql="SELECT lesson_id,lesson_name FROM lesson;";
mysql_query("set charset tis620");
$result=mysql_query($sql);
if($result){
while($lesson_arr=mysql_fetch_array($result)){
?>
<tr>
<td height="26"><div align="center"><font size="2" face="MS Sans Serif, Tahoma, sans-serif"><?php echo $lesson_arr[0] ?></font></div></td>
<td><div align="left"><font size="2" face="MS Sans Serif, Tahoma, sans-serif">&nbsp;
&nbsp; <?php echo $lesson_arr[1] ?></font></div></td>
<td><div align="center"><a href="lesson_edit.php?lesson_id=<?php echo $lesson_arr[0]; ?>%0A%09%09%09%09%09%09%09%09%09%09%09%09%09d%22sson_name=<?php echo $lesson_arr[1];
$name_lee="lesson_id"?>">
<font color="blue" size="2" face="MS Sans Serif, Tahoma, sans-serif">บทเรียนบทที่<?php echo $lesson_arr[0]; ?></font></a></div></td>
</tr>
<?php
}//end while
}else{
echo "ไม่สามารถแสดงข้อมูลได้"."<br>\n";
}
?>
</table>
<br></p>
</div></td>
<td>&nbsp;</td>
<td background="image/right2.jpg">&nbsp;</td>
</tr>
<tr>
<td height="20" background="image/left2.jpg">&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td background="image/right2.jpg">&nbsp;</td>
</tr>
<tr>
<td height="20" background="image/left2.jpg">&nbsp;</td>
<td>&nbsp;</td>
<td valign="top"><div align="center"><br>
<font size="2" face="MS Sans Serif, Tahoma, sans-serif">
</font></div></td>
<td>&nbsp;</td>
<td background="image/right2.jpg">&nbsp;</td>
</tr>
<tr>
<td height="20" valign="top"><img src="image/down-left3.jpg" width="15" height="11"></td>
<td background="image/down.gif">&nbsp; </td>
<td background="image/down.gif">&nbsp;</td>
<td background="image/down.gif">&nbsp;</td>
<td valign="top"><img src="image/down-right3.jpg" width="15" height="11"></td>
</tr>
</table>
<?php include'line_index.php'; ?>
</td>
</tr>
</table>
</div></td>
</tr>
</table>
</body>
</html>



อันนี้หน้าแก้ไข lesson_edit.php

<? session_start();?>
<html>
<head>
<title>ผู้ดูแลระบบ</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874">
<style type="text/css">
<!--
.style1 {font-weight: bold}
-->
</style>
</head>
<? include("connect.php");
if(!session_is_registered("login_true")) {
// url=index.php คำสั่งนี้จะให้ไปหน้าที่จะต้องกรอก user,pwd ถ้าอยู่โฟล์เดอร์อื่นให้เรียกให้ถูก
echo"<br><br><br><br><br><br><center><img src='image/backlogin.gif'></center>";
echo "<meta http-equiv='refresh' content='5;url=index.php'>" ;
exit() ; }?>
<?php session_start();
session_register("name_l");//เก็บชื่อเรื่องเอาไว้แสดงเวลาปรับปรุง
session_register("lesson_edit"); //เก็บบทที่
include("connect.php");
?>
<style>
a {font-size:12;color:#0000cc;}
a:link {color:#0000cc;text-decoration:none;}
a:hover {color:red;text-decoration:bold;}
a:visited {color:none;text-decoration:'none'}
</style>
<body >
<div align="left">
<table width="100%" border="0" align="center" cellspacing="1" bgcolor="#666666">
<tr>
<td height="257" valign="top" bgcolor="#FFFFFF"><div align="center"></div>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" bordercolor="#FFFFFF" bgcolor="#FFFFFF">
<tr bgcolor="#FFFFFF">
<td>
<?php include'menubar.php'; ?>
</td>
</tr>
<tr valign="top" bgcolor="#FFFFFF">
<td>&nbsp; </td>
</tr>
<tr>
<td height="201" valign="top" bgcolor="#FFFFFF"> <span class="style1"><span class="style10"><font color="#1D67F1" size="1" face="MS Sans Serif, Tahoma, sans-serif"><font color="#000000" size="2"><span class="style1"><font color="#4558AF" face="MS Sans Serif, Tahoma, sans-serif">
</font><span class="style10"><font color="#1D67F1" size="1" face="MS Sans Serif, Tahoma, sans-serif"><font color="#000000" size="2"><span class="style1"><font color="#4558AF" face="MS Sans Serif, Tahoma, sans-serif">
</font></span></font></font></span></span></font></font></span></span>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="1%" valign="bottom"><img src="image/up-left2.jpg" width="15" height="13"></td>
<td width="97%" valign="top" background="image/up3.gif">
<td width="2%" valign="bottom"><img src="image/up-right2.jpg" width="15" height="13"></td>
</tr>
<tr>
<td height="168" background="image/left2.jpg">&nbsp;</td>
<td valign="top" bgcolor="#FFFFFF"><div align="center">
<p><font size="2" face="MS Sans Serif, Tahoma, sans-serif"><img src="image/administrator1.gif" width="220" height="165"></font></p>
<p>
<?php
$lesson_edit="$lesson_id";

$result1 = mysql_query("select * from lesson where lesson_id ='$lesson_edit'") or die ("Err Can not to result") ;
$rs = mysql_fetch_array($result1) ;
$name_l=$rs['lesson_name'];

echo "<center><font size='2' face='MS Sans Serif' ><font color=#0000FF><B>ปรับปรุงบทเรียน เรื่อง</B></font>";echo "<B><font color=#FF0000> $name_l </B></font>"; echo"<br><br>"; echo" </center></font>";
//$result = mysql_query("SELECT no,id, q,question FROM quiz where q='$lesson' ");
$result = mysql_query("SELECT * FROM lessons where lesson_id='$lesson_id' ");
//$rs = mysql_fetch_array($result);
$qpall = $rs['title']; // ตัดคำ
$newtext = wordwrap($qpall,20,"<\n>",1);

$i = 0;

echo "<table >";
echo"<tr bgcolor='#FF582F'> <td width='10%'><center><font color=#FFFFFF size='2' face='MS Sans Serif'>บทที่</center></font ></td>
<td width='30%'><center><font color=#FFFFFF size='2' face='MS Sans Serif'>หัวเรื่อง</center></font ></td>
<td width='15%'><center><font color=#FFFFFF size='2' face='MS Sans Serif'>เนื้อเรื่อง</center></font ></td>
<td width='15%'><center><font color=#FFFFFF size='2' face='MS Sans Serif'>เนื้อหา</center></font ></td>
<td width='15%'><center><font color=#FFFFFF size='2' face='MS Sans Serif'>รายละเอียด</center></font></td>
<td width='15%'><center><font color=#FFFFFF size='2' face='MS Sans Serif'>รายละเอียด</center></font></td> <td><center><font color=#FFFFFF size='2' face='MS Sans Serif'>แก้ไข</center></font></td>
<td><center><font color=#FFFFFF size='2' face='MS Sans Serif'>ลบ</center></font></td>";
while ($row = mysql_fetch_array($result))
{

$no = $row["no"];
$id=$row["id"];
$lesson_id=$row["lesson_id"];
$title = $row["title"];
// $qpall = $row["question"]; // ตัดคำ
// $newtext = wordwrap($qpall,100,"<\n>",1);
$title2 = $row["title2"];
$dripcription = $row["dripcription"];
$dripcription2 = $row["dripcription2"];
$dripcription3 = $row["dripcription3"];

$i++;
if ($alternate == "1") {
$color = "#ffffff";
$alternate = "2";
}
else {
$color = "#efefef";
$alternate = "1";
}
echo "<tr bgcolor=$color>
<td width='10%'><center><font size='2' face='MS Sans Serif'>$i</center></font ></td>
<td width='30%'><font size='2' face='MS Sans Serif'>$title</font ></td>
<td width='15%'><font size='2' face='MS Sans Serif'>$title2</font ></td>
<td width='15%'><font size='2' face='MS Sans Serif'>$dripcription</font ></td>
<td width='15%'><font size='2' face='MS Sans Serif'>$dripcription2</font ></td>
<td width='15%'><font size='2' face='MS Sans Serif'>$dripcription3</font ></td>
<td width='10%'><font size='2' face='MS Sans Serif'> &nbsp; <a href='edit_lesson.php?hid_no=$no'><img src='image/icon_edit.gif' width='24' height='17' border='0'></a>&nbsp; </font ></td>
<td width='10%'><font size='2' face='MS Sans Serif'> &nbsp; <a href='deletelesson.php?no=$no' onClick=\"return confirm('คุณแน่ใจแล้วหรือค่ะ ว่าจะลบบทเรียนนี้ ?')\"><img src='image/delete1.gif' width='21' height='20' border='0'></a> </font ></td></tr>";
}
echo "</table>";
?>
<div align="center"> <br>
<a href="lesson_add.php"><font size="2" face="MS Sans Serif, Tahoma, sans-serif"><strong>
</strong></font></a>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="48%"><div align="center"><font size="2" face="MS Sans Serif, Tahoma, sans-serif"><a href="lessons.php"><font size="2" face="MS Sans Serif, Tahoma, sans-serif"><strong><img src="image/less5.2_clip_image004.gif"></strong></font></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="lesson_add.php"><img src="image/contact.gif" width="43" height="47" border="0">&nbsp;&nbsp;&nbsp;&nbsp;<strong><font size="2" face="MS Sans Serif, Tahoma, sans-serif">เพิ่มบทเรียน</font></strong></a></div></td>
</tr>
</table>
</div>
<div align="center">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="48%">&nbsp;</td>
<td width="52%">&nbsp;</td>
</tr>
</table>
</div>
<br>
</div></td>
<td background="image/right2.jpg">&nbsp;</td>
</tr>
<tr>
<td height="20" valign="top"><img src="image/down-left3.jpg" width="15" height="11"></td>
<td background="image/down.gif">&nbsp;</td>
<td valign="top"><img src="image/down-right3.jpg" width="15" height="11"></td>
</tr>
</table></td>
</tr>
<tr bordercolor="#FFFFFF" bgcolor="#FFFFFF">
<td height="37" valign="top">
<p>
<?php include'line_index.php'; ?>
</p></td>
</tr>
</table></td>
</tr>
</table>
</div>
</body>
</HTML>

อันนี้หน้าเพิ่ม lesson_add.php
<? session_start();
session_register("n1");//เก็บค่าข้อต่อไป
?>

<style>
a {font-size:15;color:#0033FF;}
a:link {color:#0000cc;text-decoration:none;}
a:hover {color:red;text-decoration:bold;}
a:visited {color:none;text-decoration:'none'}
</style>
<title>ผู้ดูแลระบบ</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874">
<table width="100%" border="0" align="center" cellspacing="1" bgcolor="#666666">
<tr>
<td height="257" valign="top" bgcolor="#FFFFFF"><div align="center"></div>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" bordercolor="#FFFFFF" bgcolor="#FFFFFF">
<tr bgcolor="#FFFFFF">
<td>
<?php include'menubar.php'; ?>
</td>
</tr>
<tr valign="top" bgcolor="#FFFFFF">
<td>&nbsp; </td>
</tr>
<tr>
<td height="201" valign="top" bgcolor="#FFFFFF"> <span class="style1"><span class="style10"><font color="#1D67F1" size="1" face="MS Sans Serif, Tahoma, sans-serif"><font color="#000000" size="2"><span class="style1"><font color="#4558AF" face="MS Sans Serif, Tahoma, sans-serif">
</font><span class="style10"><font color="#1D67F1" size="1" face="MS Sans Serif, Tahoma, sans-serif"><font color="#000000" size="2"><span class="style1"><font color="#4558AF" face="MS Sans Serif, Tahoma, sans-serif">
</font></span></font></font></span></span></font></font></span></span>
<table width="63%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="1%" valign="bottom"><img src="image/up-left2.jpg" width="15" height="13"></td>
<td width="97%" valign="top" background="image/up3.gif">
<td width="2%" valign="bottom"><img src="image/up-right2.jpg" width="15" height="13"></td>
</tr>
<tr>
<td height="168" background="image/left2.jpg">&nbsp;</td>
<td valign="top" bgcolor="#FFFFFF"><div align="center">
<table width="700" height="100%" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#66CCFF" bgcolor="#FFFFFF">
<tr>
<td align="center" valign="top"><p align="center"><strong><font color="#0000CC" size="3" face="MS Sans Serif">
<br></font><font size="2" face="MS Sans Serif, Tahoma, sans-serif"><img src="image/administrator1.gif" width="220" height="165" /></font></strong>
<?php
include("connect.php");

$sql_query = "SELECT MAX(id) as MAXID FROM lessons where lesson_id='$lesson_edit'"; //อันนี้ใช้ random ทั้งหมดจากฐานข้อมูลใช้ในแบบทดสอบรวม
$result = mysql_db_query($dbname,$sql_query);

// echo $num_row;
$num_id=$rs['MAXID'];
$n1=$num_id+1;
//echo $n1;


if($submit) //เพิ่ม
{
// $pall =htmlspecialchars($question);
$pall =addslashes($title);//แปลงอักขระ
$palltitle2 =addslashes($title2);
$palldripcription =addslashes($dripcription);
$palldripcription2 =addslashes($dripcription2);
$palldripcription3 =addslashes($dripcription3);

$sql = "INSERT INTO lessons (lesson_id,title, title2, dripcription, dripcription2,dripcription3) VALUES ('$lesson_edit','$pall','$palltitle2','$palldripcription','$palldripcription2','$palldripcription3')";

$result = mysql_query($sql);
//echo "<b><font face='ms sans serif' size='3' color='#FF0099'><br><br><br><br>ขณะนี้ระบบได้ทำการเพิ่มแบบทดสอบเรียบร้อยแล้วค่ะ<br>รอสักครู่เพื่อกลับหน้าจัดการแบบทดสอบ<br>\n</font></b>";
echo "<meta http-equiv='refresh' content='0;url=lesson_edit.php?lesson_id=$lesson_edit'>" ;
// $rs = mysql_fetch_row($result) ;
// $new_id=$rs['id'];
//echo "<br><br>Question added to quiz.<br><br>";
//include "qinsert.php";
}
else if($update) //แก้ไข
{
$pall =addslashes($title);
$palltitle2 =addslashes($title2);
$palldripcription =addslashes($dripcription);
$palldripcription2 =addslashes($dripcription2);
$palldripcription3 =addslashes($dripcription3);
$sql = "UPDATE lessons SET lesson_id='$lesson_edit',title='$pall',title2='$palltitle2',dripcription='$palldripcription',dripcription2='$palldripcription2',dripcription3='$palldripcription3' WHERE no='$no'";
$result = mysql_query($sql);
//echo "<b><font face='ms sans serif' size='3' color='#FF0099'><br><br><br><br>ขณะนี้ระบบได้ทำการปรับปรุงแบบทดสอบเรียบร้อยแล้วค่ะ<br>รอสักครู่เพื่อกลัหน้าจัดการแบบทดสอบ<br>\n</font></b>";
echo "<meta http-equiv='refresh' content='0;url=lesson.editphp'>" ;
}
else if($no)
{
$result = mysql_query("SELECT * FROM lessons WHERE no='$no'");
$myrow = mysql_fetch_array($result);
?>
<!-- แก้ไข -->
</p>
<form name ="checkForm1" method="post" action="<?php echo $PHP_SELF?>" onSubmit="return check()">
<table width="86%" border="0" align="center" cellpadding="0" cellspacing="2">
<tr>
<td height="21"> <div align="left"><br>
</div></td>
<td><div align="center"><font color="#FF9933"><font color="#000000" size="3" face="MS Sans Serif, Tahoma, sans-serif"><strong><font color="#0033FF">เรื่อง</font><font color="#006600">&nbsp;</font></strong></font>
</font><font color="#0033FF" size="3" face="MS Sans Serif, Tahoma, sans-serif"><strong><? echo $name_l;?></strong></font>
</div></td>
</tr>
<tr bgcolor="#FFFFFF">
<td width="23%" height="73"><div align="right"><font color="#009900"><strong><font color="#0033FF" size="2" face="MS Sans Serif, Tahoma, sans-serif">หัวเรื่อง&nbsp;&nbsp;</font></strong></font></div></td>
<td width="77%"><div align="left"><font color="#009900"><strong><font size="2" face="MS Sans Serif, Tahoma, sans-serif">
<textarea name="title" rows="4" cols ="50" wrap="on"><?=$myrow['title']?></textarea>
<!-- <input type="Text" name="question" ROWS="4" value="<?php echo $myrow["title"]?>" size="50"> -->
</font></strong></font></div></td>
</tr>
<tr bgcolor="#FFFFFF">
<td><div align="right"><font color="#009900"><strong><font color="#0033FF" size="2" face="MS Sans Serif, Tahoma, sans-serif">เนื้อเรื่อง&nbsp;&nbsp;</font></strong></font></div></td>
<td><div align="left"><font color="#009900"><strong><font size="2" face="MS Sans Serif, Tahoma, sans-serif">
<textarea name="title2" rows="2" cols ="50" wrap="on"><?echo $myrow["title2"]?></textarea>
<!-- <input type="Text" name="opt1" value="<?php echo $myrow["title2"]?>" size="30"> -->
</font></strong></font></div></td></tr>
<tr bgcolor="#FFFFFF">
<td><div align="right"><font color="#009900"><strong><font color="#0033FF" size="2" face="MS Sans Serif, Tahoma, sans-serif">เนื้อหา&nbsp;&nbsp;</font></strong></font></div></td>
<td><div align="left"><font color="#009900"><strong><font size="2" face="MS Sans Serif, Tahoma, sans-serif">
<textarea name="dripcription" rows="2" cols ="50" wrap="on"><?echo $myrow["dripcription"]?></textarea>
<!-- <input type="Text" name="opt2" value="<?php echo $myrow["dripcription"]?>" size="30"> -->
</font></strong></font></div></td></tr>
<tr bgcolor="#FFFFFF">
<td><div align="right"><font color="#009900"><strong><font color="#0033FF" size="2" face="MS Sans Serif, Tahoma, sans-serif">รายละเอียด&nbsp;&nbsp;</font></strong></font></div></td>
<td><div align="left"><font color="#009900"><strong><font size="2" face="MS Sans Serif, Tahoma, sans-serif">
<textarea name="dripcription2" rows="2" cols ="50" wrap="on"><?echo $myrow["dripcription2"]?></textarea>
<!-- <input type="Text" name="opt3" value="<?php echo $myrow["dripcription2"]?>" size="30"> -->
</font></strong></font></div></td></tr>
<tr bgcolor="#FFFFFF">
<td><div align="right"><font color="#009900"><strong><font color="#0033FF" size="2" face="MS Sans Serif, Tahoma, sans-serif">รายละเอียด&nbsp;&nbsp;</font></strong></font></div></td>
<td><div align="left"><font color="#009900"><strong><font size="2" face="MS Sans Serif, Tahoma, sans-serif">
<textarea name="dripcription3" rows="2" cols ="50" wrap="on"><?echo $myrow["dripcription3"]?></textarea>
<!-- <input type ="text" name="opt4" value="<? echo$myrow["dripcription3"]?>" size="30"> -->
</font></strong></font></div></td></tr>
<tr bgcolor="#FFFFFF">
<td height="20"><div align="right"><font color="#009900"><strong><font size="2" face="MS Sans Serif, Tahoma, sans-serif"><font color="#0033FF">&nbsp;</font></font>
</strong></font></div></td>
<td height="20"><div align="center"><font color="#009900"><strong><font size="2" face="MS Sans Serif, Tahoma, sans-serif">&nbsp;<font color="#0033FF">
</font> &nbsp; <font color="#0033FF">&nbsp;</font></font></strong></font></div></td>
</tr>
<tr>
<td colspan="2"><div align="center">
<input type="Submit" name="update" value=" ตกลง ">
<script language="javascript">

function check() {
if(document.checkForm1.title.value=="") {
alert("กรุณากรอก หัวเรื่องด้วยค่ะ") ;
document.checkForm1.title.focus() ;
return false ;
}
else if(document.checkForm1.title2.value=="") {
alert("กรุณากรอก เนื้อเรื่องด้วยค่ะ") ;
document.checkForm1.title2.focus() ;
return false ;
}
else if(document.checkForm1.dripcription.value=="") {
alert("กรุณากรอก เนื้อหาด้วยค่ะ") ;
document.checkForm1.dripcription.focus() ;
return false ;
}
else if(document.checkForm1.dripcription2.value=="") {
alert("กรุณากรอก รายละเอียดด้วยค่ะ") ;
document.checkForm1.dripcription2.focus() ;
return false ;
}else if(document.checkForm1.dripcription3.value=="") {
alert("กรุณากรอก รายละเอียดด้วยค่ะ") ;
document.checkForm1.dripcription3.focus() ;
return false ;
}
else
return true ;
}
</script>
</div></td>
</tr>
</table>
</form>
<!-- <input type="Submit" name="update" value="Update information"></form> -->
<?

}
else //เพิ่ม
{
?>
<!-- เพิ่ม -->
<div align="center"></div>
<form name ="checkForm" method="post" action="<?php echo $PHP_SELF?>" onSubmit="return check()">
<table width="86%" border="0" align="center" cellpadding="0" cellspacing="2">
<tr>
<td colspan="2"><strong><font color="#0033FF" size="3" face="MS Sans Serif, Tahoma, sans-serif">เรื่อง&nbsp;
</font></strong> <font color="#0033FF" size="3" face="MS Sans Serif, Tahoma, sans-serif"><strong>
<?echo $name_l;?> </strong></font><font color="#000000" size="3" face="MS Sans Serif, Tahoma, sans-serif"><strong><br>
</strong></font> </td>
</tr>
<tr bgcolor="#FFFFFF">
<td width="23%"><div align="right"><strong><font color="#0033FF" size="2" face="MS Sans Serif, Tahoma, sans-serif">หัวเรื่อง&nbsp;&nbsp;</font></strong></div></td>
<td width="77%"> <div align="left"><font color="#009900">
<textarea name="title" rows="4" cols ="50" wrap="on"><?=$myrow['title']?></textarea>
<!-- <input type="Text" name="question" size="50"> -->
</font></div></td>
</tr>
<tr bgcolor="#FFFFFF">
<td><div align="right"><strong><font color="#0033FF" size="2" face="MS Sans Serif, Tahoma, sans-serif">เนื้อเรื่อง&nbsp;&nbsp;</font></strong></div></td>
<td> <div align="left"><font color="#009900">
<textarea name="title2" rows="2" cols ="50" size="70" wrap="on"><?echo $myrow["title2"]?></textarea>
<!-- <input type="Text" name="opt1" size="30"> -->
</font></div></td></tr>
<tr bgcolor="#FFFFFF">
<td><div align="right"><strong><font color="#0033FF" size="2" face="MS Sans Serif, Tahoma, sans-serif">เนื้อหา&nbsp;&nbsp;</font></strong></div></td>
<td> <div align="left"><font color="#009900">
<textarea name="dripcription" rows="2" cols ="50" size="70" wrap="on"><?echo $myrow["dripcription"]?></textarea>
<!-- <input type="Text" name="opt2" size="30"> -->
</font></div></td></tr>
<tr bgcolor="#FFFFFF">
<td><div align="right"><strong><font color="#0033FF" size="2" face="MS Sans Serif, Tahoma, sans-serif">รายละเอียด&nbsp;&nbsp;</font></strong></div></td>
<td> <div align="left"><font color="#009900">
<textarea name="dripcription2" rows="2" cols ="50" size="70" wrap="on"><?echo $myrow["dripcription2"]?></textarea>
<!-- <input type="Text" name="opt3" size="30"> -->
</font>
<tr bgcolor="#FFFFFF">
<td><div align="right"><strong><font color="#0033FF" size="2" face="MS Sans Serif, Tahoma, sans-serif">รายละเอียด&nbsp;&nbsp;</font></strong></div></td>
<td> <div align="left"><font color="#009900">
<textarea name="dripcription3" rows="2" cols ="50" size="70" wrap="on"><?echo $myrow["dripcription3"]?></textarea>
<!-- <input type="Text" name="opt4" size="30"> -->
</font>
<tr valign="top" bgcolor="#FFFFFF">
<td height="21"><div align="right"><font color="#009900" size="2" face="MS Sans Serif, Tahoma, sans-serif"><strong></strong></font><font color="#0033FF" size="2" face="MS Sans Serif"><strong><font face="MS Sans Serif, Tahoma, sans-serif">&nbsp;</font></strong></font></div></td>
<td height="21"><div align="center"><font color="#009900" size="2" face="MS Sans Serif"><strong>
&nbsp;&nbsp; &nbsp; </strong></font></div></td>
</tr>
<tr>
<td colspan="2"><div align="center">
<input name="submit" type="Submit" value=" ตกลง " >
<script language="javascript">

function check() {
if(document.checkForm.title.value=="") {
alert("กรุณากรอก หัวเรื่องด้วยค่ะ") ;
document.checkForm.title.focus() ;
return false ;
}
else if(document.checkForm.title2.value=="") {
alert("กรุณากรอก เนื้อเืรื่องด้วยค่ะ") ;
document.checkForm.title2.focus() ;
return false ;
}
else if(document.checkForm.dripcription.value=="") {
alert("กรุณากรอก เนื้อหาด้วยค่ะ") ;
document.checkForm.dripcription.focus() ;
return false ;
}
else if(document.checkForm.dripcription2.value=="") {
alert("กรุณากรอกต รายละเอียดด้วยค่ะ") ;
document.checkForm.dripcription2.focus() ;
return false ;
}else if(document.checkForm.dripcription3.value=="") {
alert("กรุณากรอก รายละเอียดด้วยค่ะ") ;
document.checkForm.dripcription3.focus() ;
return false ;
}
else
return true ;
}
</script>
</div></td>
</tr>
</table>
</form>
<font color="#0000CC" size="3" face="MS Sans Serif, Tahoma, sans-serif"><strong>
</strong></font> <table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="41%"><div align="right"><font color="#0000CC" size="3" face="MS Sans Serif, Tahoma, sans-serif"><strong>
<?
}// echo $sql;
?>
<!-- <a href="editquizlist.php">ดูข้อสอบทั้งหมด</a> -->
</strong><a href="lesson_edit.php?$lesson_arr[0]"></a></font><font color="#0000FF" size="2" face="MS Sans Serif, Tahoma, sans-serif">&nbsp;
</font><font size="2" face="MS Sans Serif, Tahoma, sans-serif"></font><font color="#0000FF" size="2" face="MS Sans Serif, Tahoma, sans-serif"><a href="lesson_edit.php"><strong></strong></a>&nbsp;</font></div></td>
<td width="59%">&nbsp;</td>
</tr>
</table>

<font color="#0000FF" size="2" face="MS Sans Serif, Tahoma, sans-serif"><a href="lesson_edit.php?$lesson_id=$id"><br>
</a></font> </td>
</tr>
</table>
<p> </div></td>
<td background="image/right2.jpg">&nbsp;</td>
</tr>
<tr>
<td height="20" valign="top"><img src="image/down-left3.jpg" width="15" height="11"></td>
<td background="image/down.gif">&nbsp;</td>
<td valign="top"><img src="image/down-right3.jpg" width="15" height="11"></td>
</tr>
</table></td>
</tr>
<tr bordercolor="#FFFFFF" bgcolor="#FFFFFF">
<td height="18" valign="top"> <p>
<?php include'line_index.php'; ?>
</p></td>
</tr>
</table></td>
</tr>
</table>
</body>
</HTML>

ในฐานข้อมูลมีตารางดังนี้ค่ะ

-- phpMyAdmin SQL Dump
-- version 2.10.2
-- http://www.phpmyadmin.net
--
-- โฮสต์: localhost
-- เวลาในการสร้าง: 03 พ.ย. 2008 น.
-- รุ่นของเซิร์ฟเวอร์: 5.0.45
-- รุ่นของ PHP: 5.2.3

SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";

--
-- ฐานข้อมูล: `db_comm`
--

-- --------------------------------------------------------

--
-- โครงสร้างตาราง `lessons`
--

CREATE TABLE `lessons` (
`no` int(11) NOT NULL auto_increment,
`lesson_id` int(3) NOT NULL default '0',
`title` text NOT NULL,
`title2` text NOT NULL,
`dripcription` text NOT NULL,
`dripcription2` text NOT NULL,
`dripcription3` text NOT NULL,
PRIMARY KEY (`no`)
) ENGINE=MyISAM DEFAULT CHARSET=tis620 AUTO_INCREMENT=160 ;

ซึ่งพอทำเสร็จก็สามารถเพิ่มลบแก้ไขได้ แต่ว่าจะเอาข้อมูลมาใช้ต้องทำยังไงค่ะ ช่วยด้วยค่ะทุกคน


ขอบคุณล่วงหน้าค่ะ


ก้อย















































Tag : - - - -







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 3 พ.ย. 2551 17:23:40 By : ก้อย View : 1214 Reply : 1
 

 

No. 1



โพสกระทู้ ( 3,468 )
บทความ ( 0 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter

ผมก็ไม่ค่อยเข้าใจคำถามนะครับ

สามารถ เพิ่ม ลบ แก้ไข ได้ แต่ไม่สามารถเอาข้อมูลมาใช้ได้?

เวลาดึงข้อมูลก็ select from where นะครับ --น่าจะถูกนะ

แล้วฟีล no นี่คืออะไรครับ แล้ว lession_id ล่ะ
แล้ว dripcription แปลว่าอะไร

ถ้าตอบไม่ถูกขออภัยด้วย

แสดงหัวข้อ

$query = mysql_query("SELECT * FROM lessions");

while( $result = mysql_fetch_array($query) )
echo 'บทเรียน <a href=show.php?no="', $result['no'], '">', $result['title'], '</a><br>';

//หน้า show.php ก็แสดงข้อมูล
$query = mysql_query("SELECT * FROM lessions WHERE no=$no");
$result = mysql_fetch_array($query);

echo $result['dripcription'], '<br><br>';
echo $result['dripcription2'], '<br><br>';
echo $result['dripcription3'], '<br><br>';


ผมว่าน่าจะประมาณนี้


http://gunner.freetzi.com






Date : 3 พ.ย. 2551 21:58:23 By : เอี่ยว
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : เราจะนำข้อมูลจากฐานข้อมูลมาโชว์ยังไงค่....รบกวนเซียน php ตอบด่วนค่ะ.....ขอบคุณค่ะ
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 03
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่