ขอถามเรื่องการทำ spry menu bar โดยดึงข้อมูลจาก Mysql
คือ ผมต้องการที่จะทำเมนูโดยทำการดึงข้อมูลมาจาก DB เพื่อเป็นหัวข้อของเมนูย่อย เช่น เดลินวส์ ประกอบด้วย การเมือง กีฬา อื่นๆๆ ไทยรัฐ ประกอบด้วยประเภทข่าว หลายๆๆ อย่าง เป็นต้น คือ ว่าแต่ละสำนักอาจมีประเภทข่าวที่ไม่เหมือนกัน ก็เลยทำการดึงข้อมูลจาก DB มมาทำเป็นเมนู
ฐานข้อมูลประกอบ ด้วย
1. สำนักข่าว เก็บสำนักข่าว
2. ตารางเก็บ URL ประเภทข่าว
3. ตารางเก็บประเภทของสำนักข่าวทุกสำนัก
ทั้ง 3 ตารางมีความสัมพันธ์กัน
สำนักข่าว 1 สำนัก มีหลายประเภทข่าว
ตัวอย่างนะครับ
เดลินิวส์
-การเมือง
-กีฬา
ไทยรัฐ
-อาชญกรรม
แบบนี้อะครับขอความช่วยเหลือด้วยครับ
ขอถามเรื่องการทำ spry menu bar โดยดึงข้อมูลจาก Mysql
Moderator: mindphp, ผู้ดูแลกระดาน
-
- PHP Full Member
- โพสต์: 48
- ลงทะเบียนเมื่อ: 05/02/2009 5:06 pm
-
- PHP Newbie
- โพสต์: 8
- ลงทะเบียนเมื่อ: 05/02/2009 11:19 pm
Re: ขอถามเรื่องการทำ spry menu bar โดยดึงข้อมูลจาก Mysql
spry menu คืออะไร หว่า อยากรู้ด้วยคน
-
- PHP Full Member
- โพสต์: 48
- ลงทะเบียนเมื่อ: 05/02/2009 5:06 pm
Re: ขอถามเรื่องการทำ spry menu bar โดยดึงข้อมูลจาก Mysql
ที่มีเครื่องมืออยู่ใน dw cs3 อะครับ
-
- PHP Full Member
- โพสต์: 48
- ลงทะเบียนเมื่อ: 05/02/2009 5:06 pm
Re: ขอถามเรื่องการทำ spry menu bar โดยดึงข้อมูลจาก Mysql
ผู้รู้มาตอบที
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=tis620" />
<title>RSS NEWS by CPE12</title>
<script src="file:///C|/AppServ/www/propage/SpryAssets/SpryMenuBar.js" type="text/javascript"></script>
<link href="file:///C|/AppServ/www/propage/SpryAssets/SpryMenuBarVertical.css" rel="stylesheet" type="text/css" />
<script src="file:///C|/AppServ/www/propage/Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
</head>
<body>
<table width="100%" border="0">
<tr>
<th colspan="3" scope="col"> </th>
</tr>
<tr>
<td> </td>
<td valign="top"><form id="form1" name="form1" method="post" action="">
¤é¹ËÒ¢èÒÇ
<label>
<input type="text" name="textfield" id="textfield" />
</label>
<label>
<select name="select" id="select">
<option>¡ÒÃàÁ×ͧ</option>
<option>àÈÃÉ°¡Ô¨</option>
<option>µèÒ§»ÃÐà·È</option>
<option>ÍÒªÒ¡ÃÃÁ</option>
<option>¡ÕÌÒ</option>
<option>ºÑ¹à·Ô§</option>
</select>
</label>
<label>
<select name="select2" id="select2">
<option>1 Çѹ</option>
<option>2 Çѹ</option>
<option>3 Çѹ</option>
<option>4 Çѹ</option>
<option>5 Çѹ</option>
<option>6 Çѹ</option>
<option>7 Çѹ</option>
</select>
</label>
</form> </td>
<td> </td>
</tr>
<tr>
<td width="27%">
<ul id="MenuBar1" class="MenuBarVertical">
<?php
define("DB_SERVER", "127.0.0.1"); // database server
define("USERNAME", "root"); // username
define("PASSWORD", "1234"); // no password
define("CURRENT_DB", "dbrss"); // current database
$db = mysql_pconnect( DB_SERVER, USERNAME, PASSWORD);
mysql_query("SET NAMES TIS620");
$sql="SELECT r_name, r_url FROM t_residence";
$result_show = mysql_db_query(CURRENT_DB, $sql);
if($result_show) {
while($rows = mysql_fetch_array($result_show)){
$link_name = $rows['r_name'];
$link_url = $rows['r_url'];
echo "<li><a class=\"MenuBarItemSubmenu\"href=\"$link_url\">$link_name</a>";
echo "<ul>";
$sql_show="SELECT chanel_name, chanel_url FROM t_chanel WHERE r_id = '$result_show(r_id)'";
$result = mysql_db_query(CURRENT_DB, $sql_show);
if($result) {
while($rows1 = mysql_fetch_array($result)){
$link1_name = $rows1['chanel_name'];
$link1_url = $rows1['chanel_url'];
$link1_rid = $row1['r_id'];
echo "<li><a href=\"$link1_url\">$link1_name</a></li>";
}
}
echo "</ul>";
}
}
?>
</ul> </td>
<td width="66%" valign="top"><p> </p></td>
<td width="7%"> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
<script type="text/javascript">
<!--
var MenuBar1 = new Spry.Widget.MenuBar("MenuBar1", {imgRight:"SpryAssets/SpryMenuBarRightHover.gif"});
//-->
</script>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=tis620" />
<title>RSS NEWS by CPE12</title>
<script src="file:///C|/AppServ/www/propage/SpryAssets/SpryMenuBar.js" type="text/javascript"></script>
<link href="file:///C|/AppServ/www/propage/SpryAssets/SpryMenuBarVertical.css" rel="stylesheet" type="text/css" />
<script src="file:///C|/AppServ/www/propage/Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
</head>
<body>
<table width="100%" border="0">
<tr>
<th colspan="3" scope="col"> </th>
</tr>
<tr>
<td> </td>
<td valign="top"><form id="form1" name="form1" method="post" action="">
¤é¹ËÒ¢èÒÇ
<label>
<input type="text" name="textfield" id="textfield" />
</label>
<label>
<select name="select" id="select">
<option>¡ÒÃàÁ×ͧ</option>
<option>àÈÃÉ°¡Ô¨</option>
<option>µèÒ§»ÃÐà·È</option>
<option>ÍÒªÒ¡ÃÃÁ</option>
<option>¡ÕÌÒ</option>
<option>ºÑ¹à·Ô§</option>
</select>
</label>
<label>
<select name="select2" id="select2">
<option>1 Çѹ</option>
<option>2 Çѹ</option>
<option>3 Çѹ</option>
<option>4 Çѹ</option>
<option>5 Çѹ</option>
<option>6 Çѹ</option>
<option>7 Çѹ</option>
</select>
</label>
</form> </td>
<td> </td>
</tr>
<tr>
<td width="27%">
<ul id="MenuBar1" class="MenuBarVertical">
<?php
define("DB_SERVER", "127.0.0.1"); // database server
define("USERNAME", "root"); // username
define("PASSWORD", "1234"); // no password
define("CURRENT_DB", "dbrss"); // current database
$db = mysql_pconnect( DB_SERVER, USERNAME, PASSWORD);
mysql_query("SET NAMES TIS620");
$sql="SELECT r_name, r_url FROM t_residence";
$result_show = mysql_db_query(CURRENT_DB, $sql);
if($result_show) {
while($rows = mysql_fetch_array($result_show)){
$link_name = $rows['r_name'];
$link_url = $rows['r_url'];
echo "<li><a class=\"MenuBarItemSubmenu\"href=\"$link_url\">$link_name</a>";
echo "<ul>";
$sql_show="SELECT chanel_name, chanel_url FROM t_chanel WHERE r_id = '$result_show(r_id)'";
$result = mysql_db_query(CURRENT_DB, $sql_show);
if($result) {
while($rows1 = mysql_fetch_array($result)){
$link1_name = $rows1['chanel_name'];
$link1_url = $rows1['chanel_url'];
$link1_rid = $row1['r_id'];
echo "<li><a href=\"$link1_url\">$link1_name</a></li>";
}
}
echo "</ul>";
}
}
?>
</ul> </td>
<td width="66%" valign="top"><p> </p></td>
<td width="7%"> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
<script type="text/javascript">
<!--
var MenuBar1 = new Spry.Widget.MenuBar("MenuBar1", {imgRight:"SpryAssets/SpryMenuBarRightHover.gif"});
//-->
</script>
</body>
</html>
-
- PHP Full Member
- โพสต์: 48
- ลงทะเบียนเมื่อ: 05/02/2009 5:06 pm
Re: ขอถามเรื่องการทำ spry menu bar โดยดึงข้อมูลจาก Mysql
ดึงข้อมูลจากตาราง 3 ตาราง โดยให้แสดงเมนูแรกออกมาเป็นสำนักข่าวด้วยการดึงค่าจากตารางที่ 1 ย่อยลงไปในสำนักข่าวมีประเภทข่าวไหนบ้าง ต้องเขียน sql ในลักษณะไหนครับ
-
- Similar Topics
- ตอบกลับ
- แสดง
- โพสต์ล่าสุด
-
-
โพสต์ใหม่ Spry Menu bar รันแล้วเป็นค่าเก่า ไม่เป็นไปตามค่าที
โดย Apisit Kamtoon » 04/11/2017 2:21 pm » ใน Programming - PHP - 2 ตอบกลับ
- 649 แสดง
-
โพสต์ล่าสุด โดย Apisit Kamtoon
12/12/2017 7:04 pm
-
-
-
โพสต์ใหม่ อัพเกรด Mysql Ubuntu จาก MySQL 5.5 เป็น MySQL 5.7
โดย mindphp » 12/06/2016 5:57 pm » ใน Linux - Web Server - 1 ตอบกลับ
- 3317 แสดง
-
โพสต์ล่าสุด โดย mindphp
12/06/2016 5:58 pm
-
-
-
โพสต์ใหม่ [Extension phpBB3.1.1] Breadcrumb Menu หรือ pull down menu
โดย worachat » 03/06/2016 3:05 pm » ใน phpBB 3.1 Extension Review - 0 ตอบกลับ
- 1506 แสดง
-
โพสต์ล่าสุด โดย worachat
03/06/2016 3:05 pm
-
ผู้ใช้งานขณะนี้
สมาชิกกำลังดูบอร์ดนี้: ไม่มีสมาชิกใหม่ และบุคลทั่วไป 121