Jump to content

pcmac

New Members
  • Posts

    7
  • Joined

  • Last visited

pcmac's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. many thanks for your help much appreciated
  2. I am working on this project with someone else they have done the database side of things with their team - I am just working with what I am given. Thanks for this will give it a go. What would an elegant way be? In theory; if you don't want to write the code - its fine I would just like the best way to achieve this.
  3. The table has been created - I don't have control over this unfortunatley - can I not achieve the same thing with one table?
  4. Ok I'll start from the start. All the data is in one table. I don't need any other data apart from the company and that company's spec. It may look like there is repeated data in the database but its not the case... I don't think its necessary for me to go into detail about this. I have returned and displayed the values of the company and the spec using the sql query... All I want to achieve it is grouping the spec under the company... I'm not sure how my code doesn't make sense as it is working. The company and spec id returned on each row as shown in my first post. I can see how it looks like I am displaying the data in the table from my first post but the spec is bullet points of the spec - It not important how I display it for now as I can figure that out. - I don't need it bullet pointed for now - just showing the spec under the company will be more than enough! For now all I want to achieve it grouping the spec under the company... Do I use two queries? One query for retrieving the data...and 2nd query to retrieve the spec depending on company? I really not sure how to use multiple queries... If I can be pointed in the right direction will be much appreciated or if I can give any other information to make it clear please do let me know. Hope we can find a solution for this. Many thanks p.s. I can do the HTML part - no need for advice on that - just the help on displaying the correct data please
  5. My code <?php $result = "SELECT * FROM mydatabase WHERE id = '$id'"; $companyresult = mysql_query($result); while($row = mysql_fetch_array($companyresult)) { ?> <ul> <?php if($company != $row['company']){ echo $company = $row['company']; }?> <li> <?php echo $row['spec1']; ?> </li> </ul> } ?> Thank you
  6. Many thanks for your reply Jacques1. I can use DISTINCT no problem but my issue is grouping the spec under the distinct company name. Currently my data is displayed like this: Company Spec company 1 spec1 company 1 spec2 company 1 spec3 company 1 spec1 company 1 spec2 When I tried using DISTINCT in my query (before posting in forums for help) I had two queries - one to show 'distinct' company name and the 2nd query to display the spec but it showed the ALL the values from the spec column rather than then the spec for example company 1; like this: Company Spec company 1 spec1 spec2 spec3 I hope you can shed some light on this for me and point me in the right direction... Many thanks again for your response looking forward to your reply again Yep I thought this too but it was suggestion from a coder so I thought I'd mention it incase it was suggested again!
  7. Hi everyone I have created my query that returns the results I require however I need to change how its displayed Company Spec company 1 spec1 company 1 spec2 company 1 spec3 company 1 spec1 company 1 spec2 company 2 spec4 company 2 spec5 company 2 spec1 company 2 spec5 company 2 spec4 I need this to be displayed like this: Company Spec company 1 spec1 spec2 spec3 company 2 spec1 spec4 spec5 So I need the company name distinct but I want the spec values to show under the company as well rather than on each row shown above. I know it looks like the values a duplicated but they're not - theres other columns in the database with unique values I hope that makes sense... can anyone help me please? I have tried using GROUP by and the company appears once but then how do I display all the corresponding spec options under the company? Hope someone can help me with this. Many thanks
×
×
  • 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.