Jump to content

Data not printing in table


cmgmyr

Recommended Posts

I have this script:

<?php
$table = "<table border=1>\n";

$sql = "SELECT id FROM categories LIMIT 1";
$result = $db->query($sql);
while($row = $db->fetch($result)){
	$id = $row['id'];
$table .= "
<tr>
<td>$id</td>
<td>".$catalog->crumbs_category2($id)."</td>
</tr>
";
}

$table .= "</table>";
echo $table;
?>

 

<?php
function crumbs_category2($cat_id, $level=0) {  
	global $db;
	$sql = "SELECT parentid, name FROM categories WHERE id = $cat_id";
	$result = $db->query($sql);
	list ($p, $n) = $db->fetchRow($result);

	if ($p != '0') $this->crumbs_category2($p, $level+1);
	echo ($p == '0') ? "$n " : "- $n ";   
}
?>

 

and it outputs this:

Fashion Jewelry <table border=1>

<tr>

<td>1</td>

<td></td>

</tr>

</table>

 

Why is this data not printing in the table?

 

Thanks!

Link to comment
https://forums.phpfreaks.com/topic/64148-data-not-printing-in-table/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.