Jump to content

Archived

This topic is now archived and is closed to further replies.

isaac_cm

display group of data

Recommended Posts

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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Try this then....

[code]<?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";
}
?>
[/code]

You'll possibly need to change your SQL query.

Regards
Huggie

Share this post


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

thanks again

Share this post


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

Regards
Huggie

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
well the concept would be this

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

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

Then have this check on the page

[code]<?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";
?>[/code]

Ray

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

×

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.