<?php $host="localhost"; $username="root"; $password="123456"; $db="crulis"; mysql_connect( $host,$username,$password) or die ("ติดต่อกับฐานข้อมูล Mysql ไม่ได้ "); mysql_select_db($db) or die("เลือกฐานข้อมูลไม่ได้"); $cs1="SET character_set_results=tis620"; mysql_query($cs1) or die("ERR: Results"); $cs2="SET character_set_client=tis620"; mysql_query($cs2) or die("ERR: Client"); $cs3="SET character_set_connection=tis620"; mysql_query($cs3) or die("ERR: Connection"); $sql = "select * from phts"; //คำสั่ง Sql ที่ใช้ $dbq=mysql_query($sql) or die ("ไม่สามารถติดต่อฐานข้อมูลได้"); $numrow=mysql_num_rows($dbq); if($numrow > 0) { $i=1; while($i <= $numrow) { $result=mysql_fetch_array($dbq); $id_ph=$result[id_ph]; $name_photo =$result[name_photo]; $pp =$result[pp]; $numphts =$result[numphts]; ?> <table width="30%"> <td width="7%" ><? echo $i ?></td> <td width="49%"><?php echo $pp ?></td> <td width="44%"><a href="file/count.php?id_ph=<?php echo $id_ph ?>" title="ดาวน์โหลด">ดาวน์โหลด</a>[<?php echo $numphts ?>]</td> </tr> </table> <?php $i++; } } else echo"<br> <br> <font color=red>ไม่พบเอกสาร ! </b>"; ?>
<?php $host="localhost"; $username="root"; $password="123456"; $db="crulis"; mysql_connect( $host,$username,$password) or die ("ติดต่อกับฐานข้อมูล Mysql ไม่ได้ "); mysql_select_db($db) or die("เลือกฐานข้อมูลไม่ได้"); $cs1="SET character_set_results=tis620"; mysql_query($cs1) or die("ERR: Results"); $cs2="SET character_set_client=tis620"; mysql_query($cs2) or die("ERR: Client"); $cs3="SET character_set_connection=tis620"; mysql_query($cs3) or die("ERR: Connection"); $strSQL = "UPDATE phts SET numphts = numphts + 1 WHERE id_ph = '".$_GET["id_ph"]."' "; $objQuery = mysql_query($strSQL); $strSQL = "SELECT * FROM phts WHERE id_ph = '".$_GET["id_ph"]."' "; $objQuery = mysql_query($strSQL); $result = mysql_fetch_array($objQuery); header("location:".$result["name_photo"]); exit(); ?>