paul_mann wrote in php

Threaded Messages Problem

Hi,

I've been looking at the idea of a simple threaded discussion board as a educational exercise, and I've come up with the following


function thread($array, $parent_id = 0, $level = 0)
{
	while($row=mysql_fetch_row($array))
	{
		while($row[parent_id]==$parent_id)
		{
			$t_parent=$row[id];
			
			echo"$row[subject]
 "; // just basic formating thread($array, $t_parant, $level++); // call self with new data } } } function get_data($sql) { if(!mysql_connect("localhost", "root", "")) { die('failed to connect'); } $result=mysql_db_query("msg_test", $sql); thread($result); //pass the array $result to the function thread }


The table data is as follows (phpmyadmin dump)

#
# Table structure for table `msg`
#

CREATE TABLE msg (
id int(11) NOT NULL auto_increment,
parent_id int(11) NOT NULL default '0',
subject varchar(50) NOT NULL default '',
PRIMARY KEY (id),
UNIQUE KEY id_2 (id),
KEY id (id)
) TYPE=MyISAM;



My problem is that everytime I call the funcition get_data("select * from msg"); IE seems to hang on me. Any sugestions, hints on where I could be going wrong?

Thanks in advance

Paul