SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Member
    Join Date
    May 2001
    Location
    Vulcan
    Posts
    18
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just another one
    When i type Reviews.php i want it to display a list of all reviews and when i type reviews.php?ID=1 i want it to display review ID 1, any ideas how to do this?

  2. #2
    Database Jedi MattR's Avatar
    Join Date
    Jan 2001
    Location
    buried in the database shell (Washington, DC)
    Posts
    1,107
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:

    if( empty( $ID ) ) {
      
    // show all reviews
    } else {
      
    // show review # $ID
    // end if 

  3. #3
    SitePoint Member
    Join Date
    May 2001
    Location
    Vulcan
    Posts
    18
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi

    Thanks for the reply, what i ment was i want to have a list of the reviews on the dbase such as :

    vid card review
    Mobo Review

    and so on, i dont mind adding the links manualy untill i learn a better way, any ideas how i can do this?
    Ryan Munro
    Jsi Hardware
    Http://www.jsihardware.com
    "To Not Overclock Is Illogical"

  4. #4
    SitePoint Addict
    Join Date
    Feb 2001
    Location
    Shanghai, China
    Posts
    214
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If I don't misunderstand you, this here migth help:
    PHP Code:
    if (isset($ID)) {    // means: if the var. $ID exists
    $query mysql_query(SELECT FROM boardname WHERE boardid=$ID);
    } else {
    $query =mysql_query(SELECT FROM boardname);

    Last edited by smorb; May 16, 2001 at 00:17.

  5. #5
    SitePoint Addict
    Join Date
    Feb 2001
    Location
    Shanghai, China
    Posts
    214
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey, using Netscape 3.0 you can not read what there is inside the PHP-tags in this forum. So MattR's reply seemed to be blank in Netscape.
    Actually what I posted is nearly the same what he postet, sorry.

  6. #6
    SitePoint Member
    Join Date
    May 2001
    Location
    Vulcan
    Posts
    18
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hmm not realy sure i understand that code, where would i type in the review list?
    Ryan Munro
    Jsi Hardware
    Http://www.jsihardware.com
    "To Not Overclock Is Illogical"

  7. #7
    SitePoint Member
    Join Date
    May 2001
    Location
    Vulcan
    Posts
    18
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by MattR
    PHP Code:

    if( empty( $ID ) ) {
      
    // show all reviews
    } else {
      
    // show review # $ID
    // end if 
    i see how that would work, where in here would it go though?

    <?php

    // Get the review text from the database
    $result = mysql_query("SELECT ... FROM ... ".
    "WHERE ID=$ID");
    $result = mysql_fetch_array($result);
    $resulttext = $result["..."];

    // If no page specified, default to the
    // first page ($page = 0)
    if (!isset($page)) $page = 0;

    // Split the text into an array of pages
    $textarray=split("\[PAGEBREAK]",$resulttext);

    // Select the page we want
    $resulttext=$textarray[$page];

    // Hyperlinks
    $joketext = ereg_replace(
    "\[L]([-_./a-zA-Z0-9!&%#?,'=:~]+)\[EL]",
    "<A HREF=\"\\1\">\\1</A>", $resulttext);
    $joketext = ereg_replace(
    "\[L=([-_./a-zA-Z0-9!&%#?,'=:~]+)]".
    "([-_./a-zA-Z0-9 !&%#?,'=:~]+)\[EL]",
    "<A HREF=\"\\1\">\\2</A>", $resulttext);
    if ($page != 0) {
    $prevpage = $page - 1;
    echo("<P><A HREF=\"$PHP_SELF?ID=$ID&page=$prevpage\">".
    "Previous Page</A></P>");
    }
    echo( "<P>$resulttext" );
    if ($page < count($textarray) - 1) {
    $nextpage = $page + 1;
    echo("<P><A HREF=\"$PHP_SELF?ID=$ID&page=$nextpage\">".
    "Next Page</A></P>");
    }
    ?>
    Ryan Munro
    Jsi Hardware
    Http://www.jsihardware.com
    "To Not Overclock Is Illogical"

  8. #8
    SitePoint Member
    Join Date
    May 2001
    Location
    Vulcan
    Posts
    18
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    bump
    Ryan Munro
    Jsi Hardware
    Http://www.jsihardware.com
    "To Not Overclock Is Illogical"

  9. #9
    SitePoint Author Kevin Yank's Avatar
    Join Date
    Apr 2000
    Location
    Melbourne, Australia
    Posts
    2,571
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    The code you wrote fetches and formats the article specified by $ID, so:

    PHP Code:
    if( empty( $ID ) ) {
      
    // show all reviews
    } else {
      
    // YOUR CODE GOES HERE
    // end if 
    You still need to write the code to fetch and display the list of all articles which goes where it says "// show all reviews".
    Kevin Yank
    CTO, sitepoint.com
    I wrote: Simply JavaScript | BYO PHP/MySQL | Tech Times | Editize
    Baby’s got back—a hard back, that is: The Ultimate CSS Reference

  10. #10
    SitePoint Member
    Join Date
    May 2001
    Location
    Vulcan
    Posts
    18
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Youve lost me now
    Ryan Munro
    Jsi Hardware
    Http://www.jsihardware.com
    "To Not Overclock Is Illogical"


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
  •