isaac_cm Posted October 10, 2006 Share Posted October 10, 2006 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 itemsfor example:Silk item 1 item 2 item 3wool item 4 item 5 item 6ans so on, any idea ? thanks Quote Link to comment https://forums.phpfreaks.com/topic/23563-display-group-of-data/ Share on other sites More sharing options...
HuggieBear Posted October 10, 2006 Share Posted October 10, 2006 Can you provide me with your column names?RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/23563-display-group-of-data/#findComment-106949 Share on other sites More sharing options...
isaac_cm Posted October 10, 2006 Author Share Posted October 10, 2006 date, main_group, sub_group, item name, quantity, price Quote Link to comment https://forums.phpfreaks.com/topic/23563-display-group-of-data/#findComment-106961 Share on other sites More sharing options...
HuggieBear Posted October 10, 2006 Share Posted October 10, 2006 So silk and wool are sub groups or main groups?RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/23563-display-group-of-data/#findComment-106962 Share on other sites More sharing options...
isaac_cm Posted October 10, 2006 Author Share Posted October 10, 2006 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 Quote Link to comment https://forums.phpfreaks.com/topic/23563-display-group-of-data/#findComment-106964 Share on other sites More sharing options...
HuggieBear Posted October 10, 2006 Share Posted October 10, 2006 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.RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/23563-display-group-of-data/#findComment-106972 Share on other sites More sharing options...
isaac_cm Posted October 10, 2006 Author Share Posted October 10, 2006 thanks alot, do you know how to give the user tha ability to print the report without pressing next on each pagethanks again Quote Link to comment https://forums.phpfreaks.com/topic/23563-display-group-of-data/#findComment-106975 Share on other sites More sharing options...
HuggieBear Posted October 10, 2006 Share Posted October 10, 2006 You haven't implied anywhere that your results are going to be on more than one page... Are they?RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/23563-display-group-of-data/#findComment-106981 Share on other sites More sharing options...
isaac_cm Posted October 10, 2006 Author Share Posted October 10, 2006 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 Quote Link to comment https://forums.phpfreaks.com/topic/23563-display-group-of-data/#findComment-106984 Share on other sites More sharing options...
craygo Posted October 10, 2006 Share Posted October 10, 2006 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 Quote Link to comment https://forums.phpfreaks.com/topic/23563-display-group-of-data/#findComment-106995 Share on other sites More sharing options...
isaac_cm Posted October 10, 2006 Author Share Posted October 10, 2006 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 Quote Link to comment https://forums.phpfreaks.com/topic/23563-display-group-of-data/#findComment-107004 Share on other sites More sharing options...
craygo Posted October 10, 2006 Share Posted October 10, 2006 well the concept would be thisCan 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]<?phpif(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 Quote Link to comment https://forums.phpfreaks.com/topic/23563-display-group-of-data/#findComment-107035 Share on other sites More sharing options...
isaac_cm Posted October 10, 2006 Author Share Posted October 10, 2006 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 Quote Link to comment https://forums.phpfreaks.com/topic/23563-display-group-of-data/#findComment-107052 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.