Let's say that my password, username, database and everything is test. Is the code right if it is like this? And also the connections are right.
<?php
$link = mysql_connect("localhost",$test_test,$test);
mysql_select_db("test_test");
$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";
?>
<?php require('_drawrating.php'); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script type="text/javascript" language="javascript" src="js/behavior.js"></script>
<script type="text/javascript" language="javascript" src="js/rating.js"></script>
<link rel="stylesheet" type="text/css" href="css/rating.css" />
</head>
<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>Sorth by: <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></td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="14%"><p>funny picture </p>
<p>CONTENT</p></td>
<td width="86%">Rating: <?php echo rating_bar('8xxa','5'); ?>
<p> </p></td>
</tr>
<tr>
<td><p>cool picture </p>
<p>CONTENT</p></td>
<td>Rating: <?php echo rating_bar('8x41','5'); ?></td>
</tr>
<tr>
<td><p>test picture</p>
<p>CONTENT</p></td>
<td>Rating: <?php echo rating_bar('84854','5'); ?></td>
</tr>
<tr>
<td><p>test 1 picture</p>
<p>CONTENT</p></td>
<td>Rating: <?php echo rating_bar('8454','5'); ?></td>
</tr>
<tr>
<td><p>5 cool picture</p>
<p>CONTENT</p></td>
<td>Rating: <?php echo rating_bar('8454654a','5'); ?></td>
</tr>
<tr>
<td><p>number test</p>
<p>CONTENT</p></td>
<td>Rating: <?php echo rating_bar('154545','5'); ?></td>
</tr>
<tr>
<td># character testCONTENT</td>
<td>Rating: <?php echo rating_bar('8xxa','5'); ?></td>
</tr>
<tr>
<td><p>hello test </p>
<p>CONTENT</p></td>
<td>Rating: <?php echo rating_bar('815454','5'); ?></td>
</tr>
<tr>
<td><p>1 test</p>
<p> CONTENT</p></td>
<td>Rating: <?php echo rating_bar('822a','5'); ?></td>
</tr>
<tr>
<td><p>z test</p>
<p> CONTENT</p></td>
<td>Rating: <?php echo rating_bar('454xa','5'); ?></td>
</tr>
</table>
</body>
</html>


Reply With Quote




Bookmarks