הוסטס - פורום אחסון האתרים הגדול בישראל

הוסטס - פורום אחסון האתרים הגדול בישראל (https://hosts.co.il/forums/index.php)
-   פורום תיכנות (https://hosts.co.il/forums/forumdisplay.php?f=14)
-   -   [עזרה] איך אני עושה שיראו חלק מטקסט? [php] (https://hosts.co.il/forums/showthread.php?t=56331)

dudu 11-11-07 11:55

כנראה שלא הצבתי נכון...

מי שיכול לבוא לאסיקיו: 8385282

או כאן לעזור לי להציב..

תודה.

חיים 11-11-07 11:59

ציטוט:

נכתב במקור על ידי dudu (פרסם 577540)
כנראה שלא הצבתי נכון...

מי שיכול לבוא לאסיקיו: 8385282

או כאן לעזור לי להציב..

תודה.

אפשר לקבל +- תקוד שכתבת?

dudu 11-11-07 12:01

זה הקוד:


<html dir="rtl">
<body bgcolor=#ECECEC>
<font face='Arial'><span style='font-size: 12pt; font-weight: 700'>




<?php


mysql_connect("localhost","******","************** ");
mysql_select_db("**_i**");

$query = mysql_query("SELECT * FROM `topics` ORDER BY `id` DESC LIMIT 30 ");



while($array = mysql_fetch_array($query)) {





$array["poster"] = str_replace("<","<",$array["poster"]);
$array["poster"] = str_replace(">",">",$array["poster"]);
$array["title"] = str_replace("<","<",$array["title"]);
$array["title"] = str_replace(">",">",$array["title"]);
$array["FCKeditortext"] = str_replace("<","<",$array["FCKeditortext"]);
$array["title"] = str_replace(">",">",$array["title"]);
$array["text"] = str_replace(">",">",$array["text"]);
$array["text"] = str_replace(">",">",$array["text"]);
$array["date"];
$array["id"];






echo "<br>
<table align='center' border='0' cellpadding='0' cellspacing='0' style='border-collapse: collapse' bordercolor='#111111' width='650' height='81' id='AutoNumber1'>
<tr>
<td width='330' height='12' bgcolor='#0077A9'>
<img src=".$array["pic"]." height=100 width=100 border=1 align=right >
<div align='center'>
&nbsp;&nbsp;&nbsp;&nbsp;
<font size=6><b>
".$array["title"]." &nbsp;&nbsp; &nbsp;&nbsp;
</font></b></div>
<BR>
<font size=2><b>
[מאת: ".$array["poster"]."]
[תאריך: ".$array["date"]."]
# ".$array["id"]."
</font></b>
<br>
<font size=3><b>
תיאור: ".$array["t"]." &nbsp;&nbsp;&nbsp;&nbsp;
<BR>
נושא: ".$array["cat"]." &nbsp;&nbsp;&nbsp;&nbsp;
</font></b>
</p></td>
</tr>
<td width='330' height='12' bgcolor='#818181' >

</p>
<p align='right'> ".$array["FCKeditortext"]." </p><br>
<a href=". $url.$_FILES['myfile']['name']. ">". $url.$_FILES['myfile']['name'] ."<a/>
</td>
</tr>
</table>


</center>";




<?php
mysql_close();
?>

opsite 11-11-07 12:24

HTML קוד:

$tt = substr($המשתנה או הטקסט, 0, 14). '...';

DanielS 11-11-07 12:31

אתה שאלת את זה לפני כמה חודשים. היה אשכול ענק עם פולל הסברים.
למה אתה לא מסתכל אחורה ?

dudu 11-11-07 13:45

כי אז לא הצלחתי להבין..

Ron | CSite.co.il 11-11-07 13:52

האשכול הזה הוא שכפול מדוייק של הקודם ,
ולפי מה שזכור לי תומר נעל אותו .
לדעתי הסבירו לך פה יפה מאוד הכל וגם באשכול הקודם ,אתה פשוט מחפש קוד.

יניב בן צבי 11-11-07 22:42

תשתמש בפונקציה substr

miniature 11-11-07 23:44

הנה:
PHP קוד:

<?php
$str 
"משפט כלשהו..";
$strAfter substr($str,0,strrpos(substr($str,0,500)," "));
echo 
$strAfter "...\n";
?>

*שנה את 500 למקסימום התווים (אחריהם המחרוזת נקטעת)
גם מטפל בחיתוך המילה באמצע (אם זה באמצע מילה זה לא חותך אלא מחפש את הרווח הקרוב ביותר).
אני ממליץ לך לעשות תנאי שבודק עם strlen אם המילה ארוכה ממקסימום התווים.
בהצלחה :)


כל הזמנים הם GMT +2. הזמן כעת הוא 02:39.

מופעל באמצעות VBulletin גרסה 3.8.6
כל הזכויות שמורות ©
כל הזכויות שמורות לסולל יבוא ורשתות (1997) בע"מ