PHP Unlimited class (with database) (1/2)

Source: Internet
Author: User
Tags mysql tutorial
The code is as follows Copy Code
<!doctype HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/ Xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 "/>
<style type= "Text/css Tutorial" >
<!--
. menu {color: #000000; font-size:12px; cursor:hand;}
</style>
<script type= "text/web Effects" >
function ShowMenu (MENUID)
{
if (menuid.style.display== "None")
{
Menuid.style.display= "";
}
Else
{
Menuid.style.display= "None";
}
}
</script>
<title> TV tree-like directory </title>
<body>
<?php
$globals ["id"] = 1;
$jibie = 1;
$sql = "SELECT * from Tvmenu where bid=0";
$result =mysql Tutorial _query ($sql, $conn);

if (mysql_num_rows ($result) >0)
Treemenu ($conn, $result, $jibie, $id);

function Treemenu ($conn, $result, $jibie)//go into functional loops
{
$numrows =mysql_num_rows ($result);
echo "<table cellpadding= ' 0 ' cellspacing= ' 0 ' border= ' 0 ' >";
for ($rows =0; $rows < $numrows; $rows + +)
{
$menu =mysql_fetch_array ($result);
$sql = "SELECT * from Tvmenu where bid= $menu [id]";
$result _sub=mysql_query ($sql, $conn);
echo "<tr>";
If the menu item has a submenu, add the JavaScript onclick statement
if (mysql_num_rows ($result _sub) >0)
{
echo "<td width= ' ></td>";
echo "<td class= ' menu ' onclick= ' Javascript:showmenu (menu". $globals ["id"]. "); ' > ";
}
Else
{
echo "<td width= ' ></td>";
echo "<td class= ' menu ' >";
}
if ($menu [url]!= "")
echo "<a href= ' $menu [url] ' > $menu [name]</a>";
Else
echo "<a href= ' > $menu [name]</a> <a href= '? b={$menu [Id]}&tpye=add ' > Add </a> <a href= '? b={$menu [id]}&tpye=edit ' > Edit </a> <a href= '? b={$menu [id]}&action=del ' > Delete </a>];
echo "</td> </tr>";
if (mysql_num_rows ($result _sub) >0)
{
echo "<tr id=menu". $globals ["id"]++. "style= ' Display:none ' >";
echo "<td width= ' > </td>";
echo "<td>";
Add 1 to the series
$jibie + +;
Treemenu ($conn, $result _sub, $jibie);
$jibie--;
echo "</td></tr>";
}
Show Next Menu
}
echo "</table>";
}
?>
<br/>
<br/>
<?php if ($tpye = = "Add") {?>
<table width= "551" border= "0" cellpadding= "0" cellspacing= "1" bgcolor= "#cccccc" >
<form action= "" method= "Post" Name= "Form1" >
<tr>
&LT;TD height= colspan= "2" align= "center" bgcolor= "#ffffff" > Add columns </td>
</tr>
<tr>
&LT;TD width= "246" height= "align=" right "bgcolor=" #ffffff "> Column name:</td>
&LT;TD width= "302" height= "bgcolor=" #ffffff "><input name=" name "type=" text "id=" name "/></td>
</tr>
<tr>
&LT;TD height= "align=" "Right" bgcolor= "#ffffff" > Classification:</td>
&LT;TD height= "bgcolor=" "#ffffff" ><select name= "bid" >
<?php

$sql = "SELECT * from Tvmenu";
$que =mysql_query ($sql, $conn);
while ($rs =mysql_fetch_array ($que)) {
if ($rs [' id ']== $b) {
$selected = "selected=" selected "";
}else{
$selected = "";
}
?>

<option value= "<?php echo $rs [" id "];?>" <?php echo $selected;? >><?php echo $rs ["name"];?></option>
<?php}?>
</select>
</td>
</tr>
<tr>
&LT;TD height= colspan= "2" align= "center" bgcolor= "#ffffff" ><input type= "Submit" name= "Submission" value= "submitted"/& Gt;</td>
</tr>
</form>
</table>
<?php}?>

Home 1 2 last page

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.