You are here: yahoo like directory « PHP Language « IT news, forums, messages
yahoo like directory

Posted by gagal on 07/20/07 07:37

I had the not so bright idea to put a yahoo like web directory on my
site. After much frustration, I have made some progress. I get:
*********************************
Web Directory

* Marital Bliss
* Programming
* Education

There are no links for this category.
*********************************
When you click on marital bliss you should get the sub-categories
cheating and weddings. I get nothing. Same for programming and
Education. I get that I messed up doing recursion somewhere, but I
have no clue how or where. HELP!!!

PS. I also wanted path displayed as HOME-PROGRAMMING-PHP-PHP SCRIPTS.
I messed that up too. I have no path displayed.

function getCategoryPath($catid, $catname, $connect, $db_table7)
{
$path = "";
if ($catid == 0)
{
$path = "<B>Web Directory</B>";
}
else
{
while ($catid > 0)
{
$sql = "SELECT id, name FROM $db_table7 WHERE id=$catid";
$result = mysql_query ($sql, $connect) or die ('Query GCP1 failed:
' .mysql_error());
if ($result)
{
if (mysql_num_rows($result) == 0)
$catid = 0;
else
{
$row = mysql_fetch_assoc($result);
if (strlen($path) == 0)
$path = "<B>" . $row['name'] . "</B>";
else
{ // Create links on the parent categories
$path = "<A HREF='$sPage?category_id=$catid'>" . $row['name'] . "</
A>&nbsp;&gt;&nbsp;" . $path;
}
$catid = $row['parent'];
}
mysql_free_result($result);
}
else
{
echo "Cannot read $db_table7 table.<BR>Error#: ". mysql_errno() . ";
Description: " . mysql_error() . "<BR>";
$catid = 0;
}
}
$path = "<A HREF='$sPage?category_id=0'>My Web Directory</
A>&nbsp;&gt;&nbsp;" . $path;
}
return $path;
}

function getCategories ($catid, $catname, $connect, $db_table7)
{
$sql = "SELECT id, name, parent FROM $db_table7 WHERE
parent='$catid'";
$result = mysql_query ($sql, $connect) or die ('Query DL1 failed:
' .mysql_error());
if ($result)
{
if (mysql_num_rows($result) > 0)
{
echo "<UL>";
while ($row = mysql_fetch_assoc($result))
{
echo "<LI><A HREF='index.php?category_id=" . $row['id'] . "'>";
echo $row['name'] . "</A></LI>\n";
}
echo "</UL>\n";
}
else
echo "<P>There are no subcategories for this category.</P>";
mysql_free_result($result);
echo "<HR>";
}
}

function getLinks ($catid, $catname, $connect, $db_table8)
{
$sql = "SELECT name, url, description FROM $db_table8 WHERE
category='$catid' ORDER BY name ASC";
$result = mysql_query ($sql, $connect) or die ('Query GL1 failed:
' .mysql_error());
if ($result)
{
if (mysql_num_rows($result) > 0)
{
echo "<DL>";
while ($row = mysql_fetch_assoc($result))
{
$url = $row["url"];
$name = $row["name"];
$description = $row["description"];
echo "<DT><A HREF='$url' TARGET='_blank'>$name</A>";
echo " <DD>$description<BR><BR>";
}
echo "</DL>";
}
else
echo "<P>There are no links for this category.</P>";
mysql_free_result($result);
}
}
?>

<?PHP
echo getCategoryPath($catid, $catname, $connect, $db_table7,
"index.php");

getCategories ($catid, $catname, $connect, $db_table7);

getLinks ($catid, $catname, $connect, $db_table8);

?>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация