Board index   FAQ   Search  
Register  Login
Board index php forum :: Database mySQL & php coding

sort a table

Codes here !

Moderators: macek, egami, gesf

sort a table

Postby ManpowerIan » Sun Feb 02, 2014 1:09 pm

so, whats wrong with this script ? I can not see whats wrong, I get IIS error
<?php
$con=mysql_connect ("localhost", "root", "")
or die ('Error: ' . mysql_error());
mysql_select_db ("aDatabase");

if(isset($_GET['orderby'])){
$order = $_GET['orderby'];
$sql = "SELECT * FROM aTable ORDER BY ".$order" DESC";
}
else{
$sql = "select * from aTable";
}
$result = mysql_query($sql);


echo "<table border='1'>
<tr>
<th><A HREF='asite.php?orderby=title'>title</a></th>
<th>Image</th>
<th><A HREF='asite.php?orderBy=score'>score</A></th>
<th>Link</th>
</tr>";

while($row = mysql_fetch_array($result))

echo "<tr>";
echo "<td>" . $row['Title'] . "</td>";
echo "<td><IMG SRC='". $row['Image'].".jpg'></td>";
echo "<td>" . $row['Score'] . "</td>";
echo "<td><A HREF='http://" . $row['Link'] . "'>aLink</A> </td>";
echo "</tr><br>";
echo "</table>";
}
mysqli_close($con);
?>
ManpowerIan
New php-forum User
New php-forum User
 
Posts: 2
Joined: Thu Jan 30, 2014 10:02 am

Re: sort a table

Postby pietercdevries » Tue Feb 18, 2014 3:00 pm

So whats the error say?

echo "<table border='1'>
<tr>
<th><A HREF='asite.php?orderby=title'>title</a></th>
<th>Image</th>
<th><A HREF='asite.php?orderBy=score'>score</A></th>
<th>Link</th>
</tr>";

or

echo "<table border='1'>";
echo "<tr>";
echo "<th><A HREF='asite.php?orderby=title'>title</a></th>";
echo "<th>Image</th>";
echo "<th><A HREF='asite.php?orderBy=score'>score</A></th>";
echo "<th>Link</th>";
echo "</tr>";
pietercdevries
New php-forum User
New php-forum User
 
Posts: 5
Joined: Tue Feb 18, 2014 2:38 pm


Return to mySQL & php coding

Who is online

Users browsing this forum: Google [Bot] and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron