Jump to content


Photo

display group of data


  • Please log in to reply
12 replies to this topic

#1 isaac_cm

isaac_cm
  • Members
  • PipPipPip
  • Advanced Member
  • 319 posts

Posted 10 October 2006 - 04:02 PM

I have items table divided into groups and I have the sql but I do not know how to display each items group name once and not repeated for each items
for example:

Silk
  item 1
  item 2
  item 3

wool
  item 4
  item 5
  item 6

ans so on, any idea ? thanks


#2 HuggieBear

HuggieBear
  • Members
  • PipPipPip
  • Advanced Member
  • 1,899 posts
  • LocationEngland, UK

Posted 10 October 2006 - 04:08 PM

Can you provide me with your column names?

Regards
Huggie
Advice to MySQL users: Get phpMyAdmin and test your queries work there first, take half the hassle out of diagnosis, also check the reserved words list.

Links: PHP Docs :: RegEx's :: MySQL :: DevGuru :: w3schools

#3 isaac_cm

isaac_cm
  • Members
  • PipPipPip
  • Advanced Member
  • 319 posts

Posted 10 October 2006 - 04:21 PM

date, main_group, sub_group, item name, quantity, price

#4 HuggieBear

HuggieBear
  • Members
  • PipPipPip
  • Advanced Member
  • 1,899 posts
  • LocationEngland, UK

Posted 10 October 2006 - 04:23 PM

So silk and wool are sub groups or main groups?

Regards
Huggie
Advice to MySQL users: Get phpMyAdmin and test your queries work there first, take half the hassle out of diagnosis, also check the reserved words list.

Links: PHP Docs :: RegEx's :: MySQL :: DevGuru :: w3schools

#5 isaac_cm

isaac_cm
  • Members
  • PipPipPip
  • Advanced Member
  • 319 posts

Posted 10 October 2006 - 04:27 PM

yes they are main group and sub group for style only but I will figure out what to do to sub group if I know what to do to main group

#6 HuggieBear

HuggieBear
  • Members
  • PipPipPip
  • Advanced Member
  • 1,899 posts
  • LocationEngland, UK

Posted 10 October 2006 - 04:34 PM

Try this then....

<?php
$groupheader = null;
while ($row = mysql_fetch_array($result)){
   $group = $row['main_group'];
   if (is_null($groupheader) || strcmp($groupheader, $group) != 0){
      $groupheader = $row['main_group'];
      echo "<br>\n{$row['main_group']}<br>\n";
   }
   echo "{$row['item_name']}<br>\n";
}
?>

You'll possibly need to change your SQL query.

Regards
Huggie
Advice to MySQL users: Get phpMyAdmin and test your queries work there first, take half the hassle out of diagnosis, also check the reserved words list.

Links: PHP Docs :: RegEx's :: MySQL :: DevGuru :: w3schools

#7 isaac_cm

isaac_cm
  • Members
  • PipPipPip
  • Advanced Member
  • 319 posts

Posted 10 October 2006 - 04:41 PM

thanks alot, do you know how to give the user tha ability to print the report without pressing next on each page

thanks again

#8 HuggieBear

HuggieBear
  • Members
  • PipPipPip
  • Advanced Member
  • 1,899 posts
  • LocationEngland, UK

Posted 10 October 2006 - 04:47 PM

You haven't implied anywhere that your results are going to be on more than one page... Are they?

Regards
Huggie
Advice to MySQL users: Get phpMyAdmin and test your queries work there first, take half the hassle out of diagnosis, also check the reserved words list.

Links: PHP Docs :: RegEx's :: MySQL :: DevGuru :: w3schools

#9 isaac_cm

isaac_cm
  • Members
  • PipPipPip
  • Advanced Member
  • 319 posts

Posted 10 October 2006 - 04:59 PM

yes may be more than 30 pages, I know how to make next, previous button but when the user will go for printing it will be very frustrating

#10 craygo

craygo
  • Staff Alumni
  • Advanced Member
  • 1,973 posts
  • LocationRhode Island

Posted 10 October 2006 - 05:08 PM

would better off having a link to print entire report, that way they can still print just the page they want if nessasary.

Post the code you are using now and i can insert the code for you.

Ray

#11 isaac_cm

isaac_cm
  • Members
  • PipPipPip
  • Advanced Member
  • 319 posts

Posted 10 October 2006 - 05:13 PM

I did not make it yet I will use dreamweaver server behavior but I know
what you mean

I can pleace the your code in the right place

thanks

#12 craygo

craygo
  • Staff Alumni
  • Advanced Member
  • 1,973 posts
  • LocationRhode Island

Posted 10 October 2006 - 05:59 PM

well the concept would be this

Can have a link or button to pass on the variable "printreport"

<a href="<?=$_SERVER['PHP_SELF']?>?printreport=yes">Click here for entire report</a>

Then have this check on the page

<?php
if(isset($_GET['printreport'])){
// query to select all records
$sql = "select * FROM table";
} else {
// query to select records by page
$sql = "SELECT * FROM table LIMIT x, x";
?>

Ray

#13 isaac_cm

isaac_cm
  • Members
  • PipPipPip
  • Advanced Member
  • 319 posts

Posted 10 October 2006 - 06:18 PM

but would not be a very long page to display , I heared that there is another solution but using js, do you know it ?

thanks alot man




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users