Page 2 of 4 FirstFirst 1234 LastLast
Results 11 to 20 of 38

Thread: reordering content

  1. #11
    Join Date
    Nov 2007
    Posts
    346
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Something unrelated to the sorting and reordering. Would you know why everytime I add the rater, there is a horizontal line under it?

  2. #12
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    inthe rating.css the first part is this:

    Code:
    .ratingblock {
    	display:block;
    	border-bottom:1px solid #999;
    	padding-bottom:8px;
    	margin-bottom:8px;
    	}
    the border-bottom line is the culprit.

    If you don't want it remove that whole line.
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  3. #13
    Join Date
    Nov 2007
    Posts
    346
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks! Wow, you truly are incredible! Now back to the reordering/sorting.

  4. #14
    Join Date
    Jan 2008
    Posts
    32
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Default

    Quote Originally Posted by afe View Post
    Thanks! Wow, you truly are incredible! Now back to the reordering/sorting.
    Assuming you have fetched all of the required data, it looks like this, assuming "Title" is the name of the column you store the name of the photo.
    PHP Code:
    <?php
        $link 
    mysql_connect("localhost",$user,$pass);
        
    mysql_select_db("pictures");
        
    $type = ((isset($_GET["sorttype"])?$_GET["sorttype"]:"1") == "1")?"DESC":"ASC";
        
    /*
            this is really the equivelant of
            $type = "";
            if(isset($_GET["sorttype"]))
                $type = $_GET["sorttype"];
            else
                $type = "1";
            $type_cmp = $type;

            if($type_cmp == "1")
                $type = "DESC";
            else 
                $type = "ASC";
            unset($type_cmp);
            
        */
        
    $col = ($_GET["sortname"]);
        
    $q "SELECT * FROM records ORDER BY `$col$type";
    ?>
    The new links would be
    Code:
    <a href="sortexample.php?sorttype=1&amp;sortname=Name">Z to A</a>
    <a href="sortexample.php?sorttype=0&amp;sortname=Name">A to Z</a>
    <a href="sortexample.php?sorttype=1&amp;sortname=Rating">Top rated to Least</a>
    <a href="sortexample.php?sorttype=0&amp;sortname=Rating">Least rated to Top</a>

  5. #15
    Join Date
    Nov 2007
    Posts
    346
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    So I need to set up a database? And do I put that php code anywhere in that page? Thanks Leafy.

  6. #16
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    Yup, set up a DB. (Or amend the one you already have for the star rater )Change the things in the script to match (username, password, etc.)

    You should place the code ABOVE the <html>

    so it would look something like:

    PHP Code:
    <?php
        $link 
    mysql_connect("localhost",$user,$pass);
        
    mysql_select_db("pictures");
        
    $type = ((isset($_GET["sorttype"])?$_GET["sorttype"]:"1") == "1")?"DESC":"ASC";
        
    /*
            this is really the equivelant of
            $type = "";
            if(isset($_GET["sorttype"]))
                $type = $_GET["sorttype"];
            else
                $type = "1";
            $type_cmp = $type;

            if($type_cmp == "1")
                $type = "DESC";
            else 
                $type = "ASC";
            unset($type_cmp);
            
        */
        
    $col = ($_GET["sortname"]);
        
    $q "SELECT * FROM records ORDER BY `$col$type";
    ?> 
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  7. #17
    Join Date
    Nov 2007
    Posts
    346
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    <?php
    $link = mysql_connect("localhost",$DATABASE USER,$DATABASE PASSWORD);
    mysql_select_db("DATABASE");
    $type = ((isset($_GET["sorttype"])?$_GET["sorttype"]:"1") == "1")?"DESC":"ASC";
    /*
    this is really the equivelant of
    $type = "";
    if(isset($_GET["sorttype"]))
    $type = $_GET["sorttype"];
    else
    $type = "1";
    $type_cmp = $type;

    if($type_cmp == "1")
    $type = "DESC";
    else
    $type = "ASC";
    unset($type_cmp);

    */
    $col = ($_GET["sortname"]);
    $q = "SELECT * FROM records ORDER BY `$col` $type";
    ?>

    this is what I changed is this right?

  8. #18
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    One of 2 ways...

    Either define $user and $pass and $database with the terms:

    PHP Code:
    $user "username"
    etc.. 
    Or, just like you have it above just remove the $'s for those 3 spots.
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  9. #19
    Join Date
    Nov 2007
    Posts
    346
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    These are the errors that I am getting
    "
    Warning: mysql_connect() [function.mysql-connect]: Access denied for user: 'nobody@localhost' (Using password: NO) in /home/athletes/public_html/sortexample.php on line 2

    Warning: mysql_select_db() [function.mysql-select-db]: Access denied for user: 'nobody@localhost' (Using password: NO) in /home/athletes/public_html/sortexample.php on line 3

    Warning: mysql_select_db() [function.mysql-select-db]: A link to the server could not be established in /home/athletes/public_html/sortexample.php on line 3
    "

  10. #20
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    Okay, well first.. check your connections.

    Is your SQL server set up to be accessed as "localhost"? Some are, a lot aren't.

    Next, check your username and password are exactly correct.

    Lastly, check that the user has access to do the required functions for that DB.
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

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
  •