 |
สอบถามการดึงบางคำมาแสดงจากรายละเอียดที่เก็บไว้ในฐานข้อมูลค่ะ |
|
 |
|
|
 |
 |
|
Code (PHP)
$text = 'This is an example of quite long text or sentence and we want to cut it to use as an excerpt';
$max_char = 45;
echo substr($text, 0, $max_char) . '...';
ถ้า Content จำนวนข้อความไม่เท่ากันอาจจะใช้ไม่ได้ครับ จะทำได้ต้องตัดจำนวนคำให้เท่ากัน
|
 |
 |
 |
 |
Date :
2018-09-24 14:27:19 |
By :
Manussawin |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ถ้าดึงเฉพาะส่วนน้ได้มั้ยคะ
รหัส 4B17-82(ผ่อนเพียง 25,266บ.) เด๋ยวก๊อปแค่รหัสแยกเองอ่ะค่ะ
|
 |
 |
 |
 |
Date :
2018-09-24 15:35:23 |
By :
because |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ถ้าจะค้นหาเป็นมหภาค ต้องหาให้ได้ว่ามีอะไร ที่เป็น pattern .ในการค้นหา
เช่น สัญญลักษณ์แทนการขึ้นบันทัดใหม่ วงเล็บ
ถ้าไม่มี pattern ก็จะคิวรี่ไม่ได้ ค้นหาเป็น มหภาค ไม่ได้
|
 |
 |
 |
 |
Date :
2018-09-24 16:53:01 |
By :
Chaidhanan |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
รบกวนพี่ๆและอาจารย์ ช่วยดูให้ทีนะคะ ไม่รู้เขียนผิดตรงไหน
ไฟล์ที่ดึงมาจากตาราง tabletb ฟิลด์ message อ่ะค่ะ
This site uses cookies to deliver our services and to show you relevant ads and job listings. By using our site, you acknowledge that you have read and understand our Cookie Policy, Privacy Policy, CODE 4B5F-01 (PRICE) our Terms of Service. Your use of Stack Overflow’s Products and Services, including the Stack Overflow Network, is subject to these policies and terms.
ส่วนอันนี้ Code mี่ลองแกะๆดูค่ะ แต่ไม่แสดงผล แต่น่าจะใกล้เคียงนะคะ
Code (PHP)
<?php
require_once "connectdb.php";
$sqltb="select * from tabletb where id=1";
$db_query=mysql_query($sqltb);
$resultp=mysql_fetch_array($db_query);
$message=$resultp[message];
$ch=curl_init('$message');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$page = curl_exec($ch);
preg_match('#CODE[^>]*(.+?)(PRICE[^>]*)#is', $page, $matches);
foreach ($matches as &$match) {
$match = $match;
}
// echo '<table>';
echo "<b>$matches[0]</b>";
//echo '</table>';
?>
</body>
</html>
|
 |
 |
 |
 |
Date :
2018-09-25 08:21:28 |
By :
because |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ได้แล้วค่ะอาจารย์
echo $result_match[1][0];
ขอบพระคุณมากเลยค่ะ และขอบคุณทุกท่านด้วยนะคะ ใจดีกันจัง
|
 |
 |
 |
 |
Date :
2018-09-25 10:24:06 |
By :
because |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|