Jump to content

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]
Link to comment
https://forums.phpfreaks.com/topic/10794-database-sorting-by-series/
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]
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.