Jump to content

Archived

This topic is now archived and is closed to further replies.

Coronet

Database -- sorting by series

Recommended Posts

This has probably been asked a number of times, but I am attempting to create a database with PHP to organize my layouts (I run a free template site) and I'm rather new to PHP.

I have already created the tables in PHPmyadmin and named my table "layouts".

[code]
<?PHP

//My connection stuff here.

$query = "SELECT DISTINCT series FROM layouts order by series asc ";
$result= mysql_query($query, $connection) or die
("Could not execute query : $q." . mysql_error());

while ($row=mysql_fetch_array($result)) {
$series=$row["series"];

$q = mysql_query("select * from `layouts` where `series`='$series'");
$numrows = mysql_num_rows($q);

echo " <a href='series.php?series=$series'>$series</a> [<b>$numrows</b>] <br>

";

}

?>
[/code]

I get an error that it DOES list the series, but when I click on a link, it doesn't show the layouts in that category. It just sits on the page and doesn't process anything. >_<; I'm sure this is something stupid I'm doing, but any help for my nubness would be much appreciated.

Here's a link to the page that I have for testing purposes.

[a href=\"http://second-eden.net/testing/final/series.php\" target=\"_blank\"]http://second-eden.net/testing/final/series.php[/a]

Share this post


Link to post
Share on other sites
that page does exactly what you programmed it to... nowhere in your programming is a call to check inside the given 'series'.

You should put code for checking the series hits inside an if...

[code]
if ($_GET[series]!=""){ /* Note you should actually test what is given against actual values to verify that a user didn't make up a series to gain access to your query.... */
  $sql= select .....  from layouts where series='$_GET[series]'";
...etc
}
else{}

[/code]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.