Câu lạc bộ Hỗ Trợ Học Tập
Bạn có muốn phản ứng với tin nhắn này? Vui lòng đăng ký diễn đàn trong một vài cú nhấp chuột hoặc đăng nhập để tiếp tục.



 
Trang ChínhTrang Chính  Latest imagesLatest images  Tìm kiếmTìm kiếm  Đăng kýĐăng ký  Đăng NhậpĐăng Nhập  
  • Top posters
 Mr.Pakapun (256)
 ddtan90 (178)
 tvduong (147)
 dthnam90 (137)
 minhquankq (101)
 arianbo (70)
 DoanhNhan (54)
 chicken (53)
 stormit (52)
 gentle_storm (47)

 

 Thảo luận bài tập Lập trình web

Go down 
4 posters
Tác giảThông điệp
stormit
Thành viên tích cực
Thành viên tích cực
stormit


Tổng số bài gửi : 52
Join date : 06/01/2011

Thảo luận bài tập Lập trình web Empty
Bài gửiTiêu đề: Thảo luận bài tập Lập trình web   Thảo luận bài tập Lập trình web EmptySun Oct 02, 2011 10:45 am

Học kì này chắc có nhiều bạn học môn lập trình web, mình lập topic này để các bạn chia sẻ kiến thức lập trình, thảo luận bài tập thực hành.

Đầu tiên mình xin chia sẻ bài tập buổi 2 bài 2 của thầy An: Table example 1
code html:
Code:


<!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=utf-8" />
<title>Table example 1</title>
<link rel="stylesheet" type="text/css" href="Buoi2_bai 2.css" media="all" />
</head>

<body>

   <table cellspacing="0" class="outlinetable rowheight">
       <tr class="title" style="border-bottom-color:#FFF">
           <td width="50">Name</td>
            <td width="30">Age</td>
            <td width="120">Position</td>
            <td width="60">Income</td>
            <td width="50">Gender</td>
        </tr>
        <tr class="hovercolor">
           <td>Jonh</td>
            <td>37</td>
            <td>Managing director</td>
            <td>90.000</td>
            <td>Male</td>
        </tr>
        <tr class="hovercolor">
           <td>Susan</td>
            <td>34</td>
            <td>Partner</td>
            <td>90.000</td>
            <td>Female</td>
        </tr>
        <tr class="hovercolor">
           <td>David</td>
            <td>29</td>
            <td>Head of production</td>
            <td>70.000</td>
            <td>Male</td>
        </tr>
        <tr class="hovercolor">
           <td>Laura</td>
            <td>29</td>
            <td>Head of marketing</td>
            <td>70.000</td>
            <td>Female</td>
        </tr>
        <tr class="hovercolor">
           <td>Kate</td>
            <td>18</td>
            <td>Marketing</td>
            <td>50.000</td>
            <td>Female</td>
        </tr>
        <tr class="hovercolor">
           <td>Mona</td>
            <td>21</td>
            <td>Marketing</td>
            <td>53.000</td>
            <td>Female</td>
        </tr>
        <tr class="hovercolor">
           <td>Mike</td>
            <td>21</td>
            <td>Marketing</td>
            <td>53.000</td>
            <td>Male</td>
        </tr>
        <tr class="hovercolor">
           <td>Mark</td>
            <td>25</td>
            <td>Production</td>
            <td>52.000</td>
            <td>Male</td>
        </tr>
    </table>


</body>
</html>

Code css:
Code:


@charset "utf-8";
/* CSS Document */
.title{   
   font-weight:bold;
   background-color:#0FF;
   border:none;
}
.hovercolor:hover{
   background-color:#369;
}
.rowheight{
   line-height:25px;
}
.outlinetable{
   outline-color:#333;
   outline-width:1px;
   outline-style:solid;
}

Phần màu sắc hover và màu nền tiêu đề các bạn chỉnh lại dùm (mình không tìm được màu như trong bảng của thầy).
Có gì các bạn góp ý nhé, mới học lập trình web nên chưa biết nhiều! ^^
Về Đầu Trang Go down
stormit
Thành viên tích cực
Thành viên tích cực
stormit


Tổng số bài gửi : 52
Join date : 06/01/2011

Thảo luận bài tập Lập trình web Empty
Bài gửiTiêu đề: Re: Thảo luận bài tập Lập trình web   Thảo luận bài tập Lập trình web EmptySun Oct 02, 2011 4:57 pm

Thay đổi nền backgroud khi rê chuột vào ô tương ứng:
Thảo luận bài tập Lập trình web Changebackgroundcolorwithonmouseover
Code:


<!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=utf-8" />
<title>Background color with mouse over</title>
<link rel="stylesheet" href="Buoi2_bai 1.css" type="text/css" media="all" />

</head>

<body id="bd">
<script type="text/javascript">
   bd= document.getElementById("bd");
   function changeclrover(className){
      
      /*var allHTML = document.getElementsByTagName("*");
      for(i=0;i<allHTML.length;i++){*/
            if(className=="red"){
               bd.style.backgroundColor="red";   
            }
            else{
               if(className=="blue"){
                  bd.style.backgroundColor="blue";   
               }
               else{
                  if(className=="green"){
                     bd.style.backgroundColor="green";   
                  }
                  else{
                     bd.style.backgroundColor='';      
                  }
               }
            }
   }   
   function changecolorout(){
      bd.style.backgroundColor = "white";   
   }
         

      
         

</script>

   <b>Mouse over the squares and the background color will change!</b>
    <table>
       <tr>
           <td class="colorred" width="150" height="150" onmouseover="changeclrover('red')" onmouseout="changecolorout()"></td>
            <td class="colorblue"  width="150" height="150" onmouseover="changeclrover('blue')" onmouseout="changecolorout()"></td>
            <td class="colorgreen"  width="150" height="150" onmouseover="changeclrover('green')" onmouseout="changecolorout()"></td>
                     
        </tr>
    </table>

</body>
</html>
Về Đầu Trang Go down
stormit
Thành viên tích cực
Thành viên tích cực
stormit


Tổng số bài gửi : 52
Join date : 06/01/2011

Thảo luận bài tập Lập trình web Empty
Bài gửiTiêu đề: Re: Thảo luận bài tập Lập trình web   Thảo luận bài tập Lập trình web EmptySun Oct 02, 2011 5:00 pm

Thiết kế menu đơn giản:
Code:


<!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=utf-8" />
<title>Menu</title>
<style type="text/css">
   .mainnav{
      width:630px;
      line-height:30px;
      text-align:left;
      background-color:#6C0;
      margin:0 auto 30px auto;
      font-weight:bold;
      
   }
   .mainnav ul{
      margin:0px;
      padding:0px;
      list-style:none;   
   }
   .mainnav ul li{
      padding:0 20px;
      display:inline;
      line-height:20px;   
   }
   .mainnav li a{
      color:#FFF;
      text-decoration:none;
      text-transform:uppercase;
   }
   .mainnav li a:hover{
      color:#FF0;
   }


</style>
</head>

<body>
   <div class="mainnav">
       <ul>
           <li class="hover"><a href="#" title="home">Home</a></li>
            <li><a href="#" title="news"> news</a></li>
            <li><a href="#" title="articles">articles</a></li>
            <li><a href="#" title="forum">forum</a></li>
            <li><a href="#" title="contact">contact</a></li>
            <li><a href="#" title="about" style="border-right:none">about</a></li>
        </ul>
    </div>

</body>
</html>
Về Đầu Trang Go down
tvduong
Admin
Admin
tvduong


Tổng số bài gửi : 147
Join date : 29/10/2010
Age : 34

Thảo luận bài tập Lập trình web Empty
Bài gửiTiêu đề: Re: Thảo luận bài tập Lập trình web   Thảo luận bài tập Lập trình web EmptyWed Oct 12, 2011 10:46 am

Sáng nay lên google tra thông tin về code lập trình web, thấy có bài hướng dẫn tạo add dữ liệu ngày tháng vào combobox bằng php của bạn Tân trên forum mình. Ngặt hôm học php mình trốn học, nên giờ không biết php ra sao? Smile Nên mình thử add bằng javascript xem sao, các bạn góp ý nhé. Mình lấy bài tập 5, buổi thực hành 3 của thầy An làm ví dụ.
Thảo luận bài tập Lập trình web Buoi3_bai5_web

Code:


<!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=utf-8" />
<title>Form registry</title>
<style type="text/css">
*{
margin:0px;
padding:0px;
}
.formatpage{
font-family:"Times New Roman";
font-size:20px;
line-height:35px;
text-vertical:middle;
}
.formatpage table{
margin:20px auto;
}
#firsttitle{
text-align:center;
font-size:40px;
color:blue;
font-weight:bold;
padding-bottom:10px;
}
.secondtitle{
background-color:aqua;
padding:5px;
color:blue;
font-weight:bold;
font-size:22px;
}
input{
margin-left:10px;
margin-right:10px;
height:25px;
font-family:"Times New Roman";
}
input[type="radio"],input[type="checkbox"]{
height:10px;
}

input[type="reset"],input[type="submit"]{
height:30px;
width:70px;
font-weight:bold;
font-size:18px;

}

select{
font-size:18px;
height:25px;
margin-left:10px;
font-family:"Times New Roman";
}
.secondtitle span{
color:black;
}
</style>
</head>

<body>
   <div class="formatpage"> 
        <form name="formreg" action="" method="post">
           <table name="tablereg" width="800px" align="center">
               <tr>
                   <td colspan="2" id="firsttitle">THÔNG TIN ĐĂNG KÍ THÀNH VIÊN</td>
                </tr>
                <tr>
                   <td colspan="2" class="secondtitle"><span>>> </span>Thông tin cá nhân</td>
                </tr>
                <tr>
                   <td align="right">Họ tên:</td>
                    <td><input type="text" size="25" name="hoten" /></td>
                </tr>
                <tr>
                   <td align="right">Ngày sinh:</td>
                    <td>
                       Ngày
                        <select name="ngay">
                           <script type="text/javascript">
                        for(var i=1;i<=31;i++){
                           document.write("<option value='"+i+"'>"+i+"</option>");   
                        }
                     </script>
                        </select>
                        Tháng
                        <select name="thang">
                           <script type="text/javascript">
                        for(var i=1;i<=12;i++){
                           document.write("<option value='"+i+"'>"+i+"</option>");   
                        }
                     </script>
                        </select>
                        Năm
                        <select name="nam">
                           <script type="text/javascript">
                        var d= new Date();
                        for(var i=1970;i<=d.getFullYear();i++){
                           document.write("<option value='"+i+"'>"+i+"</option>");   
                        }
                     </script>
                        </select>
                    </td>
                </tr>
                <tr>
                   <td align="right">Giới tính:</td>
                    <td>
                       <input type="radio" value="nam" name="gtinh" />Nam
                        <input type="radio" value="nu" name="gtinh" />Nữ
                    </td>
                </tr>
                <td align="right">Địa chỉ:</td>
                <td>
                   <textarea name="diachi" rows="3" cols="40"></textarea>
                </td>
                <tr>
                   <td align="right">Tỉnh thành:</td>
                    <td>
                       <select name="tinh/tp">
                           <option value="index">[Chọn Tỉnh Thành]</option>
                    <script type="text/javascript">
                              var arr = new Array("Long An","Đồng Tháp","Vĩnh Long","Trà Vinh","Bến Tre","Cần Thơ","Hậu Giang","Sóc Trăng","Bạc Liêu","Cà Mau","Kiên Giang","An Giang");
                              for(var i=0;i<arr.length;i++){
                                  document.write("<option value='"+arr[i]+"'>"+arr[i]+"</option>");
                              }
                          </script>
                        </select>
                    </td>
                </tr>
                <tr>
                   <td align="right">Tài khoản</td>
                    <td><input type="text" size="25" name="taikhoan" /></td>
                </tr>
                <tr>
                   <td align="right">Mật khẩu</td>
                    <td>
                       <input type="password" name="matkhau" />
                    </td>
                </tr>
                <tr>
                   <td align="right">Xác nhận mật khẩu</td>
                    <td><input type="password" name="xnmatkhau" /></td>
                </tr>
                <tr>
                   <td colspan="2" class="secondtitle"><span>>></span> Thông tin khác:</td>
                </tr>
                <tr>
                   <td align="right">
                       Sở thích:
                    </td>
                    <td>
                       <input type="checkbox" name="thethao" />Thể thao
                        <input type="checkbox" name="amnhac" />Âm nhạc
                        <input type="checkbox" name="choigame" />Chơi game
                        <input type="checkbox" name="khac" />Khác
                    </td>
                </tr>
                <tr>
                   <td align="right">
                       Địa chỉ Email:
                    </td>
                    <td>
                       <input type="text" value="" size="30" />
                    </td>
                </tr>
                <tr>
                   <td colspan="2" align="center">
                       <input type="checkbox" name="dongy" />
                        Tôi đồng ý đăng kí thành viên và cam kết thực hiện đúng các quy định của website.
                    </td>
                </tr>
                <tr>
                   <td colspan="2" align="center">
                       <input type="submit" value="Đồng ý" disabled="disabled" />
                        <input type="reset" value="Hủy bỏ" />
                    </td>
                </tr>
            </table>
        </form>
    </div>
   
</body>
</html>

Code này mình vẫn chưa xử lý các ràng buộc!
Xem xử lý tính hợp lệ của bạn Tân ở đây:
Code:
http://clbhotrohoctap.forumvi.com/t259-topic
Về Đầu Trang Go down
fly_two
Thành viên mới
Thành viên mới
fly_two


Tổng số bài gửi : 8
Join date : 15/09/2011

Thảo luận bài tập Lập trình web Empty
Bài gửiTiêu đề: Re: Thảo luận bài tập Lập trình web   Thảo luận bài tập Lập trình web EmptyWed Oct 12, 2011 7:48 pm

Cho em hỏi ké Very Happy chỗ bài 4 buổi thực hành 3 của thầy An, làm sao để thêm, xóa, em chưa hiểu lắm chỗ firstChild, nextSibling... như bài đó để truy xuất các phần tử của form hay table thì phải làm thế nào? mọi người giải thích thêm cho em chỗ này với.
Về Đầu Trang Go down
tvduong
Admin
Admin
tvduong


Tổng số bài gửi : 147
Join date : 29/10/2010
Age : 34

Thảo luận bài tập Lập trình web Empty
Bài gửiTiêu đề: Re: Thảo luận bài tập Lập trình web   Thảo luận bài tập Lập trình web EmptyFri Oct 14, 2011 11:12 am

Thêm xóa dòng bảng dữ liệu_Bài tập 4 buổi 3_Thầy An
Code:


<!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=utf-8" />
<title>Insert Rows Table</title>
<style type="text/css">
   .page{
      margin:30px 200px;
      padding:20px;
      line-height:30px;
      font-size:20px;
   }
   .page #tb{
      margin-top:20px;   
   }
   .bold{
      font-weight:bold;
      font-family:"Times New Roman", Times, serif;
      text-align:center;   
   }
   .page table{
      border-spacing:0px;   
   }
   #tb tr{
      text-align:center;
   }
</style>
</head>

<body>
<div class="page">
  <form name="forminf" >
      MSSV:<input type="text" size="25" value="" id="mssv" name="mssv" />
      Họ tên:<input type="text" size="25" value="" id="ht" name="ht" />
      <input type="button" name="Them" value="Thêm" onclick="addrows()" />
  </form>
  <table id="tb" border="1" width="700">
     <tr class="bold">
      <td width="20%">STT</td>
      <td width="30%">MaSV</td>
      <td width="30%">Họ Tên</td>
      <td width="20%">Xóa</td>
    </tr>
 
  </table>
  <script type="text/javascript">
     var i = 1;
   function addrows(){
      var ms = document.getElementById("mssv");
      var ten = document.getElementById("ht");
      var tb = document.getElementById("tb");
      var tr = document.createElement("tr");
      tr.id = i;
      tr.innerHTML="<tr><td>"+i+"</td><td>"+ms.value+"</td><td>"+ten.value+"</td><td onclick='xoadong(\""+i+"\")'><img src='daux.gif' width='25' height='25'/></td></tr>";
      tb.appendChild(tr);
      i++;
   }
   function xoadong(r){
      row = document.getElementById(r); //Lấy dòng có id là i
      t = row.parentNode; //Trả về node bảng
      ind = t.firstChild; //dòng đầu tiên của bảng
      while(ind.nextSibling.id!=r){//Kiểm tra từng node anh em xem nút nào có id là i
         ind = ind.nextSibling;
      }
      t.removeChild(ind.nextSibling);//Remove node đó
   }
  </script>
</div>
</body>
</html>
Đây là code của mình, trong đó có ghi chú!
Mình thấy có bạn làm ngắn hơn (3-4 dòng gì đó) Smile. Cách mình dài chút nhưng dễ hiểu hơn Very Happy
Trao đổi cùng bạn!
Về Đầu Trang Go down
gentle_storm
Thành viên tích cực
Thành viên tích cực
gentle_storm


Tổng số bài gửi : 47
Join date : 03/01/2011

Thảo luận bài tập Lập trình web Empty
Bài gửiTiêu đề: Online Address Book_bai 7_ buoi 4_ thầy An   Thảo luận bài tập Lập trình web EmptySun Oct 30, 2011 9:30 pm

Mới làm xong, gửi các bạn tham khảo (Form addentry chưa ràng buộc dữ liệu nhé!)
Link csdl:
Code:
http://www.mediafire.com/?2fjc5c9zybbafzb
Code mymenu.html:
Code:


<!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=utf-8" />
<title>My address book</title>
</head>

<body>
   <h2>My Addrss Book</h2>
    <h4>Management</h4>
    <ul>
       <li><a href="addentry.php">Add an Entry</a></li>
        <li><a href="delentry.php">Delete an Entry</a></li>
    </ul>
    <h4>Viewing</h4>
    <ul>
       <li><a href="selentry.php">Select an Entry</a></li>
    </ul>
</body>
</html>

Code addentry.php:
Code:

<!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=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
   .title{
      font-weight:bold;
      margin-bottom:0px;
   }
</style>
</head>

<body>
   <?php
      if(isset($_POST['fname']) and $_POST['fname'] != ""){
         $conn = mysql_connect("localhost","root","vertrigo");
         $db = mysql_select_db("addressbookdb",$conn);
         $d = date("Y-m-d");
         $query = mysql_query("Insert into master_name(date_added,date_modified,f_name,l_name) values('$d','$d','$_POST[fname]','$_POST[lname]')",$conn) or die("Error: ".mysql_error());
         $query = mysql_query("Select * from master_name");
         $id = "1";
         while($row = mysql_fetch_array($query)){
            $id = $row['id'];
         }
         $query = mysql_query("Insert into address(master_id,date_added,date_modified,address,city,state,zipcode,type) values('$id','$d','$d','$_POST[address]','$_POST[city]','$_POST[state]','$_POST[zipcode]','$_POST[addresstype]')",$conn) or die("Error: ".mysql_error());
         $query = mysql_query("Insert into email(master_id,date_added,date_modified,email,type) values('$id','$d','$d','$_POST[emailaddress]','$_POST[emailtype]')",$conn) or die("Error: ".mysql_error());
         $query = mysql_query("Insert into fax(master_id,date_added,date_modified,fax_number,type) values('$id','$d','$d','$_POST[faxnumber]','$_POST[faxtype]')",$conn) or die("Error: ".mysql_error());
      
         $query = mysql_query("Insert into telephone(master_id,date_added,date_modified,tel_number,type) values('$id','$d','$d','$_POST[telnumber]','$_POST[teltype]')",$conn) or die("Error: ".mysql_error());
      
         $query = mysql_query("Insert into personal_notes(master_id,date_added,date_modified,note) values('$id','$d','$d','$_POST[note]')",$conn) or die("Error: ".mysql_error());
         echo "<script type='text/javascript'>alert('Them thanh cong');</script>";
      }
   ?>
   <h2>Add an Emtry</h2>
    <form name="addentry" action="addentry.php" method="post">
    <table name="table">
    <tr>
       <td colspan="2" class="title">First/Last Names:</td>
    </tr>
    <tr>
       <td><input type="text" name="fname" size="30" /></td>
        <td><input type="text" name="lname" size="30" /></td>
    </tr>
    <tr>
       <td colspan="2" class="title">Address</td>
    </tr>
    <tr>
       <td colspan="2"><input type="text" name="address" size="30" /></td>
    </tr>
    <tr>
       <td colspan="2" class="title">City/State/Zip</td>
    </tr>
    <tr>
       <td><input type="text" name="city" size="30" /></td>
        <td><input type="text" name="state" size="8" />
        <input type="text" name="zipcode" size="13" />
        </td>
    </tr>
    <tr>
       <td colspan="2" class="title">Address Type</td>
    </tr>
    <tr>
       <td colspan="2">
           <input type="radio" name="addresstype" value="home" checked="checked" />Home
            <input type="radio" name="addresstype" value="work" />work
            <input type="radio" name="addresstype" value="other" />other
        </td>
    </tr>
    <tr>
       <td colspan="2" class="title">
           Telephone Number:
        </td>
    </tr>
    <tr>
       <td><input type="text" name="telnumber" size="30" /></td>
        <td>
           <input type="radio" name="teltype" checked="checked" value="home"/>home
            <input type="radio" name="teltype" value="work"/>work
            <input type="radio" name="teltype" value="other"/>other
        </td>
    </tr>
    <tr>
       <td colspan="2" class="title">
           Fax Number:
        </td>
    </tr>
    <tr>
       <td><input type="text" name="faxnumber" size="30" /></td>
        <td>
           <input type="radio" name="faxtype" checked="checked" value="home"/>home
            <input type="radio" name="faxtype" value="work"/>work
            <input type="radio" name="faxtype" value="other"/>other
        </td>
    </tr>
    <tr>
       <td colspan="2" class="title">
           Email Address:
        </td>
    </tr>
    <tr>
       <td><input type="text" name="emailaddress" size="30" /></td>
        <td>
           <input type="radio" name="emailtype" checked="checked" value="home" />home
            <input type="radio" name="emailtype" value="work"/>work
            <input type="radio" name="emailtype" value="other" />other
        </td>
    </tr>
    <tr>
       <td colspan="2" class="title">Personal Note:</td>
    </tr>
    <tr>
       <td colspan="2">
           <textarea cols="40" rows="3" name="note"></textarea>
        </td>
    </tr>
    <tr>
       <td colspan="2">
           <input type="submit" value="Add Entry" size="10"/>
            <input type="reset" value="Reset" size="10" />
        </td>
    </tr>
     </table> 
    </form>
</body>
</html>
Code selentry.php:
Code:

<!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=utf-8" />
<title>Untitled Document</title>
</head>

<body>
   <?php
   $conn = mysql_connect("localhost","root","vertrigo");
   $db = mysql_select_db("addressbookdb",$conn);
      if(isset($_POST['entry']) and $_POST['entry'] != 0){
         $query = mysql_query("select l_name,f_name from master_name where id=$_POST[entry]",$conn);
         $row = mysql_fetch_array($query);
         echo "<h2>Showing record for ".$row['l_name']." ".$row['f_name']."</h2>";
         echo "<h4>Address</h4>";
            $query = mysql_query("select address,type from address where master_id=$_POST[entry]",$conn);
            $row =mysql_fetch_array($query);
            echo "<ul>";
            echo "<li>".$row['address']." (".$row['type'].")</li>";
            echo "</ul>";
         echo "<h4>Telephone</h4>";
            $query = mysql_query("select tel_number,type from telephone where master_id=$_POST[entry]",$conn);
            $row =mysql_fetch_array($query);
            echo "<ul>";
            echo "<li>".$row['tel_number']." (".$row['type'].")</li>";
            echo "</ul>";
         echo "<h4>Fax</h4>";
            $query = mysql_query("select fax_number,type from fax where master_id=$_POST[entry]",$conn);
            $row =mysql_fetch_array($query);
            echo "<ul>";
            echo "<li>".$row['fax_number']." (".$row['type'].")</li>";
            echo "</ul>";
         echo "<h4>Email</h4>";
            $query = mysql_query("select email,type from email where master_id=$_POST[entry]",$conn);
            $row =mysql_fetch_array($query);
            echo "<ul>";
            echo "<li>".$row['email']." (".$row['type'].")</li>";
            echo "</ul>";
         echo "<h4>Personal Notes</h4>";
            $query = mysql_query("select note from personal_notes where master_id=$_POST[entry]",$conn);
            $row =mysql_fetch_array($query);
            echo $row['note'];
         echo "<br/><div align='center'><a href='selentry.php'>Select another</a></div>";
      }
   else{
    ?>
    <h2>Select an Entry</h2>
   <h4>Select Record to View:</h4>
    <form name="form" action="selentry.php" method="post">
    <select name='entry'>"
       <option value='0'>-Select One-</option>
         <?php
         $querry = mysql_query("Select * from master_name",$conn);
         while($row = mysql_fetch_array($querry)){
            echo "<option value='".$row['id']."'>".$row['f_name'].",".$row['l_name']."</option>";
         }

         ?>
    </select>
    <input type="submit" value="View selected entry" name="submit" />
    </form>
  <?php } ?>
 
   
</body>
</html>
Code delentry.php:
Code:

<!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=utf-8" />
<title>Delete Entry</title>
</head>

<body>
<?php
   $conn = mysql_connect("localhost","root","vertrigo");
   $db =  mysql_select_db("addressbookdb",$conn);
   if(isset($_POST['entry']) and $_POST['entry']!=0){
      $query = mysql_query("Delete from master_name where id=$_POST[entry]",$conn) or die("Error: ".mysql_error());
      $query = mysql_query("Delete from address where master_id=$_POST[entry]",$conn);
      $query = mysql_query("Delete from fax where master_id=$_POST[entry]",$conn);
      $query = mysql_query("Delete from email where master_id=$_POST[entry]",$conn);
      $query = mysql_query("Delete from telephone where master_id=$_POST[entry]",$conn);
      $query = mysql_query("Delete from personal_notes where master_id=$_POST[entry]",$conn);
      echo "<h3>Record(s) Deleted</h3>";
      echo "Would you like to ";
      echo "<a href='delentry.php'>delete another</a>?";
   }
   else{
?>
<h2>Select an Entry</h2>
   <h4>Select Record to Delete:</h4>
    <form name="form" action="delentry.php" method="post">
    <select name='entry'>"
       <option value='0'>-Select One-</option>
         <?php
         $querry = mysql_query("Select * from master_name",$conn);
         while($row = mysql_fetch_array($querry)){
            echo "<option value='".$row['id']."'>".$row['f_name'].",".$row['l_name']."</option>";
         }

         ?>
    </select>
    <input type="submit" value="Delete selected entry" name="submit" />
    </form>
<?php } ?>
</body>
</html>

Hi, chưa chuẩn lắm! ^^
Về Đầu Trang Go down
tvduong
Admin
Admin
tvduong


Tổng số bài gửi : 147
Join date : 29/10/2010
Age : 34

Thảo luận bài tập Lập trình web Empty
Bài gửiTiêu đề: Thầy Trường_Bài 2_ Buổi 2_ Thực đơn   Thảo luận bài tập Lập trình web EmptyWed Nov 02, 2011 9:19 pm

Thảo luận bài tập Lập trình web Thucdon
Chuối quá, bài có chút xíu mà làm cũng lâu! ^^

Code:


<!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=utf-8" />
<title>Thực Đơn</title>
<style type="text/css">
*{
margin-bottom: 10px;
}
</style>
<script type="text/javascript">
   function chonmon(){
      var i = 0;
      var finish = false;
      var money = 0;
      for(var j = 0; j<=9; j++){
         document.getElementsByName("mon").item(j).checked = false;
      }
      while(!finish){
         var ran = Math.round(Math.random()*9);
         if(document.getElementsByName("mon").item(ran).checked == false){
            document.getElementsByName("mon").item(ran).checked = true;
            money += parseInt(document.getElementsByName("mon").item(ran).value);
            i++;
         }
         if(i==3){
            finish = true;   
         }
      }
      document.getElementsByName("tien").item(0).value = money;
   }
</script>
</head>

<body>
   <table>
       <tr>
           <td align="center" colspan="4" style="color:blue; font-weight:bold; font-size: 20px;">
               Thực đơn
            </td>
        </tr>
       <tr>
           <td width="200">
               <input type="checkbox" name="mon" value="30000" />Gà sào lăng
            </td>
            <td width="100">30.000
            </td>
            <td width="200">
               <input type="checkbox" name="mon" value="20000" />Ốc nướng tiêu
            </td>
            <td>20.000
            </td>
        </tr>
        <tr>
           <td width="200">
               <input type="checkbox" name="mon" value="30000" />Ếch rang muối
            </td>
            <td width="100">30.000
            </td>
            <td width="200">
               <input type="checkbox" name="mon" value="120000" />Nghêu hấp dừa
            </td>
            <td>120.000
            </td>
        </tr>
        <tr>
           <td width="200">
               <input type="checkbox" name="mon" value="40000" />Bê thui
            </td>
            <td width="100">40.000
            </td>
            <td width="200">
               <input type="checkbox" name="mon" value="20000" />Dòi trường sào dưa cải
            </td>
            <td>20.000
            </td>
        </tr>
        <tr>
           <td width="200">
               <input type="checkbox" name="mon" value="50000" />Bê nướng
            </td>
            <td width="100">50.000
            </td>
            <td width="200">
               <input type="checkbox" name="mon" value="15000" />Gỏi xoài cá lóc
            </td>
            <td>15.000
            </td>
        </tr>
        <tr>
           <td width="200">
               <input type="checkbox" name="mon" value="75000" />Lẩu rắn
            </td>
            <td width="100">75.000
            </td>
            <td width="200">
               <input type="checkbox" name="mon" value="200000" />Rùa hấp
            </td>
            <td>200.000
            </td>
        </tr>
        <tr>
           <td align="center" colspan="4">   
               <span style="color:red; font-weight:bold;">Tổng tiền các món đã chọn: </span><input type="text" name="tien" value="" size="30" />
            </td>
        </tr>
        <tr>
           <td align="center" colspan="4">   
               <input type="button" name="btnchonmon" value="      Click vào đây để chọn ngẫu nhiên ba món ăn      " onclick="chonmon();" />
            </td>
        </tr>
    </table>
   
</body>
</html>
Về Đầu Trang Go down
Sponsored content





Thảo luận bài tập Lập trình web Empty
Bài gửiTiêu đề: Re: Thảo luận bài tập Lập trình web   Thảo luận bài tập Lập trình web Empty

Về Đầu Trang Go down
 
Thảo luận bài tập Lập trình web
Về Đầu Trang 
Trang 1 trong tổng số 1 trang
 Similar topics
-
» Đề thi Lập trình WEB - Cùng nhau thảo luận cách giải
» Thảo luận về đề tài niên luận 1
» Thảo luận về các chủ đề trên UVA
» Rubik một trò thú vị
» hoi ve tai lieu luan van

Permissions in this forum:Bạn không có quyền trả lời bài viết
Câu lạc bộ Hỗ Trợ Học Tập :: LẬP TRÌNH WEB :: HTML/CSS/JAVASCRIPT-
Chuyển đến