not sure where to start

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Hawk

    not sure where to start

    I hope I can explain this right :) I'm new to php but am getting there
    slowly.

    I have a page with the letters ABCDE...etc
    I want to be able to click on a letter and it will bring up a list of
    title's to click on, so how do I get it to load a page if say A was
    index.php?revie ws=a

    I've already got the page with the links in and that then loads the reviews
    up if you click on the link, but I've made 26 pages areview, breview,
    creview etc. I would just rather have a common page that would choose the
    right one.

    Is this a simple answer or is it going to be complex?

    Thanks for any help :)


  • Janwillem Borleffs

    #2
    Re: not sure where to start


    "Hawk" <info@hawk-web.co.uk> schreef in bericht
    news:aZiAb.5880 $36.392@news-binary.blueyond er.co.uk...[color=blue]
    >
    > I've already got the page with the links in and that then loads the[/color]
    reviews[color=blue]
    > up if you click on the link, but I've made 26 pages areview, breview,
    > creview etc. I would just rather have a common page that would choose the
    > right one.
    >
    > Is this a simple answer or is it going to be complex?
    >[/color]

    Perhaps this is helpful:

    <?

    // Get the file name
    $file = strtoupper(base name(__FILE__)) ;

    // Generate the index
    for ($i = 65; $i < 91; $i++) {
    $c = chr($i);
    if ($c == $file{0}) {
    echo "$c\n";
    } else {
    echo "<a href=\"temp.php ?reviews=$c\">$ c</a>\n";
    }
    }

    // Include the appropriate page
    if (!isset($_GET['reviews'])) {
    echo "including areview.php";
    } else {
    $rev = strtolower($_GE T['reviews']);
    // See if $rev is valid
    if (ereg("^[a-z]$", $rev)) {
    echo "including {$rev}review.ph p";
    } else {
    echo "Invalid value for \$review";
    }
    }

    ?>

    HTH,
    JW



    Comment

    • Chung Leong

      #3
      Re: not sure where to start

      Well, it depends on how you're storing the reviews. If they're just sitting
      in a page, then I would just put some <div> tags around each section and
      just flip them on and off using Javascript. There's no much point in using
      PHP unless you have a more sophisticated backend.

      Uzytkownik "Hawk" <info@hawk-web.co.uk> napisal w wiadomosci
      news:aZiAb.5880 $36.392@news-binary.blueyond er.co.uk...[color=blue]
      > I hope I can explain this right :) I'm new to php but am getting there
      > slowly.
      >
      > I have a page with the letters ABCDE...etc
      > I want to be able to click on a letter and it will bring up a list of
      > title's to click on, so how do I get it to load a page if say A was
      > index.php?revie ws=a
      >
      > I've already got the page with the links in and that then loads the[/color]
      reviews[color=blue]
      > up if you click on the link, but I've made 26 pages areview, breview,
      > creview etc. I would just rather have a common page that would choose the
      > right one.
      >
      > Is this a simple answer or is it going to be complex?
      >
      > Thanks for any help :)
      >
      >[/color]


      Comment

      • Szar

        #4
        Re: not sure where to start


        "Hawk" <info@hawk-web.co.uk> wrote in message
        news:aZiAb.5880 $36.392@news-binary.blueyond er.co.uk...[color=blue]
        > I hope I can explain this right :) I'm new to php but am getting there
        > slowly.
        >
        > I have a page with the letters ABCDE...etc
        > I want to be able to click on a letter and it will bring up a list of
        > title's to click on, so how do I get it to load a page if say A was
        > index.php?revie ws=a
        >
        > I've already got the page with the links in and that then loads the[/color]
        reviews[color=blue]
        > up if you click on the link, but I've made 26 pages areview, breview,
        > creview etc. I would just rather have a common page that would choose the
        > right one.
        >
        > Is this a simple answer or is it going to be complex?
        >
        > Thanks for any help :)
        >
        >[/color]

        On review.php I would just do something like this:
        switch($_REQUES T["reviews"]) { //with the value you're passing
        case "a":
        include "a.php";
        break;
        case "b":
        include "b.php";
        break;
        ...and so on
        }

        This way a seperate file containing just the unique content for a, b, c,
        etc. is pulled into the body of your page. If you want to do this all on one
        big bad page you could use functions to call them like so

        case "a":
        acontent();
        break;
        etc.

        //and elsewhere in the doc
        function acontent() {
        ?>
        //here's all my a stuff
        <?
        }

        Hope that's what you were asking for.
        Steve.


        Comment

        • Hawk

          #5
          Re: not sure where to start

          Thanks for your reply's guy I will give them a try, William asked me to post
          me script, hope this helps?

          <?
          $category = "areview";


          # setup SQL statement
          $sql = " SELECT * FROM reviews ";
          $sql .= " WHERE category = '$category' ";


          # execute SQL statement
          $rs = mysql_query($sq l, $cid);
          if (mysql_error()) { print "Database Error: $sql " . mysql_error(); }

          # display results


          while ($row = mysql_fetch_arr ay($rs))
          {
          $siteurl = $row["siteurl"];
          $sitename = $row["sitename"];
          ?><a onMouseover="re turn hidestatus()" href='<?php echo $siteurl; ?>'><?php
          echo $sitename; ?></a><br/><?


          }
          ?>


          Comment

          • Guest's Avatar

            #6
            Re: not sure where to start


            "Hawk" <info@hawk-web.co.uk> wrote in message
            news:4SrAb.2049 $SV1.1027@news-binary.blueyond er.co.uk...[color=blue]
            > Thanks for your reply's guy I will give them a try, William asked me to[/color]
            post[color=blue]
            > me script, hope this helps?
            >
            > <?
            > $category = "areview";
            >
            >
            > # setup SQL statement
            > $sql = " SELECT * FROM reviews ";
            > $sql .= " WHERE category = '$category' ";
            >
            >
            > # execute SQL statement
            > $rs = mysql_query($sq l, $cid);
            > if (mysql_error()) { print "Database Error: $sql " . mysql_error(); }
            >
            > # display results
            >
            >
            > while ($row = mysql_fetch_arr ay($rs))
            > {
            > $siteurl = $row["siteurl"];
            > $sitename = $row["sitename"];
            > ?><a onMouseover="re turn hidestatus()" href='<?php echo $siteurl;[/color]
            ?>'><?php[color=blue]
            > echo $sitename; ?></a><br/><?
            >
            >
            > }
            > ?>
            >
            >[/color]

            Since you are storing this information in a database, and I am assuming that
            you have a field called title....
            Why don't you just select a review (or a title) based on the starting
            character ? One page would do it.

            Just record that first letter being passed to your page and use it in a
            query.
            For a title starting with G :

            $query = "select * from reviews where title like "G%";

            Since both of these fields - category and title - are varchar, there
            shouldn't be much of a difference in peformance.





            Comment

            Working...