Something unrelated to the sorting and reordering. Would you know why everytime I add the rater, there is a horizontal line under it?
Something unrelated to the sorting and reordering. Would you know why everytime I add the rater, there is a horizontal line under it?
inthe rating.css the first part is this:
the border-bottom line is the culprit.Code:.ratingblock { display:block; border-bottom:1px solid #999; padding-bottom:8px; margin-bottom:8px; }
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;
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.
The new links would bePHP 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";
?>
Code:<a href="sortexample.php?sorttype=1&sortname=Name">Z to A</a> <a href="sortexample.php?sorttype=0&sortname=Name">A to Z</a> <a href="sortexample.php?sorttype=1&sortname=Rating">Top rated to Least</a> <a href="sortexample.php?sorttype=0&sortname=Rating">Least rated to Top</a>
So I need to set up a database? And do I put that php code anywhere in that page? Thanks Leafy.
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;
<?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?
One of 2 ways...
Either define $user and $pass and $database with the terms:
Or, just like you have it above just remove the $'s for those 3 spots.PHP Code:$user = "username"
etc..
{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;
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
"
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