Jump to content

catlover

New Members
  • Posts

    7
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

catlover's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thanks toplay and kenrbnsn A combination of both of your suggestions and a little extra elbow-grease accomplished the job!
  2. In a previous post LordStanley (Thanks LordStanley!) was able to help me with this code: [code]<table class="text1" width="100%" border="0" cellpadding="2" cellspacing="0"> <? $result=mysql_query("SELECT breed, count(breed) as num FROM animals GROUP BY breed")or die( "Error! Could not select the database: " . mysql_error() ); while ($category = mysql_fetch_array($result))  { echo '<tr> <td width="11"><img src="images/down_arrow.jpg" width="10" height="10"></td> <td width="100%"><a href="'.$path.$category['breed'].'.php">'.$category['breed'].'</a> <a href="'.$path.$category['breed'].'.php"> ( '.$category['num'].')'; }[/code] The value of "$path.$category['breed']" returns lowercase value with "_" between values containing more than one word.... ie. "american_bobtail". It is returned this way because the pages the link will point to are named lowercase, and using underscore between words for browser url reasons. But, I need the "menu" this script is building to show Uppercase values. Like (sorry, not actual code): [code] if $category['breed'] = 'american_bobtail' { $category = 'American Bobtail' }[/code] How can I make this work? Thanks for any help that can be provided!
  3. LordStanley, Thanks for your help! I had to change ORDER BY to GROUP BY, but it now works! Thank you! [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Error! Could not select the database: Mixing of GROUP columns (MIN(),MAX(),COUNT()...) with no GROUP columns is illegal if there is no GROUP BY clause[/quote]
  4. Thanks every one for the help! I've added a second query using COUNT. I used "mysql_fetch_array" again. COUNT seems to work, but it's only showing the count for the last "breed". [b]Bengal Burmese Persian Siamese (2)[/b] Any idea on how to make it return the COUNT for all "breeds"?
  5. I'm not familiar with how Invision boards work, so I didn't know the reply was "meshing" with the last reply. Does anyone know how to sort how many "articles" are in a particular "breed" based on the previous code change (thanks to Firedrop for the first problem!)? All the script needs now is the sorting of "articles" pertaining to the particular "breed". I've fooled with quite a few queries, arrays, etc, but I don't "get it".
  6. GROUP BY returns: [b]Bengal (4) Burmese (4) Persian (4) Siamese (4)[/b] That fixed the duplicate breed names. Thank you. Any idea about how to sort the results of the articles instead of it counting the breeds?
  7. Hello, I'm new to PHP and have a little problem with a script. I hope someone will be kind enough to point me in the right direction to fix what I've scripted. If so, thank you. I need the script to display breeds of cats and how many articles (or links to articles) have been submitted about that breed into my database. For example: [b]Bengal (1) Burmese (3) Persian (2) Siamese (2)[/b] What the script is currently returning is : [b]Bengal (8) Burmese (8) Burmese (8) Burmese (8) Persian (8) Persian (8) Siamese (8) Siamese (8)[/b] I need the script to return only one instance of each breed and only the number of articles for that breed. Here is the script: [code]<table class="text1" width="100%" border="0" cellpadding="2" cellspacing="0"> <? $result=mysql_query("SELECT breed FROM animals WHERE animals.breed = animals.breed ORDER BY breed")or die( "Error! Could not select the database: " . mysql_error() ); $num_rows = mysql_num_rows($result); while ($category = mysql_fetch_array($result))  { ?> <tr> <td width="11"><img src="images/down_arrow.jpg" width="10" height="10"></td> <td width="100%"><a href="<?=$path;?><?=$category['breed'];?>.php"> <? echo ($category['breed']);?></a> <a href="<?=$path;?><?=$category['breed'];?>.php"> (<? echo "$num_rows";?>) <?}?>[/code] Thank you for your time!
×
×
  • 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.