SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Evangelist
    Join Date
    Dec 2000
    Posts
    528
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello everybody~
    I'm writing a PHP script for a friend that retrieves jokes from a database. I have two separate scripts, subcats.php3 and showjoke.php3. I got the showjoke.php3 working, it's the subcats.php3 script that I'm having trouble with.

    It is supposed to grab only the title and ID # and do that for however many jokes' records are in the database.

    The script looks like this:
    PHP Code:
    $sql "SELECT id, title, content, categoryid, categorytitle FROM $table_name";

    $result mysql_query($sql$connection) or die("Couldn't understand $sql and(or) couldn't connect.");

    while (
    $row = @mysql_fetch_array($result))
    {
    $id $row["id"];
    $title $row["title"];
    $content $row["content"];
    $categoryid $row["categoryid"];
    $categorytitle $row["categorytitle"];
    }

    print 
    "<html>\n";
    print 
    "<HTML>\n\n";
    print 
    "<HEAD>\n";
    print 
    "<TITLE>2 Crazy Guys.net: Archive: Clean: ".$categorytitle."</TITLE>\n";
    print 
    "<META name=\"keywords\" content=\"\">\n";
    print 
    "<META name=\"description\" content=\"\">\n";
    print 
    "\n";
    include(
    "http://www.2crazyguys.net/header2.txt");
    print 
    "\n\n";
    print 
    "<a href=\"http://www.2crazyguys.net/archive/\"><b>Archive:</b></a> <a href=\"http://www.2crazyguys.net/archive/clean/\"><b>Clean:</b></a> <b>".$categorytitle.":</b><br><br>\n\n";
    print 
    "<a href=\"http://www.2crazyguys.net/archive/clean/showjoke.php3?id=".$id."\"><b>".$title."</b></a><br>\n\n";
    include(
    "http://www.2crazyguys.net/footer2.txt");
    print 
    "\n\n\n\n";
    print 
    "</BODY>\n";
    ?> 
    As you can see, I have two files that have the navigation. How can I make the jokes part repeat, but not the head, body, and navigation pages? If somebody could please provide the code for me, that would be great. Thanks!
    Corbb O'Connor
    Looking for quality website design or database programming?
    Contact me for more information and a FREE quote!

  2. #2
    Not Bad, eh? Justin Sampson's Avatar
    Join Date
    Aug 2000
    Location
    N.S., Canada
    Posts
    487
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try this:
    PHP Code:
    <?
    $sql 
    "SELECT id, title, content, categoryid, categorytitle FROM $table_name";
    $result mysql_query($sql$connection) or die("Couldn't understand $sql and(or) couldn't connect.");
    print 
    "<html>\n";
    print 
    "<HTML>\n\n";
    print 
    "<HEAD>\n";
    print 
    "<TITLE>2 Crazy Guys.net: Archive: Clean: ".$categorytitle."</TITLE>\n";
    print 
    "<META name=\"keywords\" content=\"\">\n";
    print 
    "<META name=\"description\" content=\"\">\n";
    print 
    "\n";

    include(
    "http://www.2crazyguys.net/header2.txt");
    print 
    "\n\n";
    print 
    "<a href=\"http://www.2crazyguys.net/archive/\"><b>Archive:</b></a> <a href=\"http://www.2crazyguys.net/archive/clean/\"><b>Clean:</b></a> <b>".$categorytitle.":</b><br><br>\n\n";


    while (
    $row = @mysql_fetch_array($result))
    {
    $id $row["id"];
    $title $row["title"];
    $content $row["content"];
    $categoryid $row["categoryid"];
    $categorytitle $row["categorytitle"];

    print 
    "<a href=\"http://www.2crazyguys.net/archive/clean/showjoke.php3?id=".$id."\"><b>".$title."</b></a><br>\n\n";
    }


    include(
    "http://www.2crazyguys.net/footer2.txt");
    print 
    "\n\n\n\n";
    print 
    "</BODY>\n";

    ?>
    Last edited by Justin Sampson; Apr 10, 2001 at 16:31.


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
  •