| |||||||
| المدوّنات | البحث | مشاركات اليوم | اجعل كافة المشاركات مقروءة |
|
| | LinkBack | أدوات الموضوع |
| |||||
| في جملة الـ While كيف إضافة شرط آخر على هذه الجملة كود: while ($thread = mysql_fetch_array( $result )) { والشرط الجديد الذي أريد أن أضيفه هو: كود: $thread = mysql_fetch_array( $result ) جربت هذا ولم يعمل كود: while ($thread = mysql_fetch_array( $result ) AND $post = mysql_fetch_array( $result ) ) { لأني أريد استخدامها في: http://swalif.net/softs/showthread.php?threadid=9311 وتحياتي للجميع | |||||
|
| |||||
|
هلا عزيزي إنت كتبت الجملة الشرطية بشكل صحيح .. بإستخدام AND لكن المشكلة في جزء آخر .. ألا تلاحظ معي أنك تقوم بتمرير نفس القيمة الى المتغيرين .. $post $thread $thread = mysql_fetch_array( $result ) AND $post = mysql_fetch_array( $result ) حيث أن عدد الدورات سيكون هو نفسه في حالة أضفت الشرط الآخر أم لم تضفه .. لتساوي قيمة المتغيرين . أتمنى لو تراجع الكود مرة أخرى .. أو تبين الفكرة فلربما إستطعت مساعدتك .. بالنسبة لرسالة سابقة أعتذر على التأخر في الرد .. لكني لاأدري إن كان أحد الأخوة قد أجاب أم لأ .. لكن إذا أردت جديا تغيير إسم الصفحة وإسم المتغير .. فكل ماعليك هو ( بعد تغيير المتغير في التيمبليتز كما ذكرت ) أن تقوم بحفظ نسخة أخرى من نفس الملف showthread بإسم آخر وتعمل على النسخة الأولى ... قم بتغيير كل كلمة threadid الى أي إسم تريدة ثم قم بمراجعة الصفحات newreply newpost على حسب ذاكرتي إن لم تخني ... وكذا common وقم بتغيير المتغير الى نفس القيمة ... لكن تأكد من أن القيمة الجديدة ليست مستخدمة من قبل كاتب السكريبت .. وإلا ستخلق الكثير من المشاكل .. هذا في نبذة مصغرة .. والله ولي التوفيق . | |||||
|
| |||||
|
ليش البرنامج مابشتغل قمت بتعديل الـ while وأضفت الـ post و pagetext في جملة الـ select كود: <?
// The number of posts you want to see
$count = 5;
// url to the forum
$forum_url = 'http://localhost/vb/';
require("admin/config.php");
$db=mysql_connect($servername,$dbusername,$dbpassword);
mysql_select_db($dbname);
$db_conn = mysql_connect( $dbserver, $dbuser, $dbpass );
$result = mysql_db_query($dbname, "SELECT post.pagetext AS pagetext,thread.threadid AS id,thread.title AS title,thread.replycount AS replycount,thread.forumid AS forumid,forum.title AS forumtitle FROM post,thread,forum WHERE forum.forumid = thread.forumid ORDER BY thread.lastpost DESC LIMIT $count" , $db_conn);
while (($thread == mysql_fetch_array($result)) AND ($post == mysql_fetch_array($result))) {
$text = $thread["title"] . " : " . $thread["threadindex"] . $post["pagetext"];
$text = strip_tags(substr( $text, 0, 51 ));
echo $text . " <a href='".$forum_url."showthread.php?threadid=".$thread["id"]."'>التفاصيل</a><br>";
}
mysql_close( $db_conn );
?> | |||||
|
| |||||
| كود: $thread = mysql_fetch_array($result) كود: $thread == mysql_fetch_array($result) عموماً بما ان post و thread هي ناتجة من نفس الدالة فلا داع للمتغير post فمثلاً اذا كنت تريد $post["pagetext"] بامكانك قرأتها باستخدام $thread["pagetext"] دون اضافة جملة لقرأة post | |||||
|
| |||||
|
أخي لو نظرت إلى المخطط(schema) كود: Table forum ============ forumid title description active displayorder replycount lastpost lastposter threadcount categoryid allowposting daysprune forumtemplate headertemplate useadvheader footertemplate useadvfooter forumbittemplate threadtemplate threadbittemplate replytemplate newthreadtemplate edittemplate rulestemplate titleimage replyimage newthreadimage closedthreadimage newpostemail newthreademail moderatenew allowbbcode allowimages allowhtml allowsmilies Table post ========== postid threadid username userid title dateline pagetext allowsmilie email signature ipaddress iconid visible Table tread ============ threadid title lastpost forumid open replycount postusername lastposter dateline views iconid notes visible subjectindex threadindex userindex forumid وهو موجدود في Table forum و Table tread أما pagetext فهو موجود في Table post ============ ولو نظرت في البرنامج: كود:
<?
// The number of posts you want to see
$count = 5;
// url to the forum
$forum_url = 'http://localhost/vb/';
require("admin/config.php");
$db=mysql_connect($servername,$dbusername,$dbpassword);
mysql_select_db($dbname);
$db_conn = mysql_connect( $dbserver, $dbuser, $dbpass );
$result = mysql_db_query($dbname, "SELECT post.pagetext as pagetext,thread.threadid AS id,thread.title AS title,thread.replycount AS replycount,thread.forumid AS forumid,forum.title AS forumtitle FROM post,thread,forum WHERE forum.forumid = thread.forumid ORDER BY thread.lastpost DESC LIMIT $count" , $db_conn);
while ($thread = mysql_fetch_array( $result ) ) {
$text = $thread["title"] . " : " . $thread["threadindex"] ." : " . $post["pagetext"];
$text = strip_tags(substr( $text, 0, 160 ));
echo $text . " <a href='".$forum_url."showthread.php?threadid=".$thread["id"]."'>مزيد من التفاصيل</a><br>";
}
mysql_close( $db_conn );
?> ويشتغل وشكراً وأرجوك مراسلتي على إيميلي: zalamah@yahoo.com | |||||
|
| |||||
|
اعذرني اخي عندي ظروف هذه الايام تمنعني من التركيز في اي شي (صدق واللة) ، عموماَ لا اعلم مدى صحة جملة SQL لكن جرب تغير جملة while السابقة بما يلي: كود: while ($thread == mysql_fetch_array($result) {
$text = $thread["title"] . " : " . $thread["threadindex"] . $thread["pagetext"];
$text = strip_tags(substr( $text, 0, 51 ));
echo $text . " <a href='".$forum_url."showthread.php?threadid=".$thread["id"]."'>التفاصيل</a><br>";
} | |||||
|
![]() |
| |
| |
| أدوات الموضوع | |
| |