´ÙÀ½ ÀÌÀü Â÷·Ê

15. ¼îÇÎ ¸ô ¸¸µé±â

¼îÇÎ ¸ôÀº ƯÁ¤ »óÇ°À» ±¸¸ÅÀÚµéÀÌ À¥ »ó¿¡¼­ ½ÇÁ¦·Î ¼îÇÎÀ» ÇÏ´Â °Í°ú °°ÀÌ ±¸Çö ÇÏ´Â °ÍÀÌ Áß¿ä ÇÕ´Ï´Ù.    ¸ÕÀú ±¸¸ÅÀÚµéÀº ÇØ´ç »çÀÌÆ®ÀÇ °èÁ¤ÀÌ ÀÖ¾î¾ß ÇÏ°í ½ÇÁ¦ ¼îÇÎÀ» ÇÒ ¶§¿Í °°ÀÌ ¹Ù±¸´Ï Ç׸ñÀ» ¸¸µì´Ï´Ù.    ¹Ù±¸´Ï´Â ±¸¸ÅÀÚÀÇ ¼±Åà ¹°°ÇÀ» Àӽ÷ΠÀúÀå Çϸç ÁÖ¹® ¶§ ¼±º° ÇÒ ¼ö ÀÖ½À´Ï´Ù.    ÁÖ¹®¼­ÀÇ °æ¿ì ȸ¿ø °¡ÀÔ ¶§ ÀÛ¼ºÇÑ Á¤º¸¸¦ ÀÌ¿ëÇØ ÀúÀå µÇ¸ç ¹ÞÀ» ÁÖ¼Ò´Â º¯°æ °¡´É ÇØ¾ß ÇÕ´Ï´Ù.    ±×¸®°í,ÇØ´ç »çÀÌÆ®ÀÇ ¸ÞÀÎ È­¸é¿¡ ƯÁ¤ »óÇ°À¸·ÎÀÇ À̵¿ ¸µÅ©°¡ Á¸Àç ÇÕ´Ï´Ù.

±×¸². 15-1 ¼îÇÎ ¸ô À½¾Ç Ç׸ñ

15.1 ¼îÇÎ ¸ô Å×ÀÌºí ¸¸µé±â

    ¼îÇÎ ¸ô Å×À̺íÀº ÃÑ 3°³ÀÇ Å×À̺í·Î ±¸¼º µË´Ï´Ù.
    Â÷·Ê·Î pduct(Á¦Ç°ÀÇ Á¤º¸ ÀúÀå) , shopuser(±¸¸ÅÀÚ°¡ ¼±ÅÃÇÑ ¹°Ç° Á¤º¸) , sub(ÁÖ¹®¼­) ÀÔ´Ï´Ù. 
    Shopuser Å×À̺íÀº ¹Ù±¸´Ï ¿ªÇÒÀ» Çϸç ÇØ´ç Á¦Ç°ÀÇ °¡°Ý°ú ¼ö·® µîÀÇ Á¤º¸¸¦ ÀúÀå ÇÕ´Ï´Ù. °æ¸Å¿Í ÀÚ·á½Ç
    °Ô½ÃÆÇ°ú´Â ´Þ¸® ¼îÇθô Å×À̺íÀº admin¿µ¿ª¿¡¼­ »õ·Ó°Ô ¸¸µå´Â ±â´ÉÀÌ ¾øÀ¸¸ç Á÷Á¢ ¸¸µé¾î Áà¾ß ÇÕ´Ï´Ù.
    º¸´Ù ´Ù¾çÇÏ°í admin Áß½ÉÀÇ ¼îÇÎ ¸ôÀ» ±¸¼º Çϱâ À§Çؼ­´Â »óÇ°ÀÇ °¡°Ý°ú ±¸¸Å ´Ü°¡ , ¹°Ç° ±¸ÀԽà ¸¶Áøµî
    »óÇ° ÇϳªÀÇ Á¤º¸¸¦ °ü¸®ÀÚ Ãø¸é¿¡¼­ ±¸¼º ÇØ¾ß ÇÕ´Ï´Ù.
    ¹°·Ð °¢ ¹°Ç°ÀÇ ºê¶ó¿ìÀú Ãâ·Â°ú °ü·ÃµÈ ÀÏ·ÃÀÇ ÀÛ¾÷ ¶ÇÇÑ °£´ÜÇÏ°Ô °ü¸® ÇÒ ¼ö ÀÖ¾î¾ß ÇÕ´Ï´Ù.

µ¥ÀÌÅÍ º£À̽º ¸¸µé±â

    mysql>create databases shop ;

    ¼îÇÎ ¸ô¿¡ »ç¿ëÇÒ Å×À̺íÀ» »ý¼º Çϱâ À§ÇÑ µ¥ÀÌÅÍ º£À̽º¸¦ ¸¸µì´Ï´Ù.
    Âü°í·Î ÀÌÀü ÀÚ·á½Ç°ú °æ¸Å °Ô½ÃÆÇ¿¡ »ç¿ëÇÑ µ¥ÀÌÅÍ º£À̽º´Â libchal Çϳª·Î »ç¿ë Çß¾ú½À´Ï´Ù. 

Å×ÀÌºí ¸¸µé±â

    ./mysql -u root -p shop < shop.sql 

    CDÀÇ shop.sql ÆÄÀÏÀ» ÀÌ¿ëÇؼ­ ¼îÇÎ ¸ô¿¡ »ç¿ëÇÒ 3°³ÀÇ Å×À̺íÀ» »ý¼º ÇÕ´Ï´Ù.
    »õ·Î¿î Çʵå¿Í ·¹Äڵ带 Ãß°¡ , ¼öÁ¤ Çϱâ À§Çؼ­ ÀÌ ÆÄÀÏÀ» »ç¿ë ÇÏ´Â ¹æ¹ýµµ ÀÖ½À´Ï´Ù.

±×¸². 15-2 shop.sql

Å×ÀÌºí ±¸¼º ÀÎÀÚ

    ¼îÇÎ ¸ô Å×À̺íÀº ÃÑ 3°³ ÀÌ¸ç ½ºÅ©¸³Æ® ÆÄÀÏÀº 2°³·Î ÀÌ·ç¾î Áý´Ï´Ù.
    Å×À̺íÀº »óÇ°ÀÇ Á¤º¸¸¦ ÀúÀåÇÏ´Â Å×À̺í°ú ¼îÇÎÇÑ ¹°°ÇÀ» ÀúÀåÇÏ´Â Å×À̺í, ÁÖ¹®¼­ Å×À̺í·Î ÀÌ·ç¾î Áý´Ï´Ù.

»óÇ°ÀÇ Á¤º¸¸¦ ÀúÀåÇÏ´Â Å×À̺í(pduct)

    »óÇ°ÀÇ À̹ÌÁö¿Í ¼³¸í °¡°Ý µîÀ» ÀúÀå ÇÕ´Ï´Ù.

    image - BLOB ŸÀÔ ÀÌ¸ç °ü¸®ÀÚ°¡ µî·ÏÇÑ À̹ÌÁö¸¦ ¹ÙÀ̳ʸ® ÇüÅ·ΠÀúÀå ÇÕ´Ï´Ù.
    price - »óÇ° °¡°ÝÀ» ÀúÀåÇÕ´Ï´Ù.
    pdname - »óÇ°ÀÇ À̸§À» ÀúÀåÇÕ´Ï´Ù.
    cont - »óÇ°ÀÇ ¼³¸íÀ» ÀúÀåÇÕ´Ï´Ù.
    sel - »óÇ°ÀÇ Á¾¸ñ Äڵ带 ÀúÀåÇÕ´Ï´Ù. Á¾¸ñ ÄÚµå´Â °ü¸®ÀÚ°¡ »óÇ°À» ºÐ·ùÇϱâ À§ÇØ ÀÓÀÇ·Î ºÎ¿©ÇÏ´Â ¼ýÀÚÀÔ´Ï´Ù.

¼±ÅÃÇÑ »óÇ°À» ÀúÀå ÇÏ´Â Å×À̺í(shopuser)

    ±¸¸ÅÀÚ°¡ ¼îÇÎÀ» Çϸ鼭 ¼±ÅÃÇÑ ¹°°ÇÀ» º¼ ¼ö ÀÖ´Â Å×À̺íÀÌ°í, ÀÏ¸í ¹Ù±¸´Ï¶ó°í ÇÕ´Ï´Ù.

    user - »çÀÌÆ® ·Î±×ÀÎ ¶§ »ç¿ëÇÑ ID ¼¼¼ÇÀ» ÀúÀåÇÕ´Ï´Ù.
    pduct - ¼±ÅÃÇÑ »óÇ° À̸§À» ÀúÀåÇÕ´Ï´Ù.
    num - ¼±ÅÃÇÑ »óÇ°ÀÇ ¼ö·®À» ÀúÀåÇÕ´Ï´Ù.
    price - »óÇ°ÀÇ °¡°ÝÀ» ÀúÀåÇÕ´Ï´Ù.
    bprice - »óÇ°ÀÇ ´Ü°¡¸¦ ÀúÀåÇÕ´Ï´Ù.

»óÇ° ÁÖ¹®À» ÀúÀå ÇÏ´Â Å×À̺í(sub)

    ±¸¸ÅÀÚ°¡ »óÇ°À» ¹Ù±¸´Ï¿¡ ´ãÀº ÈÄ ÀÌ°ÍÀ» ÁÖ¹®Çϱâ À§ÇØ ÀÛ¼ºÇÑ ÁÖ¹®¼­ÀÇ ³»¿ëÀ» ÀúÀå ÇÕ´Ï´Ù.
    ÀÌ°ÍÀº °¢ ±¸¸ÅÀÚÀÇ ID ¼¼¼ÇÀ» ÀÌ¿ëÇÏ´Â ¹æ¹ýÀ̸ç, °¢ ±¸¸ÅÀÚÀÇ ÁÖ¹® ÇöȲÀ» ¸¸µé±â À§ÇØ ÀÌ Å×À̺íÀ»
    »ç¿ëÇÒ ¼ö ÀÖ½À´Ï´Ù.

    user - ID ¼¼¼ÇÀ» ÀúÀåÇÕ´Ï´Ù.
    wdate - ±¸¸Å ½Åû¼­ ÀÛ¼º³¯Â¥¸¦ ÀúÀåÇÕ´Ï´Ù.
    pduct - ½ÅûÇÑ »óÇ°À» ÀúÀåÇÕ´Ï´Ù.
    price - »óÇ°ÀÇ ÃÑ °¡°ÝÀ» ÀúÀåÇÕ´Ï´Ù.
    bprice - ÇØ´ç »óÇ°ÀÇ ´Ü°¡¸¦ ÀúÀåÇÕ´Ï´Ù.
    num - ¼±ÅÃÇÑ »óÇ°ÀÇ ÃÑ ¼ö·®À» ÀúÀåÇÕ´Ï´Ù.
    inmoney - °áÀ縦 À§ÇÑ ÀºÇàÀ̸§À» ÀúÀåÇÕ´Ï´Ù.
    name - ±¸¸ÅÀÚÀÇ À̸§À» ÀúÀåÇÕ´Ï´Ù.
    address - »óÇ°À» ¹ÞÀ» ÁÖ¼Ò¸¦ ÀúÀåÇÕ´Ï´Ù.

15.2 ¼îÇÎ ¸ô °Ô½ÃÆÇ ¼Ò½º ¸¸µé±â

¼îÇÎ ¸ôÀÇ ¼Ò½º´Â °¢ È­¸éÀ» º¸¿©ÁÖ´Â ÇÔ¼ö Çü½ÄÀÇ shop_e.php ÆÄÀÏ°ú ÇÔ¼ö¸¦ ÀÌ¿ëÇØ È­¸é¿¡ Ãâ·ÂÇÏ´Â shop.php ÆÄÀÏÀÌ ÀÖ½À´Ï´Ù.    ±×¸®°í ¼îÇÎ ¸ôÀº »óÇ°ÀÇ À̹ÌÁö¸¦ ºê¶ó¿ìÀú¿¡ Ãâ·Â ÇÏ´Â ºÎºÐÀÌ Á¸Àç ÇÕ´Ï´Ù.    ÀÌ°ÍÀ» HTML·Î ÀÏÀÏÀÌ ¸µÅ©¸¦ ¸¸µé¾î Ãâ·Â ÇÏ´Â ¹æ¹ýµµ Á¸ÀçÇÕ´Ï´Ù.¸ °ü¸®ÀÚÀÇ °æ¿ì Á¤¸» ¹ø°Å·Î¿î ÀÏÀÔ´Ï´Ù.    ¿©±â¼­´Â À̹ÌÁö¸¦ Mysql¿¡ ÀúÀåÇؼ­ »ç¿ë Çß½À´Ï´Ù.    ÀúÀåµÈ À̹ÌÁö¸¦ Ãâ·Â Çϱâ À§ÇØsajin.php ÆÄÀÏÀ» »ç¿ë ÇÕ´Ï´Ù.

shop_e.php Àüü ÄÚµå

    <?php

    $connect = mysql_connect('localhost','root','gksmf444');

    mysql_select_db('shop',$connect);


    function add_pd($table,$username,$pdname,$num,$price,$connect,$sel)
    {
      $ally=mysql_query("select user,pduct,num,price,bprice from shopuser
      where user='$username' and pduct='$pdname'",$connect);

      $nums=mysql_fetch_array($ally);


      if($nums == 0)
      {
        mysql_query("insert into
        $table values('$username','$pdname','$num','$price','$price')",$connect);
      }
      else
      {
        $num = $num + $nums[num];
        $price = $price + $nums[price];
 
        mysql_query("update $table set num='$num',price='$price'
        where user='$username' and pduct='$pdname'",$connect);
      }
    }


    function del_pd($username,$pdname,$connect,$sel)
    {
      $ally=mysql_query("select user,pduct,num,price,bprice from shopuser
      where user='$username' and pduct='$pdname'",$connect);

      $nums=mysql_fetch_array($ally);


      if($nums[num] == 1)
      {
        mysql_query("delete from shopuser where pduct='$pdname'
        and user='$username'",$connect);
      }
      else
      {
        $numx = $nums[num] - "1";
        $pricex = $nums[price] - $nums[bprice];

        mysql_query("update shopuser set num='$numx',price='$pricex'
        where user='$username' and pduct='$pdname'",$connect);
      }
    }


    function main_shop($connect,$shop,$username,$sel)
    {
      $ally = mysql_query("select pdname,price,cont,sel from pduct
      where sel='$sel'",$connect);


      $t_num=mysql_num_rows($ally);


      echo("
      <html>
      <title>
      main_view html
      </title>
      <body bgcolor=black>
      <center>
      <img src=skyt1.jpg border=0>
      <br>
      <table border=0 cellspacing=2 cellpadding=2 width=600 >
      <tr>
      <th bgcolor=gray colspan=4 align=center>
      <font style='font-size:12px;font-style:italic;color:#blue'>
      <b> ¸¾¿¡µå´Â »óÇ°À» °ñ¶óºÁ¿ä ¾ó¸¥..</b></font></th>
      </tr>
      ");


      if(!$t_num)
      {      
        echo ("
        <tr>
        <th bgcolor=black colspan=4>
        <font style='font-size:13px;font-style:italic;color:#fffff0'>
        <b>µî·ÏµÈ »óÇ°ÀÌ ¾ö½º¿ä...  ^^;</b></font></th>
        </tr>
        </center>
        </table>
        </html>
        ");
      }
      else
      {
        for($pd=$t_num ; $pd > 0 ; $pd--)
        {
          $put=mysql_fetch_array($ally);
          $cont = nl2br($put[cont]);


          echo("
          <tr>
          <td bgcolor=gray colspan=4>
          </tr>
          <tr>
          <td bgcolor=black>
          <font style='font-size:13px;font-style:italic;color:blue'>
          <img src=sajin.php?sel=$sel&pdname=$put[pdname] border=0></font></td>


          <td bgcolor=black>
          <font style='font-size:13px;font-style:italic;color:#fffff0'>
          <b>$cont</b></font></a></td>


          <td bgcolor=black>
          &nbsp
          </td>
          </tr>


          <tr>
          <td bgcolor=black>
          <font style='font-size:13px;font-style:italic;color:blue'>
          $put[pdname]</font></td>


          <td bgcolor=black align=center>
          <font style='font-size:13px;font-style:italic;color:red'>
          <b>$put[price]¿ø</b></font></td>


          <td bgcolor=black width=50>
          <form method=post action=shop.php>
          <input type=text name=num size=4 value=1>
          <input type=hidden name=pdname value=$put[pdname]>
          <input type=hidden name=price value=$put[price]>
          <input type=hidden name=user value=$username>
          <input type=hidden name=table value=shopuser>
          <input type=hidden name=chanl value=shop_e>
          <input type=hidden name=sel value=$sel>
          <input type=submit value=´ã±â>
          </form>
          </td>
          </tr>
          ");
        }
      }


      echo("
      <tr>
      <td bgcolor=black colspan=7>&nbsp;</td>
      </tr>
      <tr>
      <td bgcolor=black colspan=7 align=center>
      ");


      echo("
      </td>
      </tr>
      </center>
      </table>
      <br>
      <center>

      <table border=0 cellspacing=2 cellpadding=2 width=700 >

      <tr>
      <td bgcolor=black width=100>
      <a href =shop.php?chanl=item_show&sel=$sel>
      <font style='font-size:13px;font-style:italic;color:#ffd700'>
      <b>¹Ù±¸´Ï</b></font></a></td>


      <td bgcolor=black width=100>
      <a href =userin.php?chanl=main_view&username=$username>
      <font style='font-size:13px;font-style:italic;color:#ffd700'>
      <b>Home</b></font></a></td>


      <td bgcolor=black width=100>
      <a href =shop.php?chanl=sub2&sel=$sel>
      <font style='font-size:13px;font-style:italic;color:#ffd700'>
      <b>ÁÖ¹® ³»¿ª/Ãë¼Ò</b></font></a></td>


      <td bgcolor=black width=100>
      <a href =db_view.php?chanl=rootin>
      <font style='font-size:13px;font-style:italic;color:#ffd700'>

      <b>Admin</b></font></a></td>


      </tr>
      </table>
      </center>
      </html>
      ");
    }


    function item_show($table,$username,$connect,$sel)
    {
      $ally = mysql_query("select user,pduct,num,price,bprice from shopuser
      where user='$username'  ",$connect);


      $t_num=mysql_num_rows($ally);


      echo("
      <html>
      <title>
      main_view html
      </title>
      <body bgcolor=black>
      <center>
      <img src=skyt1.jpg border=0>
      <br>

      <table border=0 cellspacing=2 cellpadding=2 width=800 >

      <tr>
      <th bgcolor=gray colspan=6 align=center>
      <font style='font-size:12px;font-style:italic;color:#red'>
      <b>¼îÇÎ ÁýÇÕ¼Ò ¹Ù±¸´Ï ÀÔ´Ï´Ù.Àå¹Ù±¸´ÏÁ®^^;</b></font></th>
      </tr>


      <tr>
      <td bgcolor=black width=200 align=center>
      <font style='font-size:13px;font-style:italic;color:blue'>
      <b>Á¦Ç°¸í</b></font></td>


      <td bgcolor=black width=100 align=center>
      <font style='font-size:13px;font-style:italic;color:#fffff0'>
      <b>¼ö·®</b></font></a></td>


      <td bgcolor=black width=200 align=center>
      <font style='font-size:13px;font-style:italic;color:#fffff0'>
      <b>´Ü°¡</b></font></a></td>


      <td bgcolor=black width=200 align=center>
      <font style='font-size:13px;font-style:italic;color:#fffff0'>
      <b>ÇÕ°è</b></font></a></td>


      <td bgcolor=black width=100 align=center>
      <font style='font-size:13px;font-style:italic;color:#fffff0'>
      <b>º¿´Ù¸®</b></font></a></td>
      </tr>
      ");


      for($pd=$t_num ; $pd > 0 ; $pd--)
      {
        $put=mysql_fetch_array($ally);
        $total = $total+($put[bprice] * $put[num]);


        echo("
        <tr>
        <td bgcolor=black width=200 align=center>
        <font style='font-size:13px;font-style:italic;color:blue'>
        $put[pduct]</font></td>


        <td bgcolor=black width=100 align=center>
        <font style='font-size:13px;font-style:italic;color:#fffff0'>
        <b>$put[num]ea</b></font></td>


        <td bgcolor=black align=center width=200>
        <font style='font-size:13px;font-style:italic;color:#fffff0'>
        <b>$put[bprice]¿ø</b></font></td>


        <td bgcolor=black align=center width=200>
        <font style='font-size:13px;font-style:italic;color:#fffff0'>
        <b>$put[price]¿ø</b></font>
        </td>


        <td bgcolor=black align=left width=100>
        <form method=post action=shop.php>
        <input type=hidden name=pdname value=$put[pduct]>
        <input type=hidden name=chanl value=del_pd>
        <input type=hidden name=sel value=$sel>
        <input type=submit value=Åбâ>
        </form>
        </td>
        ");
      }


      echo("
      </tr>
      </table>


      <table border=0 cellspacing=2 cellpadding=2 width=800 >

      <tr>
      <td bgcolor=black align=center width=200>
      <a href =shop.php?sel=$sel>
      <font style='font-size:13px;font-style:italic;color:#ffd700'>
      <b>¼îÇÎ °è¼ÓÇϱâ</b></font></a></td>


      <td bgcolor=black align=center width=200>
      <a href =shop.php?chanl=sub&sel=$sel>
      <font style='font-size:13px;font-style:italic;color:#ffd700'>
      <b>ÁÖ¹®Çϱâ</b></font></a></td>


      <td bgcolor=black align=right width=200>
      <font style='font-size:13px;font-style:italic;color:blue'>
      <b>Ãѱݾ×</b></font></td>


      <td bgcolor=black align=center width=200>
      <font style='font-size:13px;font-style:italic;color:red'>
      <b>$total ¿ø</b></font></td>
      </tr>
      </table>
      </center>
      </html>
      ");
    }


    function error_view($edate,$address,$inmoney,$name)
    {

      if(!$address)
      {
        echo("
        <script>
        window.alert('address°¡ ¾ø½À´Ï´Ù. ´Ù½Ã ÀÔ·ÂÇØ ÁÖ¼¼¿ä')
        history.go(-1)
        </script>
        ");
        exit;
      }


      if(!$inmoney)
      {
        echo("
        <script>
        window.alert('ÀÔ±ÝÇÒ ÀºÇàÀÌ ¾ø½À´Ï´Ù. ´Ù½Ã ÀÔ·ÂÇØ ÁÖ¼¼¿ä')
        history.go(-1)
        </script>
        ");
        exit;
      }


      if(!$edate)
      {
        echo("
        <script>
        window.alert('¸¶°¨ÀÏÀÌ ¾ø½À´Ï´Ù. ´Ù½Ã ÀÔ·ÂÇØ ÁÖ¼¼¿ä')
        history.go(-1)
        </script>
        ");
        exit;
      }


      if(!$name)
      {
        echo("
        <script>
        window.alert('nameÀÌ ¾ø½À´Ï´Ù. ´Ù½Ã ÀÔ·ÂÇØ ÁÖ¼¼¿ä')
        history.go(-1)
        </script>
        ");
        exit;
      }
    }

    ?>

¼Ò½º ¼³¸í

    ¼îÇÎÀÇ °¢ È­¸éÀ» ÇÔ¼ö Çü½ÄÀ¸·Î ¸¸µé¾ú°í »çÀÌÆ®¿¡ µû¶ó ´Ù¾çÇÑ È­¸éÀ» Ãß°¡ ÇÒ ¼ö ÀÖ½À´Ï´Ù.
    ¹°·Ð Á¶°Ç ¹® ³ª¿­ Çü½ÄÀ» »ç¿ëÇؼ­ °¢ È­¸éÀ» Ç¥Çö ÇÒ ¼ö ÀÖ½À´Ï´Ù.

µ¥ÀÌÅÍ º£À̽º Á¢¼Ó

    $connect = mysql_connect('localhost','root','gksmf444');
    /* mysql Á¢¼ÓÀ» À§ÇÑ È£½ºÆ® À̸§ , °èÁ¤ , ºñ¹Ð ¹øÈ£ ÀÔ´Ï´Ù. */

 
    mysql_select_db('shop',$connect);
   /* shop µ¥ÀÌÅÍ º£À̽º¸¦ ¼±Åà ÇÕ´Ï´Ù. */

add_pd($table,$username,$pdname,$num,$price,$cont,$connect,$sel) ÇÔ¼ö

    ±¸¸ÅÀÚ°¡ ¼±ÅÃÇÑ ¹°°ÇÀ» ´ã´Â ¹Ù±¸´Ï ÇÔ¼ö ÀÔ´Ï´Ù. 

ÇÔ¼ö ÀÎÀÚ

    function add_pd($table,$username,$pdname,$num,$price,$connect,$sel)
    {

 
    $table - Å×À̺í À̸§À» Àü´Þ ÇÕ´Ï´Ù.
             ³ªÁß¿¡ ´Ù¾çÇÑ Å×ÀÌºí »ç¿ëÀ» ¿ëÀÌÇÏ°Ô ÇÏ°í ¿©·¯ °³ÀÇ ¼îÇÎ ¹Ù±¸´Ï Ç׸ñÀ» Ãß°¡ ÇÒ ¼ö ÀÖ½À´Ï´Ù.
    $username - »ç¿ëÀÚÀÇ ID ¼¼¼ÇÀ» Àü´ÞÇÕ´Ï´Ù.
    $pdname - ¼±ÅÃÇÑ »óÇ° À̸§À» Àü´ÞÇÕ´Ï´Ù.
    $num - ¼±ÅÃÇÑ »óÇ°ÀÇ ¼ö·®À» Àü´ÞÇÕ´Ï´Ù.
    $price - ¼±ÅÃÇÑ »óÇ°ÀÇ °¡°ÝÀ» Àü´ÞÇÕ´Ï´Ù.
    $connect - µ¥ÀÌÅÍ º£À̽º Á¢¼Ó Ç׸ñÀ» Àü´ÞÇÕ´Ï´Ù.
    $sel - ±¸¸Å Á¦Ç°ÀÇ Á¾¸ñ ¹øÈ£¸¦ Àü´ÞÇÕ´Ï´Ù.

µ¥ÀÌÅÍ º£À̽º Query ¸¸µé±â

    $ally=mysql_query("select user,pduct,num,price,bprice from shopuser 
    where user='$username' and pduct='$pdname'",$connect);
    /* ¹Ù±¸´Ï Å×À̺í(shopuser)¿¡¼­ ÇØ´ç ±¸¸ÅÀÚ¿Í »óÇ°À̸§ÀÌ Á¸ÀçÇÏ¸é ±¸¸ÅÀÚ, »óÇ°À̸§, ¼ö·®, °¡°Ý, 
       ´Ü°¡ µîÀÇ Á¤º¸¸¦ °Ë»ö ÇÕ´Ï´Ù. */

    $nums=mysql_fetch_array($ally);
    /* À§ ¹Ù±¸´Ï Å×À̺íÀÇ Á¤º¸¸¦ $nums º¯¼ö¿¡ ¹è¿­·Î ÀúÀå ÇÕ´Ï´Ù. */   

¹Ù±¸´Ï¿¡ »óÇ° ´ã±â

    if($nums == 0)
    {
      mysql_query("insert into $table
      values('$username','$pdname','$num','$price','$price')",$connect);
    }
    /* ¹Ù±¸´Ï Å×ÀÌºí¿¡ ¾Æ¹«·± Á¤º¸µµ ¾øÀ» °æ¿ì ±¸¸ÅÀÚ°¡ ¼±ÅÃÇÑ »óÇ°ÀÇ Á¤º¸¸¦ ÇØ´ç Å×ÀÌºí¿¡ ÀúÀå ÇÕ´Ï´Ù. */
    else
    {
      $num = $num + $nums[num];
      $price = $price + $nums[price];
      /* $num , $priceÀÇ °ªÀ» ±âÁ¸ÀÇ °ª°ú ´õÇÕ´Ï´Ù. ÀÌ°ÍÀº ÇØ´ç ID ¼¼¼ÇÀ» °¡Áø ±¸¸ÅÀÚ°¡ ¼±ÅÃÇÑ ¹°°ÇÀÌ
         Á¸ÀçÇÒ °æ¿ì ±âÁ¸¿¡ ÀÖ´ø »óÇ°ÀÇ ¼ö·®°ú °¡°ÝÀ» ´õÇÏ´Â °ÍÀÔ´Ï´Ù. */


      mysql_query("update $table set num='$num',price='$price'
      where user='$username' and pduct='$pdname'",$connect);
    }
    /* ¼öÁ¤µÈ $num °ú $price¸¦ ÇØ´ç Å×ÀÌºí¿¡ ÀúÀå ÇÕ´Ï´Ù.*/
    }

del_pd($username,$pdname,$connect,$sel) ÇÔ¼ö

    ¼îÇÎ ¸ôÀÇ °¢ Á¾¸ñ¿¡ ÇØ´çÇÏ´Â ¸ÞÀÎ È­¸éÀ» Ãâ·Â ÇÕ´Ï´Ù. $sel º¯¼ö°¡ Á¦Ç°ÀÇ Á¾¸ñ ¹øÈ£¸¦ Àü´Þ ÇÕ´Ï´Ù.

µ¥ÀÌÅÍ º£À̽º Query ¸¸µé±â

    $ally=mysql_query("select user,pduct,num,price,bprice from shopuser
    where user='$username' and pduct='$pdname'",$connect);
    /* shopuserÅ×ÀÌºí¿¡¼­ ÇØ´ç ID ¼¼¼Ç°ú »óÇ°¿¡ ´ëÇÏ¿© Á¤º¸¸¦ °Ë»ö ÇÕ´Ï´Ù. */

    $nums=mysql_fetch_array($ally);
    /* ÇØ´ç Å×À̺íÀÇ Á¤º¸¸¦ $nums¿¡ ¹è¿­·Î ÀúÀå ÇÕ´Ï´Ù. */

¹Ù±¸´Ï »óÇ° Á¦°ÅÇϱâ

    if($nums[num] == 1)
    {

      mysql_query("delete from shopuser where pduct='$pdname'
      and user='$username'",$connect);
    }
    /* ¹Ù±¸´Ï¿¡ ÇØ´ç »óÇ°ÀÌ Çϳª Á¸Àç ÇÒ °æ¿ì Å×ÀÌºí¿¡¼­ ¿ÏÀüÈ÷ »èÁ¦ ÇÕ´Ï´Ù. */
    else
    {
      $numx = $nums[num] - "1";
      $pricex = $nums[price] - $nums[bprice];
      /* ¹Ù±¸´Ï¿¡ ÇØ´ç »óÇ°ÀÌ Çϳª ÀÌ»óÀÏ °æ¿ì ÇØ´ç »óÇ°ÀÇ ¼ö·®À» Çϳª »èÁ¦ ÇÏ°í ÃÑ °¡°Ý¿¡¼­ ÇØ´ç »óÇ°ÀÇ ´Ü°¡¸¦ »©ÁÝ´Ï´Ù.  */

      mysql_query("update shopuser set num='$numx',price='$pricex'
      where user='$username' and pduct='$pdname'",$connect);
    }
    /* ¼öÁ¤µÈ $numx ¿Í $pricex¸¦ ÇØ´ç Å×ÀÌºí¿¡ ÀúÀå ÇÕ´Ï´Ù. */

main_shop($connect,$shop,$username,$sel) ÇÔ¼ö

    ¼îÇÎ ¸ôÀÇ °¢ Á¾¸ñ¿¡ ÇØ´çÇÏ´Â ¸ÞÀÎ È­¸éÀ» Ãâ·Â ÇÕ´Ï´Ù. $sel º¯¼ö°¡ Á¦Ç°ÀÇ Á¾¸ñ ¹øÈ£¸¦ Àü´Þ ÇÕ´Ï´Ù.

µ¥ÀÌÅÍ º£À̽º Query ¸¸µé±â

    $ally = mysql_query("select pdname,price,cont,sel from pduct where sel='$sel'",$connect);
    /* »óÇ° Á¤º¸ Å×À̺í(pduct)¿¡¼­ ÇØ´ç Á¾¸ñÀÇ »óÇ° Á¤º¸¸¦ °Ë»ö ÇÕ´Ï´Ù. 
       °Ë»ö Çʵå´Â »óÇ° À̸§ , °"Ý , »óÇ° ¼³í , »óÇ° Á¾¸ñ ¹øÈ£ ÀÔ´Ï´Ù. */


    $t_num=mysql_num_rows($ally);
    /* »óÇ° Á¤º¸ Å×ÀÌºí¿¡ Á¸ÀçÇÏ´Â »óÇ°ÀÇ ¼ö¸¦ ÇØ´ç º¯¼ö¿¡ ÀúÀå ÇÕ´Ï´Ù. */

»óÇ° Á¤º¸ È­¸é Ãâ·Â Çϱâ

    if(!$t_num)
    {
      echo ("
      <tr>
      <th bgcolor=black colspan=4>
      <font style='font-size:13px;font-style:italic;color:#fffff0'>
      <b>µî·ÏµÈ »óÇ°ÀÌ ¾ö½º¿ä...  ^^;</b></font></th>
      </tr>
      </center>
      </table>
      </html>
      ");
    }
    /* »óÇ° Á¤º¸ Å×ÀÌºí¿¡ µî·ÏµÈ »óÇ°ÀÌ ¾øÀ» °æ¿ì Ãâ·Â ÇÏ´Â È­¸é ÀÔ´Ï´Ù. */
    else
    {
      for($pd=$t_num ; $pd > 0 ; $pd--)
      {
      /* »óÇ° Á¤º¸ Å×ÀÌºí¿¡ µî·ÏµÈ »óÇ°ÀÌ ÀÖÀ» °æ¿ì ½ÇÇà ÇÕ´Ï´Ù.
         ÇØ´ç for¹®Àº Å×ÀÌºí¿¡ Á¸Àç ÇÏ´Â »óÇ°ÀÇ ¼ö¸¦ ÀÌ¿ëÇؼ­ ±× ¼ö ¸¸Å­ ¹Ýº¹ÇÕ´Ï´Ù. */


        $put=mysql_fetch_array($ally);
        /* ÇØ´ç Á¾¸ñÀÇ »óÇ° Á¤º¸¸¦ $t_num º¯¼ö¿¡ ¹è¿­·Î ÀúÀå ÇÕ´Ï´Ù. */


        $cont = nl2br($put[cont]);
        /* µ¥ÀÌÅÍ º£À̽º¿¡ ÀúÀåµÈ »óÇ°ÀÇ ¼³¸íÀ» ºê¶ó¿ìÀú¿¡ Ãâ·Â Çϱâ À§ÇØ nlÀ» <br>·Î ¹Ù²ß´Ï´Ù. */

        echo("
        <tr>
        <td bgcolor=gray colspan=4>
        </tr>
        <tr>
        <td bgcolor=black>
        <font style='font-size:13px;font-style:italic;color:blue'>
        <img src=sajin.php?sel=$sel&pdname=$put[pdname] border=0></font></td>
        /* ÇØ´ç »óÇ°ÀÇ À̹ÌÁö¸¦ Ãâ·Â ÇÕ´Ï´Ù. sajin.php ÆÄÀÏ¿¡ Ãâ·Â µÇ´Â À̹ÌÁö¸¦ Ãâ·Â ÇÕ´Ï´Ù.*/
        <td bgcolor=black>
        <font style='font-size:13px;font-style:italic;color:#fffff0'>
        <b>$cont</b></font></a></td>
        /* ÇØ´ç »óÇ°¿¡ ´ëÇÑ ¼³¸íÀ» Ãâ·Â ÇÕ´Ï´Ù. */


        <td bgcolor=black>
        &nbsp
        </td>
        </tr>
        

        <tr>
        <td bgcolor=black>
        <font style='font-size:13px;font-style:italic;color:blue'>
        $put[pdname]</font></td>
        /* ÇØ´ç »óÇ°ÀÇ °¡°ÝÀ» Ãâ·Â ÇÕ´Ï´Ù. */


        <td bgcolor=black align=center>
        <font style='font-size:13px;font-style:italic;color:red'>
        <b>$put[price]¿ø</b></font></td>
        /* ÇØ´ç »óÇ°ÀÇ °¡°ÝÀ» Ãâ·Â ÇÕ´Ï´Ù. */


        <td bgcolor=black width=50>
        <form method=post action=shop.php>
        <input type=text name=num size=4 value=1>
        <input type=hidden name=pdname value=$put[pdname]>
        <input type=hidden name=price value=$put[price]>
        <input type=hidden name=user value=$username>
        <input type=hidden name=table value=shopuser>
        <input type=hidden name=chanl value=shop_e>
        <input type=hidden name=sel value=$sel>
        <input type=submit value=´ã±â>
        </form>
        /* °¢ »óÇ°ÀÇ ¼ö·®À» ¼±ÅÃÇÏ°í ¹Ù±¸´Ï¿¡ Àü´ÞÇÏ´Â "´ã±â" ¹öÆ°À» »ý¼º ÇÕ´Ï´Ù.
           »óÇ° ¼ö·®Àº shop.php ÆÄÀÏ¿¡ ÀüÞ ÇÏ¸ç ±âº» ¼ö·®Àº 1°³ÀÔ´Ï´Ù.
           Àü´Þ ÀÎÀÚ´Â »óÇ° À̸§ , »óÇ° °"Ý , ID ¼¼¼Ç , Å×À̺í À̸§(»õ·Î¿î ¼îÇÎ ¸ôÀ» ¸¸µé °æ¿ì Àû¿ë) , 
           ÇØ´ç ÀÎÀÚ¸¦ Àû¿ëÇÒ chanl , »óÇ° Á¾¸ñ ¹øÈ£¸¦ Àü´Þ ÇÕ´Ï´Ù. */


        </td>
        </tr>
        "); 
      }
    }

´Ù¸¥ È­¸é ¸µÅ© ¸¸µé±â

    echo("
    </td>
    </tr>
    </center>
    </table>
    <br>
    <center>
    <table border=0 cellspacing=2 cellpadding=2 width=700 >
    <tr>
    <td bgcolor=black width=100>
    <a href =shop.php?chanl=item_show&sel=$sel>
    <font style='font-size:13px;font-style:italic;color:#ffd700'>
    <b>¹Ù±¸´Ï</b></font></a></td>
    /* ¼±ÅÃÇÑ ¹°°ÇÀ» º¸¿©ÁÖ´Â ¹Ù±¸´Ï ¸µÅ©¸¦ ¸¸µì´Ï´Ù.
       Shop.php ÆÄÀÏÀÇ chanlÀÌ item_show Ç׸ñÀ» ½ÇÇà ÇÏ¸ç »óÇ°ÀÇ Á¾¸ñ ¹øÈ£µµ Àü´ÞÇÕ´Ï´Ù. */


    <td bgcolor=black width=100>
    <a href =userin.php?chanl=main_view&username=$username>
    <font style='font-size:13px;font-style:italic;color:#ffd700'>
    <b>Home</b></font></a></td>
    /* »çÀÌÆ® ¸ÞÀÎ È­¸éÀ¸·Î ¸µÅ© ÇÕ´Ï´Ù. ÇØ´ç ID ¼¼¼ÇÀ» Àü´Þ Çؼ­ ¸ÞÀÎ È­¸é¿¡ ·Î±×ÀÎ »óŸ¦ º¸¿© ÁÝ´Ï´Ù. */

    <td bgcolor=black width=100>
    <a href =shop.php?chanl=sub2&sel=$sel>
    <font style='font-size:13px;font-style:italic;color:#ffd700'>
    <b>ÁÖ¹® ³»¿ª/Ãë¼Ò</b></font></a></td>
    /* ÁÖ¹® ³»¿ªÀ» Ãë¼ÒÇÏ´Â È­¸éÀ¸·Î ¸µÅ© ÇÕ´Ï´Ù. */


    <td bgcolor=black width=100>
    <a href =db_view.php?chanl=rootin>
    <font style='font-size:13px;font-style:italic;color:#ffd700'>
    <b>Admin</b></font></a></td>
    /* »çÀÌÆ®ÀÇ Àü¹ÝÀûÀÎ Á¦¾î¸¦ ÇÏ´Â admin ¿µ¿ªÀ¸·Î ¸µÅ© ÇÕ´Ï´Ù. */
    </tr>
    </table>
    </center>
    </html>
    ");

item_show($table,$username,$connect,$sel) ÇÔ¼ö

    ¼±ÅÃÇÑ »óÇ°À» º¸¿©ÁÖ´Â ¹Ù±¸´Ï Ç׸ñ ÀÔ´Ï´Ù. ÇÔ¼ö ÀÎÀÚ´Â À§ ´Ù¸¥ ÇÔ¼öÀÇ ³»¿ë°ú °°½À´Ï´Ù.

±×¸². 15-3 ¹Ù±¸´Ï È­¸é

µ¥ÀÌÅÍ º£À̽º Query ¸¸µé±â

    $ally = mysql_query("select user,pduct,num,price,bprice from shopuser
    where user='$username'  ",$connect);
    /* shopuser Å×ÀÌºí¿¡¼­ ·Î±×ÀÎ ÇÑ ID ¼¼¼Ç¿¡ ÇØ´ç ÇÏ´Â Á¤º¸¸¦ °Ë»ö ÇÕ´Ï´Ù. */

    $t_num=mysql_num_rows($ally);
    /* ÇØ´ç ID ¼¼¼ÇÀÇ °Ë»ö ¼ö·®À» $t_num º¯¼ö¿¡ ÀúÀå ÇÕ´Ï´Ù. */

¹Ù±¸´Ï¿¡ ´ãÀº »óÇ° Ãâ·Â Çϱâ

    for($pd=$t_num ; $pd > 0 ; $pd--)
    {
    /* shopuser Å×ÀÌºí¿¡ Á¸ÀçÇÏ´Â ÇØ´ç IDÀÇ ¸ðµç »óÇ°À» Ãâ·Â ÇÕ´Ï´Ù. */


      $put=mysql_fetch_array($ally);
      $total = $total+($put[bprice] * $put[num]);
      /* ¼±ÅÃÇÑ »óÇ°ÀÇ ÃÑ °¡°ÝÀ» ±¸ÇÕ´Ï´Ù. $total = ±âÁ¸ÀÇ total + ( ÇØ´ç »óÇ° ´Ü°¡ * ÇØ´ç »óÇ° ¼ö·®) À¸·Î ±¸ÇØÁý´Ï´Ù. */


      echo("
      <tr>
      <td bgcolor=black width=200 align=center>
      <font style='font-size:13px;font-style:italic;color:blue'>
      $put[pduct]</font></td>
      /* ÇØ´ç »óÇ°ÀÇ À̸§À» Ãâ·Â ÇÕ´Ï´Ù. */
      <td bgcolor=black width=100 align=center>
      <font style='font-size:13px;font-style:italic;color:#fffff0'>
      <b>$put[num]ea</b></font></td>
      /* ÇØ´ç »óÇ°ÀÇ ¼ö·®À» Ãâ·Â ÇÕ´Ï´Ù. */


      <td bgcolor=black align=center width=200>
      <font style='font-size:13px;font-style:italic;color:#fffff0'>
      <b>$put[bprice]¿ø</b></font></td>
      /* ÇØ´ç »óÇ°ÀÇ ±âº» ´Ü°¡¸¦ Ãâ·Â ÇÕ´Ï´Ù. */


      <td bgcolor=black align=center width=200>
      <font style='font-size:13px;font-style:italic;color:#fffff0'>
      <b>$put[price]¿ø</b></font>
      /* ÇØ´ç »óÇ°ÀÇ ÃÑ ±Ý¾×À» Ãâ·Â ÇÕ´Ï´Ù. */
      </td>
      <td bgcolor=black align=left width=100>
      <form method=post action=shop.php>
      <input type=hidden name=pdname value=$put[pduct]>
      <input type=hidden name=chanl value=del_pd>
      <input type=hidden name=sel value=$sel>
      <input type=submit value=Åбâ>
      /* ¼±ÅÃÇÑ »óÇ°À» »èÁ¦ ÇÏ´Â "Åбâ" ¹öÆ°À» »ý¼º ÇÕ´Ï´Ù.
         shop.phpÀÇ chanl=del_pd Ç׸ñÀ» ½ÇÇà ÇÏ¸ç »óÇ° À̸§ú »óÇ° Á¾¸ñÀ» Àü´ÞÇÕ´Ï´Ù. */
      </form>
      </td>
      ");
    }

´Ù¸¥ È­¸é ¸µÅ© ¸¸µé±â

    ¹Ù±¸´Ï È­¸é¿¡¼­´Â ´Ù½Ã ¼îÇÎÀ» °è¼ÓÇÏ´Â ¹öÆ°°ú »óÇ°À» ÁÖ¹®ÇÏ´Â Ç׸ñ , ÃÑ ±Ý¾× µîÀÌ Á¸Àç ÇÕ´Ï´Ù.


    echo("
    </tr>
    </table>


    <table border=0 cellspacing=2 cellpadding=2 width=800 >
    <tr>
    <td bgcolor=black align=center width=200>
    <a href =shop.php?sel=$sel>
    <font style='font-size:13px;font-style:italic;color:#ffd700'>
    <b>¼îÇÎ °è¼ÓÇϱâ</b></font></a></td>
    /* ÇØ´ç ¼îÇÎÀÇ ¸ÞÀÎ È­¸éÀ¸·Î ¸µÅ© ÇÕ´Ï´Ù. */


    <td bgcolor=black align=center width=200>
    <a href =shop.php?chanl=sub&sel=$sel>
    <font style='font-size:13px;font-style:italic;color:#ffd700'>
    <b>ÁÖ¹®Çϱâ</b></font></a></td>
    /* ¹Ù±¸´Ï¿¡ ´ãÀº »óÇ°À» ÁÖ¹® Çϱâ À§ÇÑ ¸µÅ© ÀÔ´Ï´Ù. shop.php ÆÄÀÏÀÇ chanl=subÇ׸ñÀ» ½ÇÇà ÇÏ¸ç »óÇ° Á¾¸ñÀ» Àü´ÞÇÕ´Ï´Ù. */


    <td bgcolor=black align=right width=200>
    <font style='font-size:13px;font-style:italic;color:blue'>
    <b>Ãѱݾ×</b></font></td>


    <td bgcolor=black align=center width=200>
    <font style='font-size:13px;font-style:italic;color:red'>
    <b>$total ¿ø</b></font></td>
    /* ¹Ù±¸´Ï¿¡ ´ãÀº »óÇ°ÀÇ ÃÑ ±Ý¾×À» Ãâ·Â ÇÕ´Ï´Ù. */


    </tr>
    </table>
    </center>
    </html> ");

shop.php Àüü ÄÚµå

    <?php
    session_start();
    ?>


    <?

    include('shop_e.php');

    if(!$username || $username == guest)
    {
      echo("
      <script>
      window.alert('Login Çϼ¼¿ä. Guest°Å³ª ID°¡ ¾øÀ¸½Å ºÐÀº ȸ¿ø °¡ÀÔÀ» Çϼ¼¿ä')
      history.go(-1)
      </script>
      ");
      exit;
    }
    else
    {
      if(!$chanl)
      {
        main_shop($connect,$shop,$username,$sel);
      }


      if($chanl==shop_e)
      {
        add_pd($table,$username,$pdname,$num,$price,$connect,$sel);
        main_shop($connect,$shop,$username,$sel);
      }


      if($chanl ==item_show)
      {
        item_show($table,$username,$connect,$sel);
      }


      if($chanl == del_pd)
      {
        del_pd($username,$pdname,$connect,$sel);
        item_show($table,$username,$connect,$sel);
      }


      if($chanl == sub)
      {
        $ally = mysql_query("select user from shopuser where user='$username'  ",$connect);
        $t_num=mysql_num_rows($ally);


        if(!$t_num)
        {
          echo("
          <script>
          window.alert('¼±ÅÃÇÑ »óÇ°ÀÌ ¾ø½À´Ï´Ù.')
          history.go(-1)
          </script>
          ");
          exit;
        }


        mysql_select_db('selectuser',$connect);
        $ally = mysql_query("select resident,email,tel1,id from userin
        where id='$username'",$connect);
        $put=mysql_fetch_array($ally);


        echo("
        <html>
        <title>
        sub html
        </title>
        <body bgcolor=black>
        <center>
        <img src=skyt1.jpg border=0>
        <br>


        <form method=post action=shop.php>
        <input type=hidden name=chanl value=sub_e>
        <input type=hidden name=sel value=$sel>


        <table border=0 cellspacing=2 cellpadding=2 width=700 >
        <tr><font style='font-size:13px;font-style:italic;color:#fffff0'>
        (* Ãß°¡ ÁÖ¹®½Ã '½ÅûÇÕ´Ï´Ù'¸¸ Ŭ¸¯ ÇÏ¸é µË´Ï´Ù.)</font>
        <td bgcolor=#808080><font style='font-size:13px;font-style:italic;color:#fffff0'>
        <b>~¹ÞÀ»ÁÖ¼Ò</b></font></td>


        <td bgcolor=black align=left><font style='font-size:13px;font-style:italic;color:#fffff0'>
        <input type=text name=address size=44></font></td>
        </tr>
        <tr>


        <td bgcolor=#808080><font style='font-size:13px;font-style:italic;color:#fffff0'>
        <b>~Name</b></font></td>


        <td bgcolor=black><font style='font-size:13px;font-style:italic;color:#fffff0'>
        <input type=text name=name size=10></font></td>
        </tr>
        <tr>


        <td bgcolor=#808080><font style='font-size:13px;font-style:italic;color:#fffff0'>
        <b>~ÁֹιøÈ£</b></font></td>


        <td bgcolor=black><font style='font-size:13px;font-style:italic;color:#fffff0'>
        $put[resident]</font></td>
        </tr>
        <tr>


        <td bgcolor=#808080><font style='font-size:13px;font-style:italic;color:#fffff0'>
        <b>~Id</b></font></td>


        <td bgcolor=black><font style='font-size:13px;font-style:italic;color:#fffff0'>
        $put[id]</font></td>
        </tr>
        <tr>

        <td bgcolor=#808080><font style='font-size:13px;font-style:italic;color:#fffff0'>
        <b>~ÀÔ±ÝÀºÇà</b></font></td>


        <td bgcolor=black><font style='font-size:13px;font-style:italic;color:#fffff0'>
        <select name=inmoney>
          <option value=±¹¹ÎÀºÇà selected>±¹¹ÎÀºÇà
          <option value=ÇѺûÀºÇà>ÇѺûÀºÇà
          <option value=Á¶ÈïÀºÇà>Á¶ÈïÀºÇà
          <option value=¿ì¸®ÀºÇà>¿ì¸®ÀºÇà
        </select>
        </font></td>
        </tr>
        <tr>


        <td bgcolor=#808080><font style='font-size:13px;font-style:italic;color:#fffff0'>
        <b>~E-mail</b></font></td>


        <td bgcolor=black><font style='font-size:13px;font-style:italic;color:#fffff0'>
        $put[email]</font></td>
        </tr>
        <tr>
        <td bgcolor=#808080><font style='font-size:13px;font-style:italic;color:#fffff0'>
        <b>~Tel</b></font></td>

        <td bgcolor=black><font style='font-size:13px;font-style:italic;color:#fffff0'>
        $put[tel1]</font></td>
        </tr>
        <tr>


        <td bgcolor=#808080><font style='font-size:13px;font-style:italic;color:#fffff0'>
        <b>~¹è´Þ½Ã°£</b></font></td>


        <td bgcolor=black><font style='font-size:13px;font-style:italic;color:#fffff0'>
        <select name=edata1>
          <option value=2000 selected>Y2K
          <option value=2001>Y21
        </select>
        <select name=edata2>
          <option value=1>1mon
          <option value=2>2mon
          <option value=3>3mon
          <option value=4 selected>4mon
          <option value=5>5mon
          <option value=6>6mon
          <option value=7>7mon
          <option value=8>8mon
          <option value=9>9mon
          <option value=10>10mon
          <option value=11>11mon
          <option value=12>12mon
          </select>
          <select name=edata3>
          <option value=1>1day
          <option value=2>2day
          <option value=3>3day
          <option value=4>4day
          <option value=5>5day
          <option value=6>6day
          <option value=7>7day
          <option value=8>8day
          <option value=9>9day
          <option value=10>10day
          <option value=11>11day
          <option value=12>12day
          <option value=13>13day
          <option value=14 selected>14day
          <option value=15>15day
          <option value=16>16day
          <option value=17>17day
          <option value=18>18day
          <option value=19>19day
          <option value=20>20day
          <option value=21>21day
          <option value=22>22day
          <option value=23>23day
          <option value=24>24day
          <option value=25>25day
          <option value=26>26day
          <option value=27>27day
          <option value=28>28day
          <option value=29>29day
          <option value=30>30day
          <option value=31>31day
        </select>
        <select name=edata4>
          <option value=am>A.m
          <option value=pm selected>P.m
        </select>
        <select name=edata5>
          <option value=1>1si
          <option value=2>2si
          <option value=3 selected>3si
          <option value=4>4si
          <option value=5>5si
          <option value=6>6si
          <option value=7>7si
          <option value=8>8si
          <option value=9>9si
          <option value=10>10si
          <option value=11>11si
          <option value=12>12si
        </select>
        <select name=edata6>
          <option value=10>10
          <option value=20>20
          <option value=30>30
          <option value=40 selected>40
          <option value=50>50
          <option value=00>00
        </select>
        </font></td>
        </tr>
        </table>
        <br><br>
        <table border=0 cellspacing=2 cellpadding=2 width=700 >
        <tr>


        <td bgcolor=black align=center width=200>
        <a href =shop.php?user=$username&sel=$sel>
        <font style='font-size:13px;font-style:italic;color:#ffd700'>
        <b>¼îÇÎ °è¼ÓÇϱâ</b></font></a></td>
        

        <td bgcolor=black align=center width=200>
        <a href =shop.php?user=$user&chanl=item_show&sel=$sel>
        <font style='font-size:13px;font-style:italic;color:#ffd700'>
        <b>¹Ù±¸´Ï</b></font></a></td>


        <td bgcolor=black align=center ><font style='font-size:13px;font-style:italic;color:#fffff0'>
        <input type=submit value=½ÅûÇÕ´Ï´Ù.>
        <input type=reset  value=Áö¿ì±â></font></td>
        </tr>
        </table>
        </form>
        </center>
        </body>
        </html>
        ");
      }


      if($chanl == sub_e)
      {
        $ally=mysql_query("select user,pduct,num,price,bprice from shopuser
        where user='$username'",$connect);

        $t_num=mysql_num_rows($ally);


        if($edata4 == am && $edata5 == 12)
        {
          $ap = "00" ;
        }
        if($edata4 == pm && $edata5 == 12)
        {
          $ap = "12" ;
        }
        if($edata4 == am)
        {
          $ap = $edata5 ;
        }
        if($edata4 == pm)
        {
          $ap = $edata5 +"12" ;
        }
        $edate = "$edata1-$edata2-$edata3-$ap-$edata6";
  

        for($pd=$t_num ; $pd > 0 ; $pd--)
        {
          $put=mysql_fetch_array($ally);
          $ally2=mysql_query("select * from sub where user='$username'
          and pduct='$put[pduct]'",$connect);


          $put2=mysql_fetch_array($ally2);


          if($put2[pduct] != $put[pduct])
          {
            $numall = $put[num] ;

            error_view($edate,$address,$inmoney,$name);

            mysql_query("insert into sub values('$username','$edate','$put[pduct]',
            '$put[price]','$put[bprice]','$numall','$inmoney','$name','$address')",$connect);
          }
          else
          {
            $numall = $put[num] + $put2[num] ;

            mysql_query("update sub set num='$numall'
            where user='$username' and pduct='$put2[pduct]'",$connect);
          }
        }  


        echo("
        <html>
        <body>
        <center>
        <form method=post action=shop.php>
        <font style='font-size:13px;font-style:italic;color:#808080'>
        <b>½Åû µÇ¾ú½À´Ï´Ù</b></font>


        <input type=hidden name=chanl value=sub2>
        <input type=hidden name=sel value=$sel>
        <input type=submit value=È®ÀÎ>
        </form>
        </center>
        </body>
        </html>
        ");
      }


      if($chanl == sub2)
      {
        $ally=mysql_query("select * from sub where user='$username' ",$connect);


        mysql_select_db('selectuser',$connect);
        $ally2=mysql_query("select resident,tel1,id from userin
        where id='$username' ",$connect);


        $put=mysql_fetch_array($ally2);
        $t_num2=mysql_num_rows($ally);


        if(!$t_num2)
        {  
          echo("
          <script>
          window.alert('ÁÖ¹®ÇÑ »óÇ°ÀÌ ¾ø½À´Ï´Ù.')
          history.go(-1)
          </script>
          ");
          exit;
        }


        echo("
        <html>
        <title>
        sub html
        </title>


        <body bgcolor=black>
        <center>
        <img src=skyt1.jpg border=0>
        <br>

        <table border=0 cellspacing=2 cellpadding=2 width=600>

        <tr>
        <td bgcolor=white colspan=5 align=center colspan=2>
        <font style='font-size:13px;font-style:italic;color:black'>
        <b> °è»ê¼­~</b></font></td>
        </tr>
        <tr>


        <td bgcolor=#808080 align=center width=200>
        <font style='font-size:13px;font-style:italic;color:#fffff0'>
        <b>~Ç°¸í</b></font></td>
      

        <td bgcolor=#808080 align=center>
        <font style='font-size:13px;font-style:italic;color:#fffff0'>
        <b>~¼ö·®</b></font></td>


        <td bgcolor=#808080 align=center>
        <font style='font-size:13px;font-style:italic;color:#fffff0'>
        <b>~´Ü°¡</b></font></td>


        <td bgcolor=#808080 align=center>
        <font style='font-size:13px;font-style:italic;color:#fffff0'>
        <b>~Èñ¸Á µµÂøÀÏ</b></font></td>
        </tr>
        ");


        for($pd=$t_num2 ; $pd >= 1 ; $pd--)
        {
          $put2=mysql_fetch_array($ally);
          $total = $total+($put2[bprice] * $put2[num]);

  
          echo("
          <tr>


          <td bgcolor=black align=center>
          <font style='font-size:13px;font-style:italic;color:#fffff0'>
          <b>$put2[pduct]</b></font></td>


          <td bgcolor=black align=center>
          <font style='font-size:13px;font-style:italic;color:#fffff0'>
          <b>$put2[num]ea</b></font></td>


          <td bgcolor=black align=center>
          <font style='font-size:13px;font-style:italic;color:#fffff0'>
          <b>$put2[bprice]¿ø</b></font></td>


          <td bgcolor=black align=center>
          <font style='font-size:13px;font-style:italic;color:#fffff0'>
          <b>$put2[wdate]</b></font></td>
          </tr>
          ");
        }


        echo("
        </table>
        <table border=0 cellspacing=2 cellpadding=2 width=600>
        <tr>


        <td bgcolor=#808080><font style='font-size:13px;font-style:italic;color:#fffff0'>
        <b>~¹ÞÀ»ÁÖ¼Ò</b></font></td>


        <td bgcolor=black align=left><font style='font-size:13px;font-style:italic;color:#fffff0'>
        $put2[address]</font></td>
        </tr>
        <tr>


        <td bgcolor=#808080><font style='font-size:13px;font-style:italic;color:#fffff0'>
        <b>~Name</b></font></td>


        <td bgcolor=black><font style='font-size:13px;font-style:italic;color:#fffff0'>
        $put2[name]</font></td>
        </tr>
        <tr>


        <td bgcolor=#808080><font style='font-size:13px;font-style:italic;color:#fffff0'>
        <b>~Id</b></font></td>


        <td bgcolor=black><font style='font-size:13px;font-style:italic;color:#fffff0'>
        $put[id]</font></td>
        </tr>
        <tr>


        <td bgcolor=#808080><font style='font-size:13px;font-style:italic;color:#fffff0'>
        <b>~ÁֹιøÈ£</b></font></td>


        <td bgcolor=black><font style='font-size:13px;font-style:italic;color:#fffff0'>
        $put[resident]</font></td>
        </tr>
        <tr>


        <td bgcolor=#808080><font style='font-size:13px;font-style:italic;color:#fffff0'>
        <b>~ÀÔ±ÝÀºÇà</b></font></td>


        <td bgcolor=black><font style='font-size:13px;font-style:italic;color:#fffff0'>
        $put2[inmoney] ¿¹±ÝÁÖ:cry 444-44-44-444</font></td>
        </tr>
        <tr>

        <td bgcolor=#808080><font style='font-size:13px;font-style:italic;color:#fffff0'>
        <b>~Tel</b></font></td>


        <td bgcolor=black><font style='font-size:13px;font-style:italic;color:#fffff0'>
        $put[tel1]</font></td>
        </tr>
        <tr>


        <td bgcolor=#808080><font style='font-size:13px;font-style:italic;color:#fffff0'>
        <b>~Ãѱݾ×</b></font></td>


        <td bgcolor=black><font style='font-size:13px;font-style:italic;color:red'>
        <b>$total</b>¿ø</font></td>
        </tr>
        </table>
        <br>

        <table border=0 cellspacing=2 cellpadding=2 width=700 >


        <td bgcolor=black align=center width=200>
        <a href =shop.php?user=$username&sel=$sel>
        <font style='font-size:13px;font-style:italic;color:#ffd700'>
        <b>¼îÇÎ °è¼ÓÇϱâ</b></font></a></td>


        <td bgcolor=black align=center width=200>
        <a href =shop.php?chanl=item_show&sel=$sel>
        <font style='font-size:13px;font-style:italic;color:#ffd700'>
        <b>¹Ù±¸´Ï</b></font></a></td>


        <td bgcolor=black align=center width=200>
        <a href =shop.php?chanl=del&sel=$sel>
        <font style='font-size:13px;font-style:italic;color:#ffd700'>
        <b>ÁÖ¹®Ãë¼Ò</b></font></a></td>
        </tr>
        </table>
        </center>
        </body>
        </html>
        ");
      }


      if($chanl == del )
      {
        mysql_query("delete from sub where user='$username' ",$connect);
        mysql_query("delete from shopuser where user='$username'",$connect);


        echo("
        <html>
        <body>
        <center>
        <form method=post action=shop.php>
        <font style='font-size:13px;font-style:italic;color:#808080'>
        <b>½ÅûÀÌ »èÁ¦ µÇ¾ú½À´Ï´Ù</b></font>
        <input type=hidden name=sel value=$sel>
        <input type=submit value=È®ÀÎ>
        </form>
        </center>
        </body>
        </html>
        ");
      }
    }

    ?>

¼Ò½º ¼³¸í

    shop.php ÆÄÀÏÀº shop_e.php ÆÄÀÏÀÇ ÇÔ¼ö¸¦ ÀÌ¿ëÇؼ­ È­¸é¿¡ Ãâ·Â ÇÏ´Â ·çƾ°ú ID ¼¼¼ÇÀ» ÀÌ¿ëÇÑ »ç¿ëÀÚ
    Á¢±ÙÀ» ¼³Á¤ ÇÕ´Ï´Ù.   ¼¼¼ÇÀÇ °æ¿ì °¡ÀÔÀÚÀÇ ID¸¦ ±×´ë·Î »ç¿ëÇؼ­ ¸¸µé±â ¶§¹®¿¡ ¹®Á¦Á¡ÀÌ ÀÖÀ» ¼ö
    ÀÖ½À´Ï´Ù.   Áï rand( ) ÇÔ¼ö¸¦ »ç¿ëÇؼ­ °¢ IDº° ¼¼¼ÇÀ» ¹«ÀÛÀ§ ¼ö·Î ¼³Á¤ ÇÏ´Â ¹æ¹ýÀ» »ç¿ëÇÏ¸é º¸´Ù 
    ¾ÈÀüÇÒ ¼ö ÀÖ½À´Ï´Ù.   ÀÌ°ÍÀº ÄíÅ°µµ ¸¶Âù°¡Áö ÀÔ´Ï´Ù. ¸¸¾à ¾î¶² »ç¿ëÀÚ°¡ ½ºÅ©¸³Æ®¸¦ ÀÌ¿ëÇؼ­ ÇØ´ç
    IDÀÇ ¼¼¼ÇÀ» »ý¼ºÇÏ°í Á¢±Ù ÇÑ´Ù¸é ¹®Á¦°¡ µÉ ¼ö ÀÖ½À´Ï´Ù.

ID ¼¼¼Ç ¼³Á¤

    <?php
    session_start();
    ?>
    /* ¼¼¼ÇÀ» ½ÃÀÛ ÇÕ´Ï´Ù. ·Î±×ÀÎÇÑ ID ¼¼¼ÇÀ» ½ÃÀÛ ÇÕ´Ï´Ù. */


    <?

    include('shop_e.php');
    /* shop_e.php ÆÄÀÏÀÇ ÇÔ¼ö¸¦ Æ÷ÇÔ ÇÕ´Ï´Ù. */

    if(!$username || $username == guest)
    {
      echo("
      <script>
      window.alert('Login Çϼ¼¿ä. Guest°Å³ª ID°¡ ¾øÀ¸½Å ºÐÀº ȸ¿ø °¡ÀÔÀ» Çϼ¼¿ä')
      history.go(-1)
      </script>");
      exit;
      }
      else
      {
      /* ID ¼¼¼ÇÀÌ ¾ø°Å³ª ·Î±×ÀÎÇÑ ID ¼¼¼ÇÀÌ guest ÀÏ °æ¿ì ¼îÇÎ ¸ôÀ» »ç¿ëÇÒ ¼ö ¾ø½À´Ï´Ù.
         ±× ¹ÛÀÇ °æ¿ì ¼îÇÎ ¸ôÀÇ ¸ðµç È­¸éÀ» º¼ ¼ö ÀÖ½À´Ï´Ù.
         Áï ¼¼¼ÇÀÇ ¿µ¿ªÀº if( ){    ~   }else{  ¼îÇÎ ¸ôÀÇ °¢ È­¸é }  ÀÔ´Ï´Ù.*/

¸ÞÀÎ È­¸é Ãâ·Â

    if(!$chanl)
    {
      main_shop($connect,$shop,$username,$sel);
    }
    /* chanl ÀÌ ¾øÀ» °æ¿ì ¼îÇÎ ¸ôÀÇ ¸ÞÀÎ È­¸éÀ» Ãâ·Â ÇÕ´Ï´Ù. */

»óÇ° ¹Ù±¸´Ï ´ã±â

    if($chanl==shop_e)
    {
      add_pd($table,$username,$pdname,$num,$price,$connect,$sel);
      main_shop($connect,$shop,$username,$sel);
    }
    /* chanlÀÌ shop_eÀÏ °æ¿ì ±¸¸ÅÀÚ°¡ ¼±ÅÃÇÑ »óÇ°À» ÇØ´ç ¹Ù±¸´Ï¿¡ ÀúÀå ÇÏ°í ´Ù½Ã ¼îÇÎ ¸ô ¸ÞÀÎ È­¸éÀ¸·Î À̵¿ ÇÕ´Ï´Ù. */

¹Ù±¸´Ï »óÇ° º¸¿©ÁÖ±â

    if($chanl ==item_show)
    {
      item_show($table,$username,$connect,$sel);
    }
    /* chanlÀÌ item_showÀÏ ¶§ ±¸¸ÅÀÚ°¡ ¼±ÅÃÇÑ »óÇ°À» ´ãÀº ¹Ù±¸´ÏÀÇ ³»¿ëÀ» Ãâ·Â ÇÕ´Ï´Ù. */

¹Ù±¸´Ï »óÇ° »èÁ¦ Çϱâ

    if($chanl == del_pd)
    {
      del_pd($username,$pdname,$connect,$sel);
      item_show($table,$username,$connect,$sel);
    }
    /* chanlÀÌ del_pdÀÏ ¶§ ¼±ÅÃÇÑ »óÇ°À» ¹Ù±¸´Ï¿¡¼­ »èÁ¦ ÇÏ°í ´Ù½Ã ¹Ù±¸´ÏÀÇ ³²Àº »óÇ°À» Ãâ·Â ÇÕ´Ï´Ù. */

»óÇ° ÁÖ¹®Çϱâ

±×¸². 15-4 »óÇ° ÁÖ¹®Çϱâ È­¸é
    if($chanl == sub)
    {
    /* chanlÀÌ subÀÏ °æ¿ì ¾Æ·¡ÀÇ Ç׸ñÀ» ½ÇÇà ÇÕ´Ï´Ù. */

      $ally = mysql_query("select user from shopuser where user='$username'  ",$connect);
      $t_num=mysql_num_rows($ally);
      /* ¹Ù±¸´Ï(shopuser Å×À̺í)¿¡¼­ ÇØ´ç ID°¡ ¼±ÅÃÇÑ »óÇ°ÀÌ ÀÖ´ÂÁö °Ë»ö ÇÕ´Ï´Ù. */


      if(!$t_num)
      {
        echo("
        <script>
        window.alert('¼±ÅÃÇÑ »óÇ°ÀÌ ¾ø½À´Ï´Ù.')
        history.go(-1)
        </script>
        ");
        exit;
      }
      /* ¹Ù±¸´Ï¿¡ ¼±ÅÃÇÑ »óÇ°ÀÌ Çϳªµµ ¾øÀ» °æ¿ì Ãâ·Â ÇÏ´Â È­¸é ÀÔ´Ï´Ù. */


      mysql_select_db('selectuser',$connect);
      /* ·Î±×ÀÎÇÑ ID ¼¼¼ÇÀÇ »ç¿ëÀÚ Á¤º¸¸¦ °¡Á® ¿À±â À§ÇØ selectuser µ¥ÀÌÅÍ º£À̽º¸¦ ¼±Åà ÇÕ´Ï´Ù. */


      $ally = mysql_query("select resident,email,tel1,id from userin
      where id='$username'",$connect);
      /* ÇØ´ç ID ¼¼¼ÇÀ» °¡Áø ±¸¸ÅÀÚÀÇ Á¤º¸¸¦ °Ë»ö ÇÕ´Ï´Ù. */


      $put=mysql_fetch_array($ally);
      /* ±¸¸ÅÀÚÀÇ Á¤º¸¸¦ ¹è¿­·Î ÀúÀå ÇÕ´Ï´Ù. */


      echo("
      <html>
      <title>
      sub html
      </title>
      <body bgcolor=black>
      <center>
      <img src=skyt1.jpg border=0>
      <br>


      <form method=post action=shop.php>
      <input type=hidden name=chanl value=sub_e>


      <table border=0 cellspacing=2 cellpadding=2 width=700 >
      <tr><font style='font-size:13px;font-style:italic;color:#fffff0'>
      (* Ãß°¡ ÁÖ¹®½Ã '½ÅûÇÕ´Ï´Ù'¸¸ Ŭ¸¯ ÇÏ¸é µË´Ï´Ù.)</font>


      <td bgcolor=#808080><font style='font-size:13px;font-style:italic;color:#fffff0'>
      <b>~¹ÞÀ»ÁÖ¼Ò</b></font></td>


      <td bgcolor=black align=left><font style='font-size:13px;font-style:italic;color:#fffff0'>
      <input type=text name=address size=44></font></td>
      /* »óÇ°À» ¹ÞÀ» ÁÖ¼Ò¸¦ ÀÔ·Â ÇÏ´Â ºÎºÐ ÀÔ´Ï´Ù. */


      </tr>
      <tr>


      <td bgcolor=#808080><font style='font-size:13px;font-style:italic;color:#fffff0'>
      <b>~Name</b></font></td>


      <td bgcolor=black><font style='font-size:13px;font-style:italic;color:#fffff0'>
      <input type=text name=name size=10></font></td>
      /* ÇØ´ç ±¸¸ÅÀÚÀÇ ½ÇÁ¦ À̸§À» ÀÔ·Â ÇÏ´Â °÷ÀÔ´Ï´Ù. */


      </tr>
      <tr>


      <td bgcolor=#808080><font style='font-size:13px;font-style:italic;color:#fffff0'>
      <b>~ÁֹιøÈ£</b></font></td>


      <td bgcolor=black><font style='font-size:13px;font-style:italic;color:#fffff0'>
      $put[resident]</font></td>
      /* ÇØ´ç ±¸¸ÅÀÚÀÇ ÁֹΠ¹øÈ£¸¦ ÀÔ·Â ÇÏ´Â ºÎºÐ ÀÔ´Ï´Ù. */


      </tr>
      <tr>


      <td bgcolor=#808080><font style='font-size:13px;font-style:italic;color:#fffff0'>
      <b>~Id</b></font></td>

      <td bgcolor=black><font style='font-size:13px;font-style:italic;color:#fffff0'>
      $put[id]</font></td>
      /* ÇØ´ç ±¸¸ÅÀÚÀÇ ·Î±×ÀÎ ¶§ »ç¿ëÇÑ ID¸¦ Ãâ·Â ÇÕ´Ï´Ù. */

      </tr>
      <tr>

      <td bgcolor=#808080><font style='font-size:13px;font-style:italic;color:#fffff0'>
      <b>~ÀÔ±ÝÀºÇà</b></font></td>


      <td bgcolor=black><font style='font-size:13px;font-style:italic;color:#fffff0'>
      <select name=inmoney>
        <option value=±¹¹ÎÀºÇà selected>±¹¹ÎÀºÇà
        <option value=ÇѺûÀºÇà>ÇѺûÀºÇà
        <option value=Á¶ÈïÀºÇà>Á¶ÈïÀºÇà
        <option value=¿ì¸®ÀºÇà>¿ì¸®ÀºÇà
      </select>
      </font></td>
      /* »óÇ° ´ë±ÝÀ» °áÁ¦ Çϱâ À§ÇÑ ÀºÇàÀ» ¼±ÅÃÇÏ´Â ºÎºÐ ÀÔ´Ï´Ù. */

      </tr>
      <tr>

      <td bgcolor=#808080><font style='font-size:13px;font-style:italic;color:#fffff0'>
      <b>~E-mail</b></font></td>

      <td bgcolor=black><font style='font-size:13px;font-style:italic;color:#fffff0'>
      $put[email]</font></td>
      /* ÇØ´ç ±¸¸ÅÀÚÀÇ ¸ÞÀÏ ÁÖ¼Ò¸¦ Ãâ·Â ÇÏ´Â ºÎºÐ ÀÔ´Ï´Ù. */

      </tr>
      <tr>


      <td bgcolor=#808080><font style='font-size:13px;font-style:italic;color:#fffff0'>
      <b>~Tel</b></font></td>


      <td bgcolor=black><font style='font-size:13px;font-style:italic;color:#fffff0'>
      $put[tel1]</font></td>
      /* ÇØ´ç ±¸¸ÅÀÚÀÇ ÀüÈ­¹øÈ£¸¦ Ãâ·Â ÇÕ´Ï´Ù. */


      </tr>
      <tr>


      <td bgcolor=#808080><font style='font-size:13px;font-style:italic;color:#fffff0'>
      <b>~¹è´Þ½Ã°£</b></font></td>


      <td bgcolor=black><font style='font-size:13px;font-style:italic;color:#fffff0'>
      <select name=edata1>
      <option value=2000 selected>Y2K
      <option value=2001>Y21
      </select>
      <select name=edata2>
        <option value=1>1mon
        <option value=2>2mon
        <option value=3>3mon
        <option value=4 selected>4mon
        <option value=5>5mon
        <option value=6>6mon
        <option value=7>7mon
        <option value=8>8mon
        <option value=9>9mon
        <option value=10>10mon
        <option value=11>11mon
        <option value=12>12mon
      </select>
        <select name=edata3>
        <option value=1>1day
        <option value=2>2day
        <option value=3>3day
        <option value=4>4day
        <option value=5>5day
        <option value=6>6day
        <option value=7>7day
        <option value=8>8day
        <option value=9>9day
        <option value=10>10day
        <option value=11>11day
        <option value=12>12day
        <option value=13>13day
        <option value=14 selected>14day
        <option value=15>15day
        <option value=16>16day
        <option value=17>17day
        <option value=18>18day
        <option value=19>19day
        <option value=20>20day
        <option value=21>21day
        <option value=22>22day
        <option value=23>23day
        <option value=24>24day
        <option value=25>25day
        <option value=26>26day
        <option value=27>27day
        <option value=28>28day
        <option value=29>29day
        <option value=30>30day
        <option value=31>31day
      </select>
      <select name=edata4>
        <option value=am>A.m
        <option value=pm selected>P.m
      </select>
      <select name=edata5>
        <option value=1>1si
        <option value=2>2si
        <option value=3 selected>3si
        <option value=4>4si
        <option value=5>5si
        <option value=6>6si
        <option value=7>7si
        <option value=8>8si
        <option value=9>9si
        <option value=10>10si
        <option value=11>11si
        <option value=12>12si
      </select>
      <select name=edata6>
        <option value=10>10
        <option value=20>20
        <option value=30>30
        <option value=40 selected>40
        <option value=50>50
        <option value=00>00
      </select>
      </font></td>
      /* select¹®À» ÀÌ¿ëÇØ »óÇ°À» ¹ÞÀ» ³¯Â¥¿Í ½Ã°£À» ÀÔ·Â ÇÏ´Â ºÎºÐ ÀÔ´Ï´Ù. */


      </tr>
      </table>
      <br><br>
      <table border=0 cellspacing=2 cellpadding=2 width=700 >
      <tr>


      <td bgcolor=black align=center width=200>
      <a href =shop.php?user=$username&sel=$sel>
      <font style='font-size:13px;font-style:italic;color:#ffd700'>
      <b>¼îÇÎ °è¼ÓÇϱâ</b></font></a></td>
      /* ÇØ´ç »óÇ° Á¾¸ñÀÇ ¼îÇÎ ¸ÞÀÎ È­¸éÀ¸·Î ¸µÅ© ÇÕ´Ï´Ù. */


      <td bgcolor=black align=center width=200>
      <a href =shop.php?user=$user&chanl=item_show&sel=$sel>

      <font style='font-size:13px;font-style:italic;color:#ffd700'>

      <b>¹Ù±¸´Ï</b></font></a></td>

      /* ÇØ´ç ±¸¸ÅÀÚÀÇ ¹Ù±¸´Ï·Î ¸µÅ© ÇÕ´Ï´Ù. */


      <td bgcolor=black align=center ><font style='font-size:13px;font-style:italic;color:#fffff0'>
      <input type=submit value=½ÅûÇÕ´Ï´Ù.>
      <input type=reset  value=Áö¿ì±â></font></td>
      /* À§ ÀÔ·Â »çÇ×À» ÁÖ¹®¼­ Å×ÀÌºí¿¡ Àü´Þ ÇÏ´Â "½ÅûÇÕ´Ï´Ù" ¹öÆ°À» »ý¼º ÇÕ´Ï´Ù. */
      </tr>
      </table>
      </form>
      </center>
      </body>
      </html>
      ");
    }

½ÅûÇÑ »óÇ° Á¤º¸ ÀúÀå Çϱâ

    if($chanl == sub_e)
    {
      /* chanlÀÌ sub_eÀÏ ¶§ ¾Æ·¡ Ç׸ñÀ» ½ÇÇà ÇÕ´Ï´Ù. */


      $ally=mysql_query("select user,pduct,num,price,bprice from shopuser
      where user='$username'",$connect);
      /* ¹Ù±¸´Ï Å×ÀÌºí¿¡¼­ ÇØ´ç ±¸¸ÅÀÚ°¡ ¼±ÅÃÇÑ »óÇ° Á¤º¸¸¦ °Ë»ö ÇÕ´Ï´Ù. */


      $t_num=mysql_num_rows($ally);
      /* ¹Ù±¸´ÏÀÇ »óÇ° ¼ö·®À» °Ë»öÇÏ°í $t_num º¯¼ö¿¡ ÀúÀå ÇÕ´Ï´Ù. */


      if($edata4 == am && $edata5 == 12)
      {
        $ap = "00" ;
      }
      if($edata4 == pm && $edata5 == 12)
      {
        $ap = "12" ;
      }
      if($edata4 == am)
      {
        $ap = $edata5 ;
      }
      if($edata4 == pm)
      {
        $ap = $edata5 +"12" ;
      }
     

      $edate = "$edata1-$edata2-$edata3-$ap-$edata6";
      /* »óÇ° ¹è´Þ ³¯Â¥¿Í ½Ã°£À» am ,pm ¿©ºÎ¸¦ °Ë»ö ÇÏ°í $edate º¯¼ö¿¡ ÀúÀå ÇÕ´Ï´Ù. */


      for($pd=$t_num ; $pd > 0 ; $pd--)
      {
      /* ¹Ù±¸´ÏÀÇ »óÇ° ¼ö·® ¸¸Å­ ·çÇÁ¸¦ ¹Ýº¹ ÇÕ´Ï´Ù. */


        $put=mysql_fetch_array($ally);
        /* ¹Ù±¸´ÏÀÇ »óÇ° Á¤º¸¸¦ ¹è¿­·Î ÀúÀå ÇÕ´Ï´Ù. */


        $ally2=mysql_query("select * from sub where user='$username'
        and pduct='$put[pduct]'",$connect);
        /* ÇØ´ç ±¸¸ÅÀÚÀÇ ÇØ´ç »óÇ°ÀÌ ÁÖ¹® Å×À̺í(sub)¿¡ Á¸Àç ÇÏ´ÂÁö °Ë»ö ÇÕ´Ï´Ù. */


        $put2=mysql_fetch_array($ally2);
        /* ÇØ´ç ±¸¸ÅÀÚÀÇ ÇØ´ç »óÇ°ÀÇ Á¤º¸¸¦ $put2 º¯¼ö¿¡ ¹è¿­·Î ÀúÀå ÇÕ´Ï´Ù. */


        if($put2[pduct] != $put[pduct])
        {
        /* ÁÖ¹®¼­ Å×À̺í(sub)¿¡ ÇØ´ç ±¸¸ÅÀÚ°¡ ÀÌÀü¿¡ ½ÅûÇÑ »óÇ°ÀÌ ¾øÀ» °æ¿ì ½ÇÇà ÇÕ´Ï´Ù. */

          $numall = $put[num] ;

          error_view($edate,$address,$inmoney,$name);


          mysql_query("insert into sub values('$username','$edate','$put[pduct]',
          '$put[price]','$put[bprice]','$numall','$inmoney','$name','$address')",$connect);
          /* ÇØ´ç ±¸¸ÅÀÚ°¡ ½ÅûÇÑ »õ·Î¿î »óÇ°ÀÇ Á¤º¸¸¦ sub Å×ÀÌºí¿¡ ÀúÀå ÇÕ´Ï´Ù. */
        }
        else
        {
        /* ÇØ´ç ±¸¸ÅÀÚ°¡ »õ·Ó°Ô ½ÅûÇÑ »óÇ°ÀÌ sub Å×ÀÌºí¿¡ Á¸ÀçÇÒ °æ¿ì ½ÇÇà ÇÕ´Ï´Ù. */


          $numall = $put[num] + $put2[num] ;


          mysql_query("update sub set num='$numall'
          where user='$username' and pduct='$put2[pduct]'",$connect);
          /* sub Å×À̺íÀÇ »óÇ°°ú »õ·Ó°Ô ½ÅûÇÑ »óÇ°ÀÌ °°À¸¹Ç·Î °»½ÅÇؼ­ sub Å×ÀÌºí¿¡ ÀúÀå ÇÕ´Ï´Ù. */

        }
      }


      echo("
      <html>
      <body>
      <center>
      <form method=post action=shop.php>
      <font style='font-size:13px;font-style:italic;color:#808080'>
      <b>½Åû µÇ¾ú½À´Ï´Ù</b></font>
      <input type=hidden name=chanl value=sub2>
      <input type=hidden name=sel value=$sel>
      <input type=submit value=È®ÀÎ>
      </form>
      </center>
      </body>
      </html>
      ");
      /* ¸ðµç »óÇ°ÀÇ ÁÖ¹® ÀÔ·ÂÀ» ÇÏ°í ÁÖ¹® ÇöȲ È­¸éÀ¸·Î ¸µÅ©ÇÏ´Â "È®ÀÎ" ¹öÆ°À» »ý¼º ÇÕ´Ï´Ù.*/
    }

ÁÖ¹® ÇöȲ ¸¸µé±â

±×¸². 15-5 »óÇ° ÁÖ¹® ÇöȲ È­¸é
    if($chanl == sub2)
    {
    /* chanlÀÌ sub2ÀÏ °æ¿ì ½ÇÇà ÇÕ´Ï´Ù. */


      $ally=mysql_query("select * from sub where user='$username' ",$connect);
      /* ÇØ´ç ±¸¸ÅÀÚ°¡ ÁÖ¹®ÇÑ »óÇ° Á¤º¸¸¦ sub Å×ÀÌºí¿¡¼­ °Ë»ö ÇÕ´Ï´Ù. */


      mysql_select_db('selectuser',$connect);
      /* ÇØ´ç ±¸¸ÅÀÚ°¡ »ç¿ëÇÑ ID ¼¼¼ÇÀÇ Á¤º¸¸¦ °Ë»öÇϱâ À§ÇØ selectuser µ¥ÀÌÅÍ º£À̽º¸¦ ¼±Åà ÇÕ´Ï´Ù. */


      $ally2=mysql_query("select resident,tel1,id from userin
      where id='$username' ",$connect);
      /* ÇØ´ç ID ¼¼¼ÇÀ» °¡Áø ±¸¸ÅÀÚÀÇ Á¤º¸¸¦ °Ë»ö ÇÕ´Ï´Ù. */


      $put=mysql_fetch_array($ally2);
      /* ÇØ´ç ID ¼¼¼ÇÀÇ Á¤º¸¸¦ $put º¯¼ö¿¡ ÀúÀå ÇÕ´Ï´Ù. */


      $t_num2=mysql_num_rows($ally);
      /* ÇØ´ç ±¸¸ÅÀÚ°¡ ½ÅûÇÑ »óÇ°ÀÇ ¼ö·®À» $t_num2 º¯¼ö¿¡ ÀúÀå ÇÕ´Ï´Ù.*/


      if(!$t_num2)
      {
        echo("
        <script>
        window.alert('ÁÖ¹®ÇÑ »óÇ°ÀÌ ¾ø½À´Ï´Ù.')
        history.go(-1)
        </script>
        ");
        exit;
      }
      /* ÇØ´ç ±¸¸ÅÀÚ°¡ ½ÅûÇÑ »óÇ°ÀÌ ¾øÀ» °æ¿ì Ãâ·ÂÇÏ´Â È­¸é ÀÔ´Ï´Ù. */


      echo("
      <html>
      <title>
      sub html
      </title>
      <body bgcolor=black>
      <center>
      <img src=skyt1.jpg border=0>
      <br>


      <table border=0 cellspacing=2 cellpadding=2 width=600>
      <tr>


      <td bgcolor=white colspan=5 align=center colspan=2>
      <font style='font-size:13px;font-style:italic;color:black'>
      <b> °è»ê¼­~</b></font></td>
      </tr>
      <tr>


      <td bgcolor=#808080 align=center width=200>
      <font style='font-size:13px;font-style:italic;color:#fffff0'>
      <b>~Ç°¸í</b></font></td>


      <td bgcolor=#808080 align=center>
      <font style='font-size:13px;font-style:italic;color:#fffff0'>
      <b>~¼ö·®</b></font></td>


      <td bgcolor=#808080 align=center>
      <font style='font-size:13px;font-style:italic;color:#fffff0'>
      <b>~´Ü°¡</b></font></td>


      <td bgcolor=#808080 align=center>
      <font style='font-size:13px;font-style:italic;color:#fffff0'>
      <b>~Èñ¸Á µµÂøÀÏ</b></font></td>
      </tr>
      ");


      for($pd=$t_num2 ; $pd >= 1 ; $pd--)
      {
      /* ÇØ´ç ±¸¸ÅÀÚ°¡ ½ÅûÇÑ »óÇ°ÀÇ ¼ö·® ¸¸Å­ ·çÇÁ¸¦ ¹Ýº¹ ÇÕ´Ï´Ù. */


        $put2=mysql_fetch_array($ally);
        /* ÇØ´ç ±¸¸ÅÀÚ°¡ ½ÅûÇÑ »óÇ°ÀÇ Á¤º¸¸¦ $put2 º¯¼ö¿¡ ÀúÀå ÇÕ´Ï´Ù. */


        $total = $total+($put2[bprice] * $put2[num]);
        /* ÁÖ¹®ÇÑ »óÇ°ÀÇ ÃÑ °¡°ÝÀ» ±¸ÇÕ´Ï´Ù. */


        echo("
        <tr>
        <td bgcolor=black align=center>
        <font style='font-size:13px;font-style:italic;color:#fffff0'>
        <b>$put2[pduct]</b></font></td>
        /* ÁÖ¹®ÇÑ »óÇ° À̸§À» Ãâ·Â ÇÕ´Ï´Ù. */


        <td bgcolor=black align=center>
        <font style='font-size:13px;font-style:italic;color:#fffff0'>
        <b>$put2[num]ea</b></font></td>
        /* ÁÖ¹®ÇÑ »óÇ°ÀÇ ¼ö·®À» Ãâ·Â ÇÕ´Ï´Ù. */


        <td bgcolor=black align=center>
        <font style='font-size:13px;font-style:italic;color:#fffff0'>
        <b>$put2[bprice]¿ø</b></font></td>
        /* ÁÖ¹®ÇÑ »óÇ°ÀÇ ±âº» ´Ü°¡¸¦ Ãâ·Â ÇÕ´Ï´Ù. */


        <td bgcolor=black align=center>
        <font style='font-size:13px;font-style:italic;color:#fffff0'>
        <b>$put2[wdate]</b></font></td>
        </tr>
        /* ÁÖ¹®ÇÑ »óÇ°ÀÇ Èñ¸Á µµÂø ³¯Â¥¸¦ Ãâ·Â ÇÕ´Ï´Ù. */
        ");
      }


      echo("
      </table>
      <table border=0 cellspacing=2 cellpadding=2 width=600>
      <tr>


      <td bgcolor=#808080>
      <font style='font-size:13px;font-style:italic;color:#fffff0'>
      <b>~¹ÞÀ»ÁÖ¼Ò</b></font></td>


      <td bgcolor=black align=left>
      <font style='font-size:13px;font-style:italic;color:#fffff0'>
      $put2[address]</font></td>
      /* ÁÖ¹®ÇÑ »óÇ°À» ¹ÞÀ» ÁÖ¼Ò¸¦ Ãâ·Â ÇÕ´Ï´Ù. */


      </tr>
      <tr>


      <td bgcolor=#808080><font style='font-size:13px;font-style:italic;color:#fffff0'>
      <b>~Name</b></font></td>


      <td bgcolor=black><font style='font-size:13px;font-style:italic;color:#fffff0'>
      $put2[name]</font></td>
      /* »óÇ°À» ÁÖ¹®ÇÑ ±¸¸ÅÀÚ À̸§À» Ãâ·Â ÇÕ´Ï´Ù. */


      </tr>
      <tr>
      <td bgcolor=#808080><font style='font-size:13px;font-style:italic;color:#fffff0'>
      <b>~Id</b></font></td>


      <td bgcolor=black><font style='font-size:13px;font-style:italic;color:#fffff0'>
      $put[id]</font></td>
      /* »óÇ°À» ÁÖ¹®ÇÑ ±¸¸ÅÀÚÀÇ ID¸¦ Ãâ·Â ÇÕ´Ï´Ù. */


      </tr>
      <tr>


      <td bgcolor=#808080><font style='font-size:13px;font-style:italic;color:#fffff0'>
      <b>~ÁֹιøÈ£</b></font></td>
      <td bgcolor=black><font style='font-size:13px;font-style:italic;color:#fffff0'>
      $put[resident]</font></td>
      /* »óÇ°À» ÁÖ¹®ÇÑ ±¸¸ÅÀÚÀÇ ÁֹΠ¹øÈ£¸¦ Ãâ·Â ÇÕ´Ï´Ù. */


      </tr>
      <tr>


      <td bgcolor=#808080><font style='font-size:13px;font-style:italic;color:#fffff0'>
      <b>~ÀÔ±ÝÀºÇà</b></font></td>


      <td bgcolor=black><font style='font-size:13px;font-style:italic;color:#fffff0'>
      $put2[inmoney] ¿¹±ÝÁÖ:cry 444-44-44-444</font></td>
      /* »óÇ°ÀÇ ´ë±Ý °áÁ¦¸¦ À§ÇÑ ÀºÇàÀ» Ãâ·Â ÇÕ´Ï´Ù. */


      </tr>
      <tr>

      <td bgcolor=#808080><font style='font-size:13px;font-style:italic;color:#fffff0'>
      <b>~Tel</b></font></td>


      <td bgcolor=black><font style='font-size:13px;font-style:italic;color:#fffff0'>
      $put[tel1]</font></td>
      /* »óÇ°À» ½ÅûÇÑ ±¸¸ÅÀÚÀÇ ÀüÈ­¹øÈ£¸¦ Ãâ·Â ÇÕ´Ï´Ù. */


      </tr>
      <tr>
      <td bgcolor=#808080><font style='font-size:13px;font-style:italic;color:#fffff0'>
      <b>~Ãѱݾ×</b></font></td>


      <td bgcolor=black><font style='font-size:13px;font-style:italic;color:red'>
      <b>$total</b>¿ø</font></td>
      </tr>
      /* ±¸¸ÅÀÚ°¡ ½ÅûÇÑ »óÇ°ÀÇ ÃÑ ±Ý¾×À» Ãâ·Â ÇÕ´Ï´Ù. */


      </table>
      <br>
      <table border=0 cellspacing=2 cellpadding=2 width=700 >
      <td bgcolor=black align=center width=200>
      <a href =shop.php?user=$username&sel=$sel>
      <font style='font-size:13px;font-style:italic;color:#ffd700'>
      <b>¼îÇÎ °è¼ÓÇϱâ</b></font></a></td>
      /* ÇØ´ç Á¾¸ñÀÇ ¼îÇÎ ¸ÞÀÎ È­¸éÀ¸·Î ¸µÅ© ÇÕ´Ï´Ù. */
      <td bgcolor=black align=center width=200>
      <a href =shop.php?chanl=item_show&sel=$sel>
      <font style='font-size:13px;font-style:italic;color:#ffd700'>
      <b>¹Ù±¸´Ï</b></font></a></td>


      <td bgcolor=black align=center width=200>
      <a href =shop.php?chanl=del&sel=$sel>
      <font style='font-size:13px;font-style:italic;color:#ffd700'>
      <b>ÁÖ¹®Ãë¼Ò</b></font></a></td>
      /* ÁÖ¹®ÇÑ »óÇ°ÀÇ ÁÖ¹® Ãë¼Ò È­¸éÀ¸·Î ¸µÅ© ÇÕ´Ï´Ù. */


      </tr>
      </table>
      </center>
      </body>
      </html>
      ");
    }

´ÙÀ½ ÀÌÀü Â÷·Ê