
14-09-2006, 22:04
|
 |
|
|
חבר מתאריך: 02.10.05
הודעות: 2,355
|
|
|
בעיה בפורום רקורסיבי- הצגת הפורום
אוקי, זה הקוד שהכנתי:
קוד PHP:
<?php header("Content-type: text/html; charset=utf8"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html dir="rtl"> <head> <title>פורום!</title> <style type="text/css"> div.cat_main { margin-top: 8px; color: #9F6363; }
div.cat_sub { margin-right: 20px; color: #CFA8A8; } .vis { display : block; } .nvis { display : none; } </style> <script type="text/javascript"> <!-- function disNabale(divObjects) { if(document.getElementById(divObjects).className== 'vis') document.getElementById(divObjects).className='nvi s'; else document.getElementById(divObjects).className='vis '; } //--> </script> </head>
<body>
<?php
include('db.php');
function printTreePost($deep, $id) { global $cats; foreach($cats[$id] as $key => $cat) { if($key == 0) { echo '<div class="cat_main">'.$cat['title'].'</div>'; } $nDeep = $deep * 20; echo '<div style="margin-right: '.$nDeep.'px; color: #CFA8A8;" >'.$cat['title'].'</div>'."\n"; if(isset($cats[$cat['id']])) printTreePost(++$deep, $cat['id']); } } $start = mysql_query('SELECT * FROM `forum_messeges` ORDER BY `parent`') OR die('Error on query MySQL said: '.mysql_error()); $post = 1;
while($info = mysql_fetch_array($start)) { if($info['parent'] == 0) { $cats[$info['id']][0]['parent'] = TRUE; $cats[$info['id']][0]['title'] = $info['title']; $cats[$info['id']][0]['id'] = $info['id']; //all over information.. here continue; } $key = count($cats[$info['parent']]); $cats[$info['parent']][++$key]['parent'] = FALSE; $cats[$info['parent']][++$key]['title'] = $info['title']; }
foreach($cats as $sub) { printTreePost(1, $sub); } ?> </div> </body> </html>
וזה מחזיר לי את ההודעות שגיאה הבאות:
Notice: Undefined index: 2 in C:\Apache2\htdocs\lowar\forum_display.php on line 79
Notice: Undefined index: 3 in C:\Apache2\htdocs\lowar\forum_display.php on line 79
Warning: Illegal offset type in C:\Apache2\htdocs\lowar\forum_display.php on line 54
Warning: Invalid argument supplied for foreach() in C:\Apache2\htdocs\lowar\forum_display.php on line 54
Warning: Illegal offset type in C:\Apache2\htdocs\lowar\forum_display.php on line 54
Warning: Invalid argument supplied for foreach() in C:\Apache2\htdocs\lowar\forum_display.php on line 54
Warning: Illegal offset type in C:\Apache2\htdocs\lowar\forum_display.php on line 54
Warning: Invalid argument supplied for foreach() in C:\Apache2\htdocs\lowar\forum_display.php on line 54
מישהו יכול לפתור את הבעיה או לכוון אותי לפיתרון?
_____________________________________
|