SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: Rate this site

  1. #1
    SitePoint Evangelist
    Join Date
    Oct 2000
    Posts
    430
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    I would like to add a "rate this website" script to my site, where the "website" referres to an external site. I've seen them on a number of site, (such as the one on hotscripts.com for script rating).

    I've looked on hotscripts.com for such a script but couldn't find any on numerous searches. Has anyone any idea how these work? I'm only looking for something basic, and hopefully using flat files, as I'm just beginning MYSQL.

    cheers.

  2. #2
    imagine no limitations exbabylon's Avatar
    Join Date
    Dec 2000
    Location
    Idaho, USA
    Posts
    452
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    if your using MySQL, then add another colum to your "links" databse and try this:

    Rate page
    PHP Code:
    <?php
    // links table
    $table links;
    if(!isset(
    $new_rate)){
    $sql "SELECT * FROM $table";
    $result mysql_result($sql);
    while(
    $row mysql_fetch_array($result)){
    $id $row['ID'];
    $href $row['url'];
    $name $row['name'];
    $current_rate $row['rate'];
    ?>
    <a href="<?php echo $href?>"><?php echo $name?></a><br>Current Rate of the site is: <?php echo $current_rate?><br>Rate this site!
    <form action="<?php echo $PHP_SELF?>" method="get">
    <select name="new_rate">
    <option>0
    <option>1
    <option>2
    <option>3
    <option>4
    <option>5
    <option>6
    <option>7
    <option>8
    <option>9
    <option>10
    </select>
    <input type="submit" value="RATE!">
    <input type="hidden" value="<?php echo $id?>" name="id">
    </form>
    <?php
    }

    if(isset(
    $rate)){
    $sql "SELECT * FROM $table WHERE ID='$id'";
    $result mysql_result($sql);
    while(
    $row mysql_fetch_array($result)){
    $rate $row['rate'];
    $rate $rate $new_rate;
    $rate $rate 2;
    }

    $sql "UPDATE SET rate='$rate' WHERE ID='$id'";
    $result mysql_result($sql);
    if(!
    result){
    echo(
    "An error occured");
    { else {
    echo(
    "Thanks for voting");
    }

    }
    else {

    echo(
    "An error has occured");
    }
    Blamestorming: Sitting around in a group discussing why a deadline was missed or a project failed and who was responsible.

    Exbabylon- Professional Internet Services


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
  •