Jump to content


Photo

Organisation Help


  • Please log in to reply
3 replies to this topic

#1 RJT

RJT
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 23 April 2006 - 07:33 PM

In my add data form, there is a category option. Im trying to make a series of pages that will list the appropriate data for each category ($category). For Example if the category was "TNA" then it would only list the data that was given that category in the add data form. For some reason i get an error message when i use this code. Could anyone point out where the problem is?

<?php include('http://www.reef-break.com/cawcenter/header.php') ?>

<?
include("dbinfo.inc.php");
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM caws ORDER BY name WHERE category='TNA'";
$result=mysql_query($query);

$num=mysql_fetch_array( $result ); 

mysql_close();

echo "<b><center>Viewing All CAWs ($num)</center></b><br>";

?>

<?
$i=0;
$first_letter_old="";
while ($i < $num) {
    $name=mysql_result($result,$i,"name");
    $category=mysql_result($result,$i,"category");
    $first_letter=substr($name,0,1);
    if (($first_letter!=$first_letter_old)&&($first_letter_old!="")){
        echo "<br />";
    }
    $first_letter_old=$first_letter;
    ++$i;
    echo "<a href='http://www.reef-break.com/cawcenter/svr2006/caw.php?name=$name'>$name</a><br>";
} 

?>

<?php include('http://www.reef-break.com/cawcenter/footer.php') ?>

Thanks.

#2 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 24 April 2006 - 07:12 AM

And why can't you simply add a WHERE clause? Or did I miss something?
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#3 RJT

RJT
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 24 April 2006 - 07:49 PM

Bump for post update

#4 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 25 April 2006 - 05:38 PM

You said you got an error... what's the error? PHP, MySQL?
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users