
08-10-2007, 14:44
|
|
|
|
חבר מתאריך: 21.01.06
הודעות: 813
|
|
|
בעיה עם While
השתמשתי בwhile וfetch array כדי להציג את כל התוצאות של החיפוש בטבלה
קוד PHP:
<html dir=rtl> <head> <title>חיפוש באתר</title> <style type="text/css"> input { font-family: arial; font-size: 9pt; font-weight: bold; } </style> <body> <? require ("config.php"); // require sql connection ?> <br> <center> <? $res = $_GET['seek']; if (isset ($_GET['sendseek'])) { $wordfors = $res; $result = mysql_query ("SELECT * FROM articles WHERE `body` LIKE '%$wordfors%'"); $col = mysql_query ("SELECT * FROM colors"); $colors = mysql_fetch_array ($col); // the colors for design this paper ?> <b><font face="arial" size="2">תוצאות חיפוש: </font></b> <? $ress = mysql_num_rows ($result); echo '<font face="arial" size="2" color="red">'; echo " נמצאו "; echo $ress; echo " תוצאות "; echo "</font><br><br>"; echo '<table bgcolor="#00000"><tr><td><font face="arial" size="2" color="white"><b>תוכן</font></b></td><td><font face="arial" size="2" color="white"><b>נכתב על ידי</td></tr></font></b>'; while ($resulta = mysql_fetch_array ($result)) { $resulta['body'] = str_replace($wordfors, '<font face="arial" size="3" color="red"><b>'.$wordfors.'</b></font>', $resulta['body']); echo '<tr><td width="500" bgcolor='. $colors['color'] .'><font face="arial" size="2">' . $resulta['body'] . '</font>'; // גוף ההודעה echo '</td><td bgcolor='. $colors['color'] .' width="80"><font face="arial" size="2">' . $resulta['sender'] . '</font>'; // שולח ההודעה echo "</td></tr></table></b></font>"; } } else echo "<font face='arial' size='2'><b>לא נמצאה מילת החיפוש</font></b>"; ?> </body> </html>
הבעיה היא, שבמקום להציג את כל תוצאות החיפוש (גוף ההודעה ושולח ההודעה) כל אחד לטבלה,
זה מציג רק טבלה אחת בה הגוף והשולח של הממצא הראשון ושאר הממצאים זה עושה בלי טבלה..
מה הבעיה?
תודה.
_____________________________________
--- ! Area Close ! ---
|