|
|
|
อยากได้โค้ดการแปลงโค้ดของอีโมออกมาเป็นรูปภาพตอนแสดงผลครับ ไม่ทราบต้องทำอย่างไรบ้างครับ |
|
|
|
|
|
|
|
Code (PHP)
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Welcome</title>
<!-- ไอคอน -->
<script type="text/JavaScript">
function setsmile(what) {
document.form1.message.value = document.form1.elements.message.value+" "+what;
document.form1.message.focus();
}
</script>
</head>
<body background="images/bg.jpg" >
<center><table width="900" height="550" bgcolor="#FFFFFF" border="0" cellpadding="0" cellspacing="0">
<tr>
<td colspan="2"><center>
<?php include("header.php");?>
</center></td>
</tr>
<tr>
<td colspan="2">
<?php include("icon.php"); ?>
</td>
</tr>
<tr >
<td background="images/bgmenu.jpg" valign="top" width="200">
<?php include("menu.php");?>
</td>
<td width="700" height="400" valign="top" >
<center><font size="6" face="Angsana New"><b>แสดงความคิดเห็นและข้อสงสัยเกี่ยวกับเว็บไซต์ </b></font><br/><br/>
[<a href="post.php">ตั้งกระทู้ใหม่</a>]<br/><br/></center>
<table width="600" bgcolor="#FFFFFF" border="0" bordercolor="#FFFFFF" align="center" cellpadding="0" cellspacing="0">
<tr>
<td>
<?
include('config.php');
//หารายระเอียดของคำถาม
$sql = "select * from quiz where id_quiz=$id_quiz";
$dbquery = mysql_db_query($dbname, $sql);
$result = mysql_fetch_array($dbquery);
$id_quiz = $result[id_quiz];
$title = $result[title];
$name = $result[name];
$message = $result[message];
$email = $result[email];
$date_q = $result[date_q];
echo sprintf("<B><FONT COLOR=\"Blue\">%05d</FONT></B>", $id_quiz). " <FONT COLOR=\"Red\">คำถามจาก $name</FONT> $date_q<BR>";
echo "<u>รายละเอียดคำถาม</u> : $message<br/><br/><hr>";
//แสดงคำตอบ
$sql = "select * from ans where id_quiz=$id_quiz order by id_ans";
$dbquery = mysql_db_query($dbname, $sql);
// หาจำนวนเรกคอร์ดข้อมูลในตาราง
$num_rows = mysql_num_rows($dbquery);
if($num_rows==''){
echo "ยังไม่มีใครตอบคำถาม";
}
$i=0;
while ($i < $num_rows)
{
$result = mysql_fetch_array($dbquery);
$id_ans = $result[id_ans];
$id_quiz = $result[id_quiz];
$name = $result[name];
$message = $result[message];
$email = $result[email];
$date_a = $result[date_a];
$date = $result[id_ans];
$n++;
echo "<font color=\"red\"><b>คำตอบที่ $n</b></font> จาก $name <font color=\"#FF6600\">$date_a</font><br/><br/>";
echo "<u>รายละเอียดคำตอบ</u> : $message [$pic] <br/><br/>";
echo "<a href=edit.php?id_ans=".$date['id_ans'] . "> แก้ไข </a>";
echo" ";
echo "<a href=del.php?id_ans=".$date['id_ans'] . "> ลบ </a>";
//$message = eregi_replace($txt[$i],"<img src=\"images/$pic[$i]\">",$message);
echo "<hr color=#FFCC00>";
$i++;
}
// ปิดการติดต่อฐานข้อมูล
mysql_close();
?>
<form name="form1" id="form1" method="post" action="reply.php" >
<table border="0" align="center" cellpadding="0" cellspacing="0">
<tr><td colspan="2" align="center"><font size="6" face="Angsana New"><br><b>ร่วมตอบคำถาม</b></font><br/><br/></td></tr>
<tr><td valign="top" align="right">ชื่อ : </td>
<td><input name="name" type="text" id="name" size="30">
<br></td></tr>
<tr><td valign="top" align="right">อีเมล์ : </td>
<td><input name="email" type="text" id="email" size="30">
<br></td></tr>
<tr><td valign="top" align="right">รายละเอียด : </td>
<td><textarea name="message" cols="35" rows="4" id="message"></textarea></td></tr>
<?
if($action == "Add") {
$txt = array(':1:', ":2:",":3:", ":4:", ":5:");
$pic = array("1.gif","2.gif","3.gif","4.gif","5.gif");
for ($i=0 ; $i<sizeof($txt) ; $i++) {
$message = eregi_replace($txt[$i],"<img src=\"./images/$pic[$i]\">",$message);
}
}
?>
<tr>
<td align="center"><b>emotion : </b></td>
<td><a href="javascript:;" onClick="setsmile(':1:')"><img src="images/1.gif" width="20" height="20" border="0"></a>
<a href="javascript:;" onClick="setsmile(':2:')"><img src="images/2.gif" width="20" height="20" border="0"></a>
<a href="javascript:;" onClick="setsmile(':3:')"><img src="images/3.gif" width="20" height="20" border="0"></a>
<a href="javascript:;" onClick="setsmile(':4:')"><img src="images/4.gif" width="20" height="20" border="0"></a>
<a href="javascript:;" onClick="setsmile(':5:')"><img src="images/5.gif" width="20" height="20" border="0"></a></td>
</tr>
<tr><td colspan="2" align="center">
<input type="submit" name="Submit" value="ตอบคำถาม">
<input type="reset" name="Submit2" value="ยกเลิก">
<input type="hidden" name="id_quiz" value="<? echo $id_quiz;?>">
</td></tr>
</table>
</form>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td colspan="2" width="900" height="125" >
<?php include("footer.php");?>
</td>
</tr>
</table></center>
</body>
</html>
|
|
|
|
|
Date :
2012-02-23 20:55:59 |
By :
donhongsa |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
<?php
class BbCode //by num
{
var $bb = array(
'b'=>array('/\[b\](.+?)\[\/b\]/is','<span class="bold">$1</span>'),
'i'=>array('/\[i\](.+?)\[\/i\]/is','<span class="italic">$1</span>'),
'u'=>array('/\[u\](.+?)\[\/u\]/is','<span class="underline">$1</span>'),
'img'=>array('/\[img\]\s*(http:.+?)\[\/img\]/i','<img src="$1" />'),
'url'=>array('/\[url\]\s*(http:.+?)\[\/url\]/i','<a href="$1">$1</a>'),
'url2'=>array('/\[url=\s*(http:.+?)\](.+?)\[\/url\]/is','<a href="$1">$2</a>'),
);
var $_CSRF = array('img');
var $_key;
function h($s){
return htmlspecialchars($s);
}
function style(){
$s = '<style type="text/css">'.
'.bold {font-weight:bold;}'.
'.italic {font-style:italic;}'.
'.underline {text-decoration:underline;}'.
'</style>';
return $s;
}
function _bb($backref){
unset($backref[0]);
$a = array();
$n = 0;
while(isset($backref[++$n])) {
if (in_array($this->_key,$this->_CSRF)) {
$backref[$n] = preg_replace('/\?/is','#illegal#', $backref[$n]);
}
$a[] = '$'.$n;
}
$s = str_replace($a,$backref,$this->bb[$this->_key][1]);
return $s;
}
function html($s,$escape=true,$csrf=true,$bb=array())
{
$temp = $this->_CSRF;
if (!$csrf)
$this->_CSRF = array();
if ($escape)
$s = $this->h($s);
if ($bb===array())
$bb = array_keys($this->bb);
foreach($bb as $key){
$this->_key = $key;
$s = preg_replace_callback($this->bb[$key][0],
array($this,'_bb'),$s);
}
$this->_CSRF = $temp;
return $s;
}
}
$s1 = 'bb code string';
$s2 = 'bb code string';
$b = new BbCode();
echo $b->style();
echo $b->html($s1);
echo '<hr/>';
echo $b->html($s2);
?>
Go to : ใครมี script เปลี่ยน bbcode เป็น html บ้างครับ ขอซื้อต่อหน่อย
|
|
|
|
|
Date :
2012-02-24 06:36:49 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอบคุณพี่วินมากครับ
|
|
|
|
|
Date :
2012-02-24 12:00:32 |
By :
donhongsa |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
พี่วินครับ...ในโค้ดของผมส่วนในหรอครับที่มันส่งค่าของอีโมแล้วให้มาแสดงเป็นตัวอีโมออกมา อะครับ
|
|
|
|
|
Date :
2012-02-24 12:06:21 |
By :
donhongsa |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ตัวอย่างกระทู้นี้ครับ
Code (BBCode)
$text = str_replace(": lol:",'<img src="/images/bbcode/lol.gif" align="absmiddle">', $text);
$text = str_replace(": ken:",'<img src="/images/bbcode/ken.gif" align="absmiddle">', $text);
$text = str_replace(": -D:",'<img src="/images/bbcode/grin.gif" align="absmiddle">', $text);
$text = str_replace(": -):",'<img src="/images/bbcode/smile.gif" align="absmiddle">', $text);
$text = str_replace(": -)",'<img src="/images/bbcode/smile.gif" align="absmiddle">', $text);
$text = str_replace(": ;):",'<img src="/images/bbcode/wink.gif" align="absmiddle">', $text);
$text = str_replace(" : eek:",'<img src="/images/bbcode/eek.gif" align="absmiddle">', $text);
$text = str_replace(": geek:",'<img src="/images/bbcode/geek.gif" align="absmiddle">', $text);
$text = str_replace(": roll:",'<img src="/images/bbcode/roll.gif" align="absmiddle">', $text);
$text = str_replace(": erm:",'<img src="/images/bbcode/erm.gif" align="absmiddle">', $text);
$text = str_replace(": cool:",'<img src="/images/bbcode/cool.gif" align="absmiddle">', $text);
$text = str_replace(": blank:",'<img src="/images/bbcode/blank.gif" align="absmiddle">', $text);
$text = str_replace(": idea:",'<img src="/images/bbcode/idea.gif" align="absmiddle">', $text);
$text = str_replace(": ehh:",'<img src="/images/bbcode/ehh.gif" align="absmiddle">', $text);
$text = str_replace(": aargh:",'<img src="/images/bbcode/aargh.gif" align="absmiddle">', $text);
$text = str_replace(": evil:",'<img src="/images/bbcode/evil.gif" align="absmiddle">', $text);
Go to : อยากได้โค้ดการแปลงโค้ดอีโมออกมาเป็นรูปภาพตอนที่แสดงผลออกมาบนหน้าเวบ
|
|
|
|
|
Date :
2012-02-24 13:07:05 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 00
|