Welcome to WebmasterWorld Guest from 23.20.238.193

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

New Sites Functionality Query

     
5:49 pm on Nov 28, 2005 (gmt 0)

10+ Year Member



Hi again,

I've come across a new problem which is really annoying me!

Anyway what I have is a SQL query which gets the latest sites submitted over a certain period. Now I get all the data I need into a WHILE loop, and for each site listed it displays the site details and the category of where it belongs.

This is where I get the problem which is something similar in my previous post.

What it is displaying now is the following...

Name of Site

Description

Home > Computers > Programming > Delphi and BCB > VCL Components >

Name of Site

Description

Home > Computers > Programming > Delphi and BCB > VCL Components >
Home > Arts > Animation > Web Rings >

Name of Site

Description

Home > Computers > Programming > Delphi and BCB > VCL Components >
Home > Arts > Animation > Web Rings >
Home > Arts > Animation > Web Rings >

You see where I am getting at? Frustrating.

Now I am having that same problem with the function.

Here's the code:

function nav ($id,$x='')
{
$result=mysql_query("select cat_name,parentid
from db_categories
where catid=$id");
list($DBcat_name,$DBparentid1)=mysql_fetch_row($result);
mysql_free_result($result);
$cat_name=str_replace(" ","-",$DBcat_name);
$x="$cat_name-$id/".$x;
#echo $id .'<br>';
if($id>0)
$x=nav($DBparentid1,$x);
#echo $x;

return $x;
}

$result=mysql_query("select lid,parentid,cat_name,title,url,description,link_date
from db_links,db_categories
where to_days(now()) - to_days(link_date) between 0 and 30
and db_links.catid=db_categories.catid
and approved=1
order by link_date desc
limit 3");

while (list($DBlid,$DBparentid,$DBcat_name,$DBtitle,$DBurl,$DBdescription,$DBlink_date)=mysql_fetch_row($result))
{
echo "<a href=\"$DBurl\" class=\"list4\"><strong>$DBtitle</strong></a>";
echo "<div id=\"desc_con\">$DBdescription<br /><br />";

// Category
$sql_result=mysql_query("select catid
from db_links
where lid=$DBlid");

list($DBcatid)=mysql_fetch_row($sql_result);
$url[]=nav($DBcatid);

foreach ($url as $u)
{
$u = substr($u,37);
$t=$u;
$t=str_replace("-"," ",$t);
$t=str_replace("/"," > ",$t);
$t=ereg_replace("[0-9]"," ",$t);
$location=$base_url.'/'.$u;

echo "<a href=\"$base_url/$u\" class=\"list4\">Home > $t</a><br>";
}

echo "</div>";

}

Any help is much appreciated..

If I don't get this to work then I might have to store the URL of the category in a table, and do it that way!

Any help always appreciated

Woldie.

7:33 pm on Nov 28, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



After you print the array elements for each item, reset the array:

foreach ($url as $u) {

...

}

$url=array();

Without something like that, you just keep appending items to the

$url
array, which then print with each subsequent
foreach
loop.
8:11 pm on Nov 28, 2005 (gmt 0)

10+ Year Member



Hi StupidScript,

Thanks for the response.

Yep that did work. So simple in the end as well, sheesh!

Woldie.

 

Featured Threads

Hot Threads This Week

Hot Threads This Month