
Dow.php
01.<?02.$host="localhost";03.$username="root";04.$password="123456";05.$db="crulis";06.mysql_connect( $host,$username,$password) or die ("ติดต่อกับฐานข้อมูล Mysql ไม่ได้ ");07.mysql_select_db($db) or die("เลือกฐานข้อมูลไม่ได้");08.$cs1="SET character_set_results=tis620";09.mysql_query($cs1) or die("ERR: Results");10.$cs2="SET character_set_client=tis620";11.mysql_query($cs2) or die("ERR: Client");12.$cs3="SET character_set_connection=tis620";13.mysql_query($cs3) or die("ERR: Connection");14.$sql = "select * from phts"; //คำสั่ง Sql ที่ใช้15.$dbq=mysql_query($sql) or die ("ไม่สามารถติดต่อฐานข้อมูลได้");16.$numrow=mysql_num_rows($dbq);17. 18.if($numrow > 0)19.{20.$i=1;21.while($i <= $numrow)22.{23.$result=mysql_fetch_array($dbq);24.$id_ph=$result[id_ph];25.$name_photo =$result[name_photo];26.$pp =$result[pp];27.$numphts =$result[numphts];28.?>29.<table width="30%">30.<td width="7%" ><? echo $i ?></td>31.<td width="49%"><?=$pp ?></td>32.<td width="44%"><a href="file/count.php?id_ph=<?=$id_ph ?>" title="ดาวน์โหลด">ดาวน์โหลด</a>[<?=$numphts ?>]</td>33.</tr>34.</table>35.<?36.$i++;37.}38.}39.else40.echo"<br> <br> <font color=red>ไม่พบเอกสาร ! </b>";41.?>count.php
01.<?02.$host="localhost";03.$username="root";04.$password="123456";05.$db="crulis";06.mysql_connect( $host,$username,$password) or die ("ติดต่อกับฐานข้อมูล Mysql ไม่ได้ ");07.mysql_select_db($db) or die("เลือกฐานข้อมูลไม่ได้");08.$cs1="SET character_set_results=tis620";09.mysql_query($cs1) or die("ERR: Results");10.$cs2="SET character_set_client=tis620";11.mysql_query($cs2) or die("ERR: Client");12.$cs3="SET character_set_connection=tis620";13.mysql_query($cs3) or die("ERR: Connection");14. 15.$strSQL = "UPDATE phts SET numphts = numphts + 1 WHERE id_ph = '".$_GET["id_ph"]."' ";16.$objQuery = mysql_query($strSQL);17. 18.$strSQL = "SELECT * FROM phts WHERE id_ph = '".$_GET["id_ph"]."' ";19.$objQuery = mysql_query($strSQL);20.$result = mysql_fetch_array($objQuery);21. 22.header("location:".$result["name_photo"]);23.exit();24.?>
No comments:
Post a Comment