Jump to content

ssnet12

New Members
  • Posts

    4
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

ssnet12's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi again this is the only way i can figure out how to do it. but the code is long and there must be a better way. if anyone can show me a better way. that would be greatly appreciated thanks steve ps code below ------------------------------------------------------------------------------------- $querynew = "SELECT COUNT(id) AS numrows FROM table where category = 'antiques-for-sale' "; $resultnew = mysql_query($querynew) or die('Error, query failed'); $row = mysql_fetch_array($resultnew, MYSQL_ASSOC); $catid1 = $row['numrows']; $querynew = "SELECT COUNT(id) AS numrows FROM table where category = 'baby-items-for-sale' "; $resultnew = mysql_query($querynew) or die('Error, query failed'); $row = mysql_fetch_array($resultnew, MYSQL_ASSOC); $catid2 = $row['numrows']; $querynew = "SELECT COUNT(id) AS numrows FROM table where category = 'bikes-for-sale' "; $resultnew = mysql_query($querynew) or die('Error, query failed'); $row = mysql_fetch_array($resultnew, MYSQL_ASSOC); $catid3 = $row['numrows']; $querynew = "SELECT COUNT(id) AS numrows FROM table where category = 'boats-for-sale' "; $resultnew = mysql_query($querynew) or die('Error, query failed'); $row = mysql_fetch_array($resultnew, MYSQL_ASSOC); $catid4 = $row['numrows']; etc etc etc this code would have to go on for 200 categorys.
  2. hi i have just tried looking at the link you gave me, thanks but i still cant figure this out. when i use the echo in the code below it returns the amount of rows in the category 'antiques-for-sale' i need the code below to echo the amount of rows in each category. The code below only works for 1 category, how can i change this code to show amount of rows for multiple categorys. many thanks steve $querynew = "SELECT COUNT(id) AS numrows FROM table where category = 'antiques-for-sale' "; $resultnew = mysql_query($querynew) or die('Error, query failed'); $row = mysql_fetch_array($resultnew, MYSQL_ASSOC); $catid1 = $row['numrows']; echo $catid1;
  3. hi thanks for your help but i couldnt get that code to work. does anyone else no how i do this? thanks steve
  4. hi i am a new member here. i have joined looking for some help. i am trying to select the numrows from my database table where category = somevalue. below my code shows that i am querying where category = 'antiques-for-sale' this code works fine for 1 category but i need to query all categorys example i want to produce the numrows of each category, results should show how many rows where category = antiques-for-sale, how many rows where category = bikes-for-sale, how many rows where category = boats-for-sale, etc my code below only returns results for 1 category,(antiques-for-sale) is there a way of doing this without writing multiple sql query statements, basically i would like a sql query to bring back all results, but i cannot figure out how to do it. any help will be greatly appreciated. thanks steve ------------------------------------------------------------------------- $querynew = "SELECT COUNT(id) AS numrows FROM table WHERE category = 'antiques-for-sale'"; $resultnew = mysql_query($querynew) or die('Error, query failed'); $row = mysql_fetch_array($resultnew, MYSQL_ASSOC); $catid1 = $row['numrows'];
×
×
  • 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.