SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    Feel my RewiredMind KMxRetro's Avatar
    Join Date
    Jan 2001
    Location
    Exeter, Devon, UK
    Posts
    477
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi there all once again,
    I'm currently creating a kind of Yahoo! style section for my new website (where've you heard this before? ) and am having problems deciding on which route to take.

    I have the easy option, which involves me putting the whole set of links into a MySQL database and having one dynamic page call up each category as it is required. Easy peasy and could probably be done in an hour or two.

    On the other hand, I have the raw HTML version which would look quite cool URL wise as well as being a bonus when it comes to search engines.

    I was thinking that I could have an HTML template (no access to PHP fasttemplates, I'm afraid) and once a week say, run an updater script that creates the directories and copies the template into each one before updating it with each pages links, subcategories and what have you.

    The problem I have is that when I come to put the heirarchy (eg. Top >> Baseball >> High Heat 2001 >> Official) at the top of the page, I can pull a plain text version from the DB which doesn't have links to the other categories (ie, Top, Baseball, High Heat) but I figure a linked version would be useful.

    Also, I have a few problems with the output of subcategories as in HOW the heck do I do that?

    My DB has two tables, Links and Categories. The Categories table has ParentCat, CatId, CatName and CatHeirarchy. The Links table contains Description, Name, URL, LinkID and ClickCount.

    I figure I could get the heirarchy going by using some sort of recursive scripting, but I really can't work that part out

    Any help greatly appreciated. Should I just take the soft option?

  2. #2
    Idea Developer
    Join Date
    Sep 2000
    Location
    Bethlehem, PA
    Posts
    521
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Making something which looks like pure html is very easy with php. its hard to explain, but for example for all the direcory pages all you need is difrrent files with like directory/eduaction/papers/index.php and just put in the code include '/home/directoryfull.php'; and that script will parse the filename, and use the file name like a ? directory = education/papers/ if you knwo what i mena.

  3. #3
    Feel my RewiredMind KMxRetro's Avatar
    Join Date
    Jan 2001
    Location
    Exeter, Devon, UK
    Posts
    477
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for replying!

    I read something like this but the article I looked at said that I needed access to apache.conf, which I don't.

    Is there any way around using apache.conf to do this?

    .htaccess maybe?

  4. #4
    One website at a time mmj's Avatar
    Join Date
    Feb 2001
    Location
    Melbourne Australia
    Posts
    6,282
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Have a look at my site.

    My host has set up php so that if no extension is given, it looks for a php file before it looks for a directory.

    For example,
    http://www.mostlyamphigory.com/articles/afiles.html
    works exactly the same as
    http://www.mostlyamphigory.com/articles.php/afiles.html
    and
    http://www.mostlyamphigory.com/articles.php?name=afiles

    All the above urls go to articles.php, even when the ".php" is not given, and there are "/" afterwards.
    [mmj] My magic jigsaw
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    The Bit Depth Blog Twitter Contact me
    Neon Javascript Framework Jokes Android stuff

  5. #5
    Feel my RewiredMind KMxRetro's Avatar
    Join Date
    Jan 2001
    Location
    Exeter, Devon, UK
    Posts
    477
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Got it!

    Thanks for your advice guys, but I think I'm gonna go with the flat html to be honest. I just worked out the recursive code to put the heirarchy in.

    Here it is in case you were wondering :-
    Code:
    <?
    
    $site = "localhost";
    $username = "";
    $password = "";
    $dbName = sportsgamer;
    mysql_connect($site, $username, $password); 
    
    $result = mysql($dbName, "SELECT * from categories WHERE CatID = '$work'");
    $num = mysql_numrows($result);
    $parentcat = mysql_result($result,0,"parentcat");
    $heirarchy = mysql_result($result,0,"heirarchy");
    $catid = mysql_result($result,0,"catid");
    $name = mysql_result($result,0,"name");
    $ender = " >> " . $name;
    $holder = $parentcat;
    
    $babandinga = "<a href=http://localhost/sportsgamer/index.php><b>SportsGamer</b></a> >> <a href=http://localhost/sportsgamer/netguide/index.php>NetGuide</a>";
    
    while ($holder !== "999"):
    $result = mysql($dbName, "SELECT * from categories WHERE CatID = '$holder'");
    
    $parentcat = mysql_result($result,0,"parentcat");
    $heirarchy = mysql_result($result,0,"heirarchy");
    $catid = mysql_result($result,0,"catid");
    $name = mysql_result($result,0,"name");
    
    $heirarchy = eregi_replace("SportsGamer >> NetGuide >> ","",$heirarchy);
    $heirarchy = eregi_replace(" >> ","",$heirarchy);
    $heirarchy = eregi_replace(" ","_",$heirarchy);
    
    $babandinga .= " >> <a href=http://localhost/sportsgamer/netguide/" . $heirarchy . "/index.php>" . $name . "</a>";
    $holder = $parentcat;
    endwhile;
    
    print $babandinga . $ender;
    
    ?>
    A bit of modification and it'll be cool to write to a html file rather than just print to screen.

    I know it has a TON of MySQL queries but to be honest, it'll be used to update about once every fortnight, if that. I have a directory builder/remover in place also so that's taken care of.

    Thanks again folks,


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •