homepage Welcome to WebmasterWorld Guest from 54.166.96.101
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
New Sites Functionality Query
woldie

10+ Year Member



 
Msg#: 10941 posted 5:49 pm on Nov 28, 2005 (gmt 0)

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.

 

StupidScript

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 10941 posted 7:33 pm on Nov 28, 2005 (gmt 0)

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.

woldie

10+ Year Member



 
Msg#: 10941 posted 8:11 pm on Nov 28, 2005 (gmt 0)

Hi StupidScript,

Thanks for the response.

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

Woldie.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved