SlideShare a Scribd company logo
1 of 13
1. dbcon.php
<?php
   $link =mysql_connect("localhost","root","") or die("No
connection");
   mysql_select_db("banhang",$link);
   mysql_query("set names 'utf8'");
?>
2. index.php
<body>
<div id="container">
   <div id="header">
         <?php include ("header.php"); ?>
   </div>
   <div id="loaisp">
   <?php include ("loaisp2.php"); ?>
   </div>
   <div id="content">
      <div id="sdmenu">
         <?php include ("sdmenu/sdmenu.php"); ?>
      </div>

      <div id="gsp">
         <?php
               if (!isset($_GET["act"]))
               { include ("gsp.php");}
               else
               {
                      switch($_GET["act"])
                      {
                            case "loaisp": include ("sanpham.php");
                            break;
                            case "tim": include ("sanpham2.php");
                            break;
                            case "chitiet": include ("ctsp.php");
                            break;
                      }
               }
               ?>
      </div>
   </div>
   <div id="footer">
         <?php include ("footer.php"); ?>
   </div>
</div>
</body>
3. gsp.php
<scri pt t ype="t ext / j avascri pt " src=" j query.mi n.j s" ></ scri pt >

<scri pt t ype="t ext / j avascri pt " >
$(docu ment ).read y(f unct i on (){
     $(' # mai n_phi m>di v' ).ea ch(f unct i on (){
         var $i mg=$ (t hi s).chi l dren(). at t r (' src' );
         / / al ert ($i mg)
         var $t i t l e=$(t hi s ).f i nd(' p.nam e' ).t ext ()
         / / al ert ($t i t l e)
         $(t hi s ).f i nd(' di v.i nf o' ).pr epend(' <i mg src=' +$i mg+' / ><p cl ass=" t i tl e" >' +
$t i tl e+' </ p>' )
     })
     $(' # mai n_phi m>di v>i mg' ).ho ver (f unct i on (){
         $(t hi s ).parent ().f i nd (' di v.i nf o' ).show ()
     },f unct i on(){
         $(t hi s ).parent ().f i nd (' di v.i nf o' ).hi de()
     }).mous emov e(f unct i on (e ){
         var $X=e.cl i ent X
         var $Y =e.cl i entY
         $(t hi s ).parent ().f i nd (' di v.i nf o' ).css ({' l ef t ' :$X+20,' t op' :$Y })
     }).cl i c k(f unct i on (){
         var $l i nk=$ (t hi s).par ent (). f i nd(' a' ).at t r(' href ' )
         w i ndow .open ($l i nk,' ' )
     })
})
</ scri pt >

    <?php
    include("dbcon.php");
    //can chep doan nay vao neu co lam
    $sodong=9;


     $kq=mysql_query("select * from sanpham",$link);
     $tongsotrang=ceil(mysql_num_rows($kq)/$sodong); //tong so
    dong du lieu truy van
     //ceil lay tron


      if (!isset($_GET["p"]))
      { $p=1;
      }
      else
      {
        $p=intval($_GET["p"]); //intval chuyen chuoi thanh so
      }
      $x=($p-1)*$sodong;


         $query_sanpham="select * from sanpham limit $x, $sodong";
//chep den day
     $table_sanpham=mysql_query($query_sanpham,$link);
?>

<div id="main_phim">

   <?php while($d=mysql_fetch_array($table_sanpham)) { ?>
  <div>
  <img width="100" height="100" src="images/<?php echo
$d["UrlHinh"];?>">
      <div class="info">

      <p>Gia=<?php echo $d["Gia"]; ?></p>
      <p>MaSP=<?php echo $d["MaSP"]; ?></p>
     </div>
  <a href="index.php?act=chitiet&masp=<?php echo $d["MaSP"];
?>"> Chitiet </a>
  </div>

  <?php } ?>
</div>


<p align="center">
<?php
//can chep doan nay vao neu co lam phan trang
for($i=1;$i<=$tongsotrang;$i++)
{ if ($i==$p)
   { echo $i."&nbsp;";
   }
   else
   {
 ?>
 <a href="index.php?p=<?php echo $i; ?>"><?php echo $i; ?></a>
<?php
   }
}
//chep den day
?>
</p>
</body>
4. loaisp2.php
<body>
<?php
   $link =mysql_connect("localhost","root","") or die("No
connection");
   mysql_select_db("qlhsthpt",$link);
   mysql_query("set names 'utf8'");

     $query_chungloaisp="select * from hocsinh";
     $table_chungloaisp=mysql_query($query_chungloaisp,$link);

?>

<form id="form1" name="form1" method="post"
action="index.php?act=tim">
   <select name="truong" id="list">
    <?php
while($chungloaisp=mysql_fetch_array($table_chungloaisp)) { ?>
    <option
               <?php if(isset($_POST["loaisp"]) &&
($_POST["loaisp"]=="cl-".$chungloaisp["idCL"])) echo
"selected";?> value="cl-<?php echo $chungloaisp['idCL']; ?>"
class="menu_cap1"><?php echo $chungloaisp['Ten']?> </option>
    <?php
                    $idCL=$chungloaisp['idCL'];
                    $query_loaisp="select * from loaisp where
idCL=$idCL";
                    $table_loaisp=mysql_query($query_loaisp,
$link);

   while($loaisp=mysql_fetch_array($table_loaisp)) {
              ?>
    <option
                   <?php
                   if(isset($_POST["loaisp"]) &&
($_POST["loaisp"]==$loaisp["idLoai"])) echo "selected";?>
class="menu_cap2" value="<?php echo $loaisp['idLoai'];?
>">&nbsp;&nbsp;&nbsp;<?php echo $loaisp['Ten'];
                   ?> </option>
    <?php }?>
    <?php } ?>
   </select>
<select name="mon" id="mon">
 <option value="0" selected="selected">0</option>
    <?php for($i=1;$i<=5;$i++){?>
<option <?php if(isset($_POST["price_from"]) &&
($_POST["price_from"]== $i*100)) echo "selected";?> value="<?
php echo $i*100;?>"><?php echo ($i*100)." VND"?>
         </option>
    <?php }?>


   </select>
 <select name="hk" id="hk">
 <option value="0" selected="selected">0</option>
    <?php for($i=1;$i<=5;$i++){?>
                <option <?php if(isset($_POST["price_to"]) &&
($_POST["price_to"]==$i*100)) echo "selected";?> value="<?php
echo $i*100;?>"><?php echo ($i*100)." VND"?>
          </option>
    <?php }?>
   </select>
 <label>Ten hs
 <input value="<?php if(isset($_POST["henhs"])) echo
$_POST["tenhs"]; ?>" type="text" name="tenhs" id="tenhs" />
 </label>
 <input type="submit" name="button" id="button"
value="Submit" />
</form>
</body>
4. sanpham2.php
<body>

<div id="main_phim">
        <?php
        $id=$_POST["loaisp"];
        $price_from=$_POST["price_from"];
        $price_to=$_POST["price_to"];
        $mota=$_POST["mota"];
  ?>


  <?php
          include("dbcon.php");

  //can chep doan nay vao neu co lam
$sodong=9;


 $kq=mysql_query("select * from sanpham",$link);
$tongsotrang=ceil(mysql_num_rows($kq)/$sodong); //tong so
dong du lieu truy van
 //ceil lay tron


 if (!isset($_GET["p"]))
 { $p=1;
 }
 else
 {
   $p=intval($_GET["p"]); //intval chuyen chuoi thanh so
 }
 $x=($p-1)*$sodong;


  //chep den day

         if (substr($id,0,2)=="cl")
         {
               $idcl=substr($id,3,strlen($id)-3);
               $s="select * from sanpham,loaisp
               where sanpham.idLoai=loaisp.idLoai
               and idCL=$idcl and Gia between $price_from and
$price_to and mota like '%$mota%' limit $x, $sodong ";
         }
         else
         {
               $idloai=$id;
               $s="select * from sanpham where idLoai=$idloai
and Gia between $price_from and $price_to limit $x, $sodong ";
         }
         $table_sanpham=mysql_query($s,$link);
   ?>
  <?php while($d=mysql_fetch_array($table_sanpham)) { ?>
  <div>
  <img width="100" height="100" src="images/<?php echo
$d["UrlHinh"];?>">
      <div class="info">

     <p>IDLoai= <?php echo $d["idLoai"]; ?></p>
     <p>Gia= <?php echo $d["Gia"]; ?></p>
     <p>Mota= <?php echo $d["Mota"]; ?></p>
     </div>
 <a href="index.php?act=chitiet&masp=<?php echo
$d["MaSP"]; ?>"> Chitiet </a>
</div>

   <?php }?>
</div>

<p align="center">
<?php
//can chep doan nay vao neu co lam phan trang
for($i=1;$i<=$tongsotrang;$i++)
{ if ($i==$p)
   { echo $i."&nbsp;";
   }
   else
   {
 ?>
 <a href="index.php?p=<?php echo $i; ?>"><?php echo $i; ?></a>
<?php
   }
}
//chep den day
?>
</p>
</body>
5. sanpham.php
<body>

<div id="main_phim">
<?php
  $idloai=$_GET["idLoai"];
  include("dbcon.php");
  $sodong=9;


 $kq=mysql_query("select * from sanpham",$link);
 $tongsotrang=ceil(mysql_num_rows($kq)/$sodong); //tong so
dong du lieu truy van
 //ceil lay tron


 if (!isset($_GET["p"]))
 { $p=1;
 }
 else
 {
   $p=intval($_GET["p"]); //intval chuyen chuoi thanh so
}
 $x=($p-1)*$sodong;


  $query_sanpham="select * from sanpham limit $x, $sodong";
  $table_sanpham=mysql_query($query_sanpham,$link);
?>
 <?php while($d=mysql_fetch_array($table_sanpham)) { ?>
   <div>
   <img width="100" height="100" src="images/<?php echo
$d["UrlHinh"];?>">
      <div class="info">
      <?php echo $d["MaSP"];?><br />
      <?php echo $d["Gia"];?><br />
      </div>
    <a href="index.php?act=chitiet&masp=<?php echo
$d["MaSP"]; ?>"> Chitiet </a>
   </div>

    <?php }?>
</div>
<p align="center">
<?php
//can chep doan nay vao neu co lam phan trang
for($i=1;$i<=$tongsotrang;$i++)
{ if ($i==$p)
   { echo $i."&nbsp;";
   }
   else
   {
 ?>
 <a href="index.php?p=<?php echo $i; ?>"><?php echo $i; ?></a>
<?php
   }
}
//chep den day
?>
</p>
</body>


6. sdmenu.php
  <l i nk rel =" st yl esheet " t ype=" t ext / css" href =" sdmenu.css" / >
  <scri pt t ype="t ext / j avascri pt " src=" sdmenu.j s" >
           / ***********************************************
           * Sl ashdot Menu scri pt - By Di mX
* Submi t t ed t o Dynami c Dri ve DHT ML code li brary:
ht t p:/ /w w w .dynami cdri ve.com
                * Vi si t Dynami c Dri ve at ht t p:// w ww .dynami cdri ve. com/ f or f ul l source
code
                ***********************************************/
      </ scri pt >
      <scri pt t ype="t ext / j avascri pt " >
      / / <![C DAT A[
      var myMenu;
      w i ndow .onl oad = funct i on() {
                myMenu = new SDMenu (" my_menu" );
                myMenu.i ni t ();
      };
      // ]] >
      </ scri pt >

<body>
 <?php
  $link =mysql_connect("localhost","root","") or die("No
connection");
  mysql_select_db("banhang",$link);
  mysql_query("set names 'utf8'");

   $query_chungloaisp="select * from chungloaisp";
   $table_chungloaisp=mysql_query($query_chungloaisp,$link);
  ?>

  <div style="float: left" id="my_menu" class="sdmenu">
  <?php
while($chungloaisp=mysql_fetch_array($table_chungloaisp)) { ?>

        <div>
           <span><?php echo $chungloaisp['Ten']?></span>
           <?php $idCL=$chungloaisp['idCL'];
              $query_loaisp="select * from loaisp where
idCL=$idCL";
              $table_loaisp=mysql_query($query_loaisp,$link);
              while($loaisp=mysql_fetch_array($table_loaisp)) { ?
>
                 <a href="index.php?act=loaisp&idLoai=<?php
echo $loaisp["idLoai"];?>"><?php echo $loaisp['Ten'];?></a>
           <?php }?>
        </div>
      <?php } ?>
   </div>
  </body>
7. hanghoa.php
<body>
<p align="center">Danh Sach Hang Hoa</p>
<table width="400" border="1" align="center" cellpadding="0"
cellspacing="0">
 <tr>
   <td width="200"><div align="center">ten hang hoa</div></td>
   <td width="100"><div align="center">gia</div></td>
   <td width="100"><div align="center">hinh</div></td>
 </tr>
 <?php
 require_once("dbcon.php"); //include
 $sodong=5;
 $kq=mysql_query("select * from hanghoa",$link);
 $tongsotrang=ceil(mysql_num_rows($kq)/$sodong); //tong so
dong du lieu truy van
 //ceil lay tron

 if (!isset($_GET["p"]))
 { $p=1;
 }
 else
 {
   $p=intval($_GET["p"]); //intval chuyen chuoi thanh so
 }
 $x=($p-1)*$sodong;
 $s="select * from hanghoa limit $x,$sodong";
 $kq=mysql_query($s,$link);
 while($dong=mysql_fetch_array($kq))
 {
 ?>
 <tr>
   <td width="200"> <div align="center"> <?php echo
$dong["Tenhang"];?> </div></td>
   <td width="100"> <div align="center"> <?php echo
$dong["gia"];?> </div></td>
   <td width="100"> <div align="center"> <img width="50"
height="50" src="hinh/<?php echo $dong["hinh"]; ?>"
/></div></td>
 </tr>
 <?php } ?>
</table>
<p align="center">
<?php
for($i=1;$i<=$tongsotrang;$i++)
{ if ($i==$p)
  { echo $i."&nbsp;";
  }
else
  {
 ?>
 <a href="hanghoa.php?p=<?php echo $i; ?>"><?php echo $i; ?
></a>
<?php
  }
}
?>
</p>
</body>

8. hanghoa_nhom.php
<body>
<p align="center">Danh Sach Hang Hoa</p>
<table width="400" border="1" align="center" cellpadding="0"
cellspacing="0">
 <tr>
   <td width="200"><div align="center">ten hang hoa</div></td>
   <td width="100"><div align="center">gia</div></td>
   <td width="100"><div align="center">hinh</div></td>
 </tr>
 <?php
 require_once("dbcon.php");
 $sodong=3;
 $manhom=$_GET["m"];

 if(!isset($_GET["tst"])) {

 $kq=mysql_query("select * from hanghoa where
manhom='$manhom'",$link);
 $tongsotrang=ceil(mysql_num_rows($kq)/$sodong);
 }
 else
 {
 $tongsotrang=intval($_GET["tst"]);
 }
 if (!isset($_GET["p"]))
 { $p=1;
 }
 else
 {
   $p=intval($_GET["p"]);
 }
 $x=($p-1)*$sodong;
$s="select * from hanghoa where manhom='$manhom' limit $x,
$sodong";
  $kq=mysql_query($s,$link);
  while($dong=mysql_fetch_array($kq))
  {
  ?>
  <tr>
    <td width="200"><div align="center"><?php echo
$dong["tenhang"]; ?></div></td>
    <td width="100"><div align="center"><?php echo
$dong["gia"]; ?></div></td>
    <td width="100"><div align="center"><img width="50"
height="50" src="hinh/<?php echo $dong["hinh"]; ?>"
/></div></td>
  </tr>
  <?php } ?>
</table>
<p align="center">
<?php
for($i=1;$i<=$tongsotrang;$i++)
{ if ($i==$p)
   { echo $i."&nbsp;";
   }
   else
   {
 ?>
 <a href="hanghoa_nhom.php?p=<?php echo $i; ?>&tst=<?php
echo $tongsotrang; ?>&m=<?php echo $_GET["m"]; ?>"><?php
echo $i; ?></a>
<?php
   }
}
?>
</p>
</body>
9. nhomhang.php
<body>
<table width="100" border="1" align="center" cellpadding="0"
cellspacing="0">
  <tr>
    <td><div align="center">nhom hang</div></td>
  </tr>
  <?php
  require_once("dbcon.php");
  $kq=mysql_query("select * from nhomhang",$link);
while($dong=mysql_fetch_array($kq))
 {?>
 <tr>
  <td><div align="center"><a href="hanghoa_nhom.php?m=<?
php echo $dong["manhom"]; ?>"><?php echo $dong["tennhom"]; ?
></a></div></td>
 </tr>
 <?php } ?>


</table>
</body>

More Related Content

What's hot

R57shell
R57shellR57shell
R57shellady36
 
Why Hacking WordPress Search Isn't Some Big Scary Thing
Why Hacking WordPress Search Isn't Some Big Scary ThingWhy Hacking WordPress Search Isn't Some Big Scary Thing
Why Hacking WordPress Search Isn't Some Big Scary ThingChris Reynolds
 
Open Source Search: An Analysis
Open Source Search: An AnalysisOpen Source Search: An Analysis
Open Source Search: An AnalysisJustin Finkelstein
 
PHP tips and tricks
PHP tips and tricks PHP tips and tricks
PHP tips and tricks Damien Seguy
 
London XQuery Meetup: Querying the World (Web Scraping)
London XQuery Meetup: Querying the World (Web Scraping)London XQuery Meetup: Querying the World (Web Scraping)
London XQuery Meetup: Querying the World (Web Scraping)Dennis Knochenwefel
 
HirshHorn theme: how I created it
HirshHorn theme: how I created itHirshHorn theme: how I created it
HirshHorn theme: how I created itPaul Bearne
 
https://www.facebook.com/valdyna.monna?fref=ts
https://www.facebook.com/valdyna.monna?fref=tshttps://www.facebook.com/valdyna.monna?fref=ts
https://www.facebook.com/valdyna.monna?fref=tsArif Alexi
 
8時間耐久CakePHP2 勉強会
8時間耐久CakePHP2 勉強会8時間耐久CakePHP2 勉強会
8時間耐久CakePHP2 勉強会Yusuke Ando
 
20160227 Granma
20160227 Granma20160227 Granma
20160227 GranmaSharon Liu
 
Propel sfugmd
Propel sfugmdPropel sfugmd
Propel sfugmdiKlaus
 
WordPress Security: Be a Superhero - WordCamp Raleigh - May 2011
WordPress Security: Be a Superhero - WordCamp Raleigh - May 2011WordPress Security: Be a Superhero - WordCamp Raleigh - May 2011
WordPress Security: Be a Superhero - WordCamp Raleigh - May 2011John Ford
 
Mongoose v3 :: The Future is Bright
Mongoose v3 :: The Future is BrightMongoose v3 :: The Future is Bright
Mongoose v3 :: The Future is Brightaaronheckmann
 
jQuery%20on%20Rails%20Presentation
jQuery%20on%20Rails%20PresentationjQuery%20on%20Rails%20Presentation
jQuery%20on%20Rails%20Presentationguestcf600a
 

What's hot (19)

R57shell
R57shellR57shell
R57shell
 
Why Hacking WordPress Search Isn't Some Big Scary Thing
Why Hacking WordPress Search Isn't Some Big Scary ThingWhy Hacking WordPress Search Isn't Some Big Scary Thing
Why Hacking WordPress Search Isn't Some Big Scary Thing
 
PHP Tutorial (funtion)
PHP Tutorial (funtion)PHP Tutorial (funtion)
PHP Tutorial (funtion)
 
Daily notes
Daily notesDaily notes
Daily notes
 
Open Source Search: An Analysis
Open Source Search: An AnalysisOpen Source Search: An Analysis
Open Source Search: An Analysis
 
PHP tips and tricks
PHP tips and tricks PHP tips and tricks
PHP tips and tricks
 
Send.php
Send.phpSend.php
Send.php
 
London XQuery Meetup: Querying the World (Web Scraping)
London XQuery Meetup: Querying the World (Web Scraping)London XQuery Meetup: Querying the World (Web Scraping)
London XQuery Meetup: Querying the World (Web Scraping)
 
HirshHorn theme: how I created it
HirshHorn theme: how I created itHirshHorn theme: how I created it
HirshHorn theme: how I created it
 
https://www.facebook.com/valdyna.monna?fref=ts
https://www.facebook.com/valdyna.monna?fref=tshttps://www.facebook.com/valdyna.monna?fref=ts
https://www.facebook.com/valdyna.monna?fref=ts
 
8時間耐久CakePHP2 勉強会
8時間耐久CakePHP2 勉強会8時間耐久CakePHP2 勉強会
8時間耐久CakePHP2 勉強会
 
20160227 Granma
20160227 Granma20160227 Granma
20160227 Granma
 
Propel sfugmd
Propel sfugmdPropel sfugmd
Propel sfugmd
 
Potential Friend Finder
Potential Friend FinderPotential Friend Finder
Potential Friend Finder
 
R57.Php
R57.PhpR57.Php
R57.Php
 
Nop2
Nop2Nop2
Nop2
 
WordPress Security: Be a Superhero - WordCamp Raleigh - May 2011
WordPress Security: Be a Superhero - WordCamp Raleigh - May 2011WordPress Security: Be a Superhero - WordCamp Raleigh - May 2011
WordPress Security: Be a Superhero - WordCamp Raleigh - May 2011
 
Mongoose v3 :: The Future is Bright
Mongoose v3 :: The Future is BrightMongoose v3 :: The Future is Bright
Mongoose v3 :: The Future is Bright
 
jQuery%20on%20Rails%20Presentation
jQuery%20on%20Rails%20PresentationjQuery%20on%20Rails%20Presentation
jQuery%20on%20Rails%20Presentation
 

Viewers also liked

Viewers also liked (7)

Assistive technology
Assistive technologyAssistive technology
Assistive technology
 
Havij dork
Havij dorkHavij dork
Havij dork
 
Google Dorks
Google DorksGoogle Dorks
Google Dorks
 
Dr.Repi
Dr.Repi Dr.Repi
Dr.Repi
 
Google Dorks and SQL Injection
Google Dorks and SQL InjectionGoogle Dorks and SQL Injection
Google Dorks and SQL Injection
 
Footprints
FootprintsFootprints
Footprints
 
Web-servers & Application Hacking
Web-servers & Application HackingWeb-servers & Application Hacking
Web-servers & Application Hacking
 

Similar to Php

Php update and delet operation
Php update and delet operationPhp update and delet operation
Php update and delet operationsyeda zoya mehdi
 
C A S Sample Php
C A S Sample PhpC A S Sample Php
C A S Sample PhpJH Lee
 
Latihan form login
Latihan form loginLatihan form login
Latihan form loginEdy Sinaga
 
Ex[1].3 php db connectivity
Ex[1].3 php db connectivityEx[1].3 php db connectivity
Ex[1].3 php db connectivityMouli Chandira
 
Drupal Development (Part 2)
Drupal Development (Part 2)Drupal Development (Part 2)
Drupal Development (Part 2)Jeff Eaton
 
Virtual Madness @ Etsy
Virtual Madness @ EtsyVirtual Madness @ Etsy
Virtual Madness @ EtsyNishan Subedi
 
The History of PHPersistence
The History of PHPersistenceThe History of PHPersistence
The History of PHPersistenceHugo Hamon
 
Php 102: Out with the Bad, In with the Good
Php 102: Out with the Bad, In with the GoodPhp 102: Out with the Bad, In with the Good
Php 102: Out with the Bad, In with the GoodJeremy Kendall
 
Unit testing with zend framework tek11
Unit testing with zend framework tek11Unit testing with zend framework tek11
Unit testing with zend framework tek11Michelangelo van Dam
 
Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011
Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011
Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011Masahiro Nagano
 

Similar to Php (20)

Php (1)
Php (1)Php (1)
Php (1)
 
Php update and delet operation
Php update and delet operationPhp update and delet operation
Php update and delet operation
 
C A S Sample Php
C A S Sample PhpC A S Sample Php
C A S Sample Php
 
Latihan form login
Latihan form loginLatihan form login
Latihan form login
 
Zero to SOLID
Zero to SOLIDZero to SOLID
Zero to SOLID
 
Coding part
Coding partCoding part
Coding part
 
Separation of concerns - DPC12
Separation of concerns - DPC12Separation of concerns - DPC12
Separation of concerns - DPC12
 
Ex[1].3 php db connectivity
Ex[1].3 php db connectivityEx[1].3 php db connectivity
Ex[1].3 php db connectivity
 
Add loop shortcode
Add loop shortcodeAdd loop shortcode
Add loop shortcode
 
Drupal Development (Part 2)
Drupal Development (Part 2)Drupal Development (Part 2)
Drupal Development (Part 2)
 
My shell
My shellMy shell
My shell
 
Virtual Madness @ Etsy
Virtual Madness @ EtsyVirtual Madness @ Etsy
Virtual Madness @ Etsy
 
The History of PHPersistence
The History of PHPersistenceThe History of PHPersistence
The History of PHPersistence
 
Database api
Database apiDatabase api
Database api
 
wget.pl
wget.plwget.pl
wget.pl
 
PHP POWERPOINT SLIDES
PHP POWERPOINT SLIDESPHP POWERPOINT SLIDES
PHP POWERPOINT SLIDES
 
Php 102: Out with the Bad, In with the Good
Php 102: Out with the Bad, In with the GoodPhp 102: Out with the Bad, In with the Good
Php 102: Out with the Bad, In with the Good
 
Php 101: PDO
Php 101: PDOPhp 101: PDO
Php 101: PDO
 
Unit testing with zend framework tek11
Unit testing with zend framework tek11Unit testing with zend framework tek11
Unit testing with zend framework tek11
 
Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011
Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011
Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011
 

Php

  • 1. 1. dbcon.php <?php $link =mysql_connect("localhost","root","") or die("No connection"); mysql_select_db("banhang",$link); mysql_query("set names 'utf8'"); ?> 2. index.php <body> <div id="container"> <div id="header"> <?php include ("header.php"); ?> </div> <div id="loaisp"> <?php include ("loaisp2.php"); ?> </div> <div id="content"> <div id="sdmenu"> <?php include ("sdmenu/sdmenu.php"); ?> </div> <div id="gsp"> <?php if (!isset($_GET["act"])) { include ("gsp.php");} else { switch($_GET["act"]) { case "loaisp": include ("sanpham.php"); break; case "tim": include ("sanpham2.php"); break; case "chitiet": include ("ctsp.php"); break; } } ?> </div> </div> <div id="footer"> <?php include ("footer.php"); ?> </div> </div> </body>
  • 2. 3. gsp.php <scri pt t ype="t ext / j avascri pt " src=" j query.mi n.j s" ></ scri pt > <scri pt t ype="t ext / j avascri pt " > $(docu ment ).read y(f unct i on (){ $(' # mai n_phi m>di v' ).ea ch(f unct i on (){ var $i mg=$ (t hi s).chi l dren(). at t r (' src' ); / / al ert ($i mg) var $t i t l e=$(t hi s ).f i nd(' p.nam e' ).t ext () / / al ert ($t i t l e) $(t hi s ).f i nd(' di v.i nf o' ).pr epend(' <i mg src=' +$i mg+' / ><p cl ass=" t i tl e" >' + $t i tl e+' </ p>' ) }) $(' # mai n_phi m>di v>i mg' ).ho ver (f unct i on (){ $(t hi s ).parent ().f i nd (' di v.i nf o' ).show () },f unct i on(){ $(t hi s ).parent ().f i nd (' di v.i nf o' ).hi de() }).mous emov e(f unct i on (e ){ var $X=e.cl i ent X var $Y =e.cl i entY $(t hi s ).parent ().f i nd (' di v.i nf o' ).css ({' l ef t ' :$X+20,' t op' :$Y }) }).cl i c k(f unct i on (){ var $l i nk=$ (t hi s).par ent (). f i nd(' a' ).at t r(' href ' ) w i ndow .open ($l i nk,' ' ) }) }) </ scri pt > <?php include("dbcon.php"); //can chep doan nay vao neu co lam $sodong=9; $kq=mysql_query("select * from sanpham",$link); $tongsotrang=ceil(mysql_num_rows($kq)/$sodong); //tong so dong du lieu truy van //ceil lay tron if (!isset($_GET["p"])) { $p=1; } else { $p=intval($_GET["p"]); //intval chuyen chuoi thanh so } $x=($p-1)*$sodong; $query_sanpham="select * from sanpham limit $x, $sodong";
  • 3. //chep den day $table_sanpham=mysql_query($query_sanpham,$link); ?> <div id="main_phim"> <?php while($d=mysql_fetch_array($table_sanpham)) { ?> <div> <img width="100" height="100" src="images/<?php echo $d["UrlHinh"];?>"> <div class="info"> <p>Gia=<?php echo $d["Gia"]; ?></p> <p>MaSP=<?php echo $d["MaSP"]; ?></p> </div> <a href="index.php?act=chitiet&masp=<?php echo $d["MaSP"]; ?>"> Chitiet </a> </div> <?php } ?> </div> <p align="center"> <?php //can chep doan nay vao neu co lam phan trang for($i=1;$i<=$tongsotrang;$i++) { if ($i==$p) { echo $i."&nbsp;"; } else { ?> <a href="index.php?p=<?php echo $i; ?>"><?php echo $i; ?></a> <?php } } //chep den day ?> </p> </body>
  • 4. 4. loaisp2.php <body> <?php $link =mysql_connect("localhost","root","") or die("No connection"); mysql_select_db("qlhsthpt",$link); mysql_query("set names 'utf8'"); $query_chungloaisp="select * from hocsinh"; $table_chungloaisp=mysql_query($query_chungloaisp,$link); ?> <form id="form1" name="form1" method="post" action="index.php?act=tim"> <select name="truong" id="list"> <?php while($chungloaisp=mysql_fetch_array($table_chungloaisp)) { ?> <option <?php if(isset($_POST["loaisp"]) && ($_POST["loaisp"]=="cl-".$chungloaisp["idCL"])) echo "selected";?> value="cl-<?php echo $chungloaisp['idCL']; ?>" class="menu_cap1"><?php echo $chungloaisp['Ten']?> </option> <?php $idCL=$chungloaisp['idCL']; $query_loaisp="select * from loaisp where idCL=$idCL"; $table_loaisp=mysql_query($query_loaisp, $link); while($loaisp=mysql_fetch_array($table_loaisp)) { ?> <option <?php if(isset($_POST["loaisp"]) && ($_POST["loaisp"]==$loaisp["idLoai"])) echo "selected";?> class="menu_cap2" value="<?php echo $loaisp['idLoai'];? >">&nbsp;&nbsp;&nbsp;<?php echo $loaisp['Ten']; ?> </option> <?php }?> <?php } ?> </select> <select name="mon" id="mon"> <option value="0" selected="selected">0</option> <?php for($i=1;$i<=5;$i++){?>
  • 5. <option <?php if(isset($_POST["price_from"]) && ($_POST["price_from"]== $i*100)) echo "selected";?> value="<? php echo $i*100;?>"><?php echo ($i*100)." VND"?> </option> <?php }?> </select> <select name="hk" id="hk"> <option value="0" selected="selected">0</option> <?php for($i=1;$i<=5;$i++){?> <option <?php if(isset($_POST["price_to"]) && ($_POST["price_to"]==$i*100)) echo "selected";?> value="<?php echo $i*100;?>"><?php echo ($i*100)." VND"?> </option> <?php }?> </select> <label>Ten hs <input value="<?php if(isset($_POST["henhs"])) echo $_POST["tenhs"]; ?>" type="text" name="tenhs" id="tenhs" /> </label> <input type="submit" name="button" id="button" value="Submit" /> </form> </body> 4. sanpham2.php <body> <div id="main_phim"> <?php $id=$_POST["loaisp"]; $price_from=$_POST["price_from"]; $price_to=$_POST["price_to"]; $mota=$_POST["mota"]; ?> <?php include("dbcon.php"); //can chep doan nay vao neu co lam $sodong=9; $kq=mysql_query("select * from sanpham",$link);
  • 6. $tongsotrang=ceil(mysql_num_rows($kq)/$sodong); //tong so dong du lieu truy van //ceil lay tron if (!isset($_GET["p"])) { $p=1; } else { $p=intval($_GET["p"]); //intval chuyen chuoi thanh so } $x=($p-1)*$sodong; //chep den day if (substr($id,0,2)=="cl") { $idcl=substr($id,3,strlen($id)-3); $s="select * from sanpham,loaisp where sanpham.idLoai=loaisp.idLoai and idCL=$idcl and Gia between $price_from and $price_to and mota like '%$mota%' limit $x, $sodong "; } else { $idloai=$id; $s="select * from sanpham where idLoai=$idloai and Gia between $price_from and $price_to limit $x, $sodong "; } $table_sanpham=mysql_query($s,$link); ?> <?php while($d=mysql_fetch_array($table_sanpham)) { ?> <div> <img width="100" height="100" src="images/<?php echo $d["UrlHinh"];?>"> <div class="info"> <p>IDLoai= <?php echo $d["idLoai"]; ?></p> <p>Gia= <?php echo $d["Gia"]; ?></p> <p>Mota= <?php echo $d["Mota"]; ?></p> </div> <a href="index.php?act=chitiet&masp=<?php echo $d["MaSP"]; ?>"> Chitiet </a>
  • 7. </div> <?php }?> </div> <p align="center"> <?php //can chep doan nay vao neu co lam phan trang for($i=1;$i<=$tongsotrang;$i++) { if ($i==$p) { echo $i."&nbsp;"; } else { ?> <a href="index.php?p=<?php echo $i; ?>"><?php echo $i; ?></a> <?php } } //chep den day ?> </p> </body> 5. sanpham.php <body> <div id="main_phim"> <?php $idloai=$_GET["idLoai"]; include("dbcon.php"); $sodong=9; $kq=mysql_query("select * from sanpham",$link); $tongsotrang=ceil(mysql_num_rows($kq)/$sodong); //tong so dong du lieu truy van //ceil lay tron if (!isset($_GET["p"])) { $p=1; } else { $p=intval($_GET["p"]); //intval chuyen chuoi thanh so
  • 8. } $x=($p-1)*$sodong; $query_sanpham="select * from sanpham limit $x, $sodong"; $table_sanpham=mysql_query($query_sanpham,$link); ?> <?php while($d=mysql_fetch_array($table_sanpham)) { ?> <div> <img width="100" height="100" src="images/<?php echo $d["UrlHinh"];?>"> <div class="info"> <?php echo $d["MaSP"];?><br /> <?php echo $d["Gia"];?><br /> </div> <a href="index.php?act=chitiet&masp=<?php echo $d["MaSP"]; ?>"> Chitiet </a> </div> <?php }?> </div> <p align="center"> <?php //can chep doan nay vao neu co lam phan trang for($i=1;$i<=$tongsotrang;$i++) { if ($i==$p) { echo $i."&nbsp;"; } else { ?> <a href="index.php?p=<?php echo $i; ?>"><?php echo $i; ?></a> <?php } } //chep den day ?> </p> </body> 6. sdmenu.php <l i nk rel =" st yl esheet " t ype=" t ext / css" href =" sdmenu.css" / > <scri pt t ype="t ext / j avascri pt " src=" sdmenu.j s" > / *********************************************** * Sl ashdot Menu scri pt - By Di mX
  • 9. * Submi t t ed t o Dynami c Dri ve DHT ML code li brary: ht t p:/ /w w w .dynami cdri ve.com * Vi si t Dynami c Dri ve at ht t p:// w ww .dynami cdri ve. com/ f or f ul l source code ***********************************************/ </ scri pt > <scri pt t ype="t ext / j avascri pt " > / / <![C DAT A[ var myMenu; w i ndow .onl oad = funct i on() { myMenu = new SDMenu (" my_menu" ); myMenu.i ni t (); }; // ]] > </ scri pt > <body> <?php $link =mysql_connect("localhost","root","") or die("No connection"); mysql_select_db("banhang",$link); mysql_query("set names 'utf8'"); $query_chungloaisp="select * from chungloaisp"; $table_chungloaisp=mysql_query($query_chungloaisp,$link); ?> <div style="float: left" id="my_menu" class="sdmenu"> <?php while($chungloaisp=mysql_fetch_array($table_chungloaisp)) { ?> <div> <span><?php echo $chungloaisp['Ten']?></span> <?php $idCL=$chungloaisp['idCL']; $query_loaisp="select * from loaisp where idCL=$idCL"; $table_loaisp=mysql_query($query_loaisp,$link); while($loaisp=mysql_fetch_array($table_loaisp)) { ? > <a href="index.php?act=loaisp&idLoai=<?php echo $loaisp["idLoai"];?>"><?php echo $loaisp['Ten'];?></a> <?php }?> </div> <?php } ?> </div> </body> 7. hanghoa.php <body> <p align="center">Danh Sach Hang Hoa</p>
  • 10. <table width="400" border="1" align="center" cellpadding="0" cellspacing="0"> <tr> <td width="200"><div align="center">ten hang hoa</div></td> <td width="100"><div align="center">gia</div></td> <td width="100"><div align="center">hinh</div></td> </tr> <?php require_once("dbcon.php"); //include $sodong=5; $kq=mysql_query("select * from hanghoa",$link); $tongsotrang=ceil(mysql_num_rows($kq)/$sodong); //tong so dong du lieu truy van //ceil lay tron if (!isset($_GET["p"])) { $p=1; } else { $p=intval($_GET["p"]); //intval chuyen chuoi thanh so } $x=($p-1)*$sodong; $s="select * from hanghoa limit $x,$sodong"; $kq=mysql_query($s,$link); while($dong=mysql_fetch_array($kq)) { ?> <tr> <td width="200"> <div align="center"> <?php echo $dong["Tenhang"];?> </div></td> <td width="100"> <div align="center"> <?php echo $dong["gia"];?> </div></td> <td width="100"> <div align="center"> <img width="50" height="50" src="hinh/<?php echo $dong["hinh"]; ?>" /></div></td> </tr> <?php } ?> </table> <p align="center"> <?php for($i=1;$i<=$tongsotrang;$i++) { if ($i==$p) { echo $i."&nbsp;"; }
  • 11. else { ?> <a href="hanghoa.php?p=<?php echo $i; ?>"><?php echo $i; ? ></a> <?php } } ?> </p> </body> 8. hanghoa_nhom.php <body> <p align="center">Danh Sach Hang Hoa</p> <table width="400" border="1" align="center" cellpadding="0" cellspacing="0"> <tr> <td width="200"><div align="center">ten hang hoa</div></td> <td width="100"><div align="center">gia</div></td> <td width="100"><div align="center">hinh</div></td> </tr> <?php require_once("dbcon.php"); $sodong=3; $manhom=$_GET["m"]; if(!isset($_GET["tst"])) { $kq=mysql_query("select * from hanghoa where manhom='$manhom'",$link); $tongsotrang=ceil(mysql_num_rows($kq)/$sodong); } else { $tongsotrang=intval($_GET["tst"]); } if (!isset($_GET["p"])) { $p=1; } else { $p=intval($_GET["p"]); } $x=($p-1)*$sodong;
  • 12. $s="select * from hanghoa where manhom='$manhom' limit $x, $sodong"; $kq=mysql_query($s,$link); while($dong=mysql_fetch_array($kq)) { ?> <tr> <td width="200"><div align="center"><?php echo $dong["tenhang"]; ?></div></td> <td width="100"><div align="center"><?php echo $dong["gia"]; ?></div></td> <td width="100"><div align="center"><img width="50" height="50" src="hinh/<?php echo $dong["hinh"]; ?>" /></div></td> </tr> <?php } ?> </table> <p align="center"> <?php for($i=1;$i<=$tongsotrang;$i++) { if ($i==$p) { echo $i."&nbsp;"; } else { ?> <a href="hanghoa_nhom.php?p=<?php echo $i; ?>&tst=<?php echo $tongsotrang; ?>&m=<?php echo $_GET["m"]; ?>"><?php echo $i; ?></a> <?php } } ?> </p> </body> 9. nhomhang.php <body> <table width="100" border="1" align="center" cellpadding="0" cellspacing="0"> <tr> <td><div align="center">nhom hang</div></td> </tr> <?php require_once("dbcon.php"); $kq=mysql_query("select * from nhomhang",$link);
  • 13. while($dong=mysql_fetch_array($kq)) {?> <tr> <td><div align="center"><a href="hanghoa_nhom.php?m=<? php echo $dong["manhom"]; ?>"><?php echo $dong["tennhom"]; ? ></a></div></td> </tr> <?php } ?> </table> </body>