|
|
|
ทำนส่วนของ emotion ค่ะ ไม่รู้ผิดพลาดตรงไหนค่ะ รับค่าใน txtbox ได้ แต่บันทึกข้อมูลไม่ได้ |
|
|
|
|
|
|
|
ตาม code เลยค่ะ พอทำการบันทึก ยังได้ค่า :1: , :2: .... มันไม่แปลงเป็น <img src=images/1.gif> .. อ่ะค่ะ
Code (PHP)
if($_POST[action] == "Add")
{
$txt = array(":1:", ":2:",":3:", ":4:", ":5:",":6:", ":7:",":8:", ":9:", ":10:");
$pic = array("1.gif","2.gif","3.gif","4.gif","5.gif","6.gif","7.gif","8.gif","9.gif","10.gif");
for ($i=0 ; $i<sizeof($txt) ; $i++) {
$postmessagereply = str_replace($txt[$i],"<img src=images/$pic[$i]>",$_POST['messagereply']);
}
echo "$postmessagereply";
}
โดยที่ $_POST['messagereply'] เป็นค่าที่รับในการพิมพ์มาค่ะ
โดยทำการ echo "$postmessagereply";
ได้แค่ :1: , :2: ....
ต้องแก้ยังไงคะ
Tag : PHP, HTML/CSS, JavaScript
|
ประวัติการแก้ไข 2011-10-11 12:00:36
|
|
|
|
|
Date :
2011-10-11 11:55:33 |
By :
php.girl |
View :
785 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
จำเป็นต้องวนลูป For ด้วยหรอครับ
Code (PHP)
if($_POST[action] == "Add")
{
$txt = array(":1:", ":2:",":3:", ":4:", ":5:",":6:", ":7:",":8:", ":9:", ":10:");
$pic = array("1.gif","2.gif","3.gif","4.gif","5.gif","6.gif","7.gif","8.gif","9.gif","10.gif");
echo str_replace($txt[$i],"<img src=images/$pic[$i]>",$_POST['messagereply']);
แบบนี้เลยได้ไหมครับ
|
|
|
|
|
Date :
2011-10-11 13:27:38 |
By :
ppanchai |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ตอบคุณ php.girl ครับ
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
if($_POST[action] == "Add")
{
$txt = array(":1:", ":2:",":3:", ":4:", ":5:",":6:", ":7:",":8:", ":9:", ":10:");
$pic = array("1.gif","2.gif","3.gif","4.gif","5.gif","6.gif","7.gif","8.gif","9.gif","10.gif");
for ($i=0 ; $i<sizeof($txt) ; $i++) {
$postmessagereply = str_replace($txt[$i],"<img src=images/$pic[$i]>",$_POST['messagereply']);
}
echo "$postmessagereply";
}
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
คุณลองย้าย echo "$postmessagereply"; ไปไว้ใน for สิครับ แล้วคุณจะรู้ข้อผิดพลาดว่าทำไมถึงเป็นเช่นนั้นครับ
|
|
|
|
|
Date :
2011-10-11 13:34:56 |
By :
zenix |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 04
|