|
|
|
รบกวนด้วยครับ ไม่ทราบว่า code นี้ ควร สร้าง DB ว่าอย่างไร Y^Y |
|
|
|
|
|
|
|
Code (read_image.php)
<?php
$conn = mysql_connect("localhost", "root", "123");
mysql_query("USE php_mysql;");
$id = $_GET['id'];
$sql = "SELECT img, img_type FROM topic WHERE topic_id = $id;";
$qry = mysql_query($sql);
$type = mysql_result($qry, 0, "img_type");
header("Content-type: $type");
$data = mysql_result($qry, 0, "img");
echo $data;
mysql_close($conn);
?>
Code (webboard.html)
<html>
<frameset rows="80, *">
<frame name="top" src="webboard_top.html" frameborder="0"
scrolling="no" resize="no">
<frame name="bottom" src="" frameborder="0" scrolling="yes">
</frameset>
</html>
Code (webboard_add_reply.php)
<?php
$conn = mysql_connect("localhost", "root", "123");
mysql_query("USE php_mysql;");
$sql = "INSERT INTO reply VALUES(";
$sql .= "'', '$id', '$message', '$replier'";
$sql .= ");";
mysql_query($sql);
$sql = "UPDATE topic SET reply = reply + 1 ";
$sql .= "WHERE topic_id = $id; ";
mysql_query($sql);
mysql_close($conn);
echo "ข้อมูลของท่านถูกจัดเก็บแล้ว";
exit();
?>
Code (webboard_new_topic.php)
<?php
if(isset($_POST['topic'])) {
if($_FILES['img']['error']==0) {
$temp_file = $_FILES['img']['tmp_name'];
$file = fopen($temp_file, "r");
$img_ = fread($file, filesize($temp_file));
$img = addslashes($img_);
fclose($file);
$type = $_FILES['img']['type'];
}
else {
$img = "";
$type = "";
}
$group = $_POST['group'];
$topic = addslashes($_POST['topic']);
$detail = addslashes($_POST['detail']);
$name = addslashes($_POST['name']);
$conn = mysql_connect("localhost", "root", "123");
mysql_query("USE php_mysql;");
$sql = "INSERT INTO topic VALUES(";
$sql .= "'', '$group', NOW(), '$topic', '$detail', ";
$sql .= "'$name', 0, '$img', '$type'";
$sql .= ");";
mysql_query($sql);
mysql_close($conn);
echo "กระทู้ของท่านถูกจัดเก็บแล้ว";
exit();
}
?>
Tag : PHP
|
|
|
|
|
|
Date :
2013-10-07 00:43:25 |
By :
vwillto |
View :
5869 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
เอิ่ม .. ทุกวันนี้เขาเขียนโค้ดก่อนการสร้าง DB กันแล้วเหรอเนี่ย .. ไม่ได้เข้ามานาน ชักงง
|
|
|
|
|
Date :
2013-10-07 04:02:37 |
By :
deawx |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
เอามาจากไหนครับ น่าจะมี DB มาให้ด้วยน่ะครับ
|
|
|
|
|
Date :
2013-10-07 06:13:56 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 01
|