473,385 Members | 2,210 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Pulling out matching values from a database

HaLo2FrEeEk
404 256MB
Hi, I'm using a mysql database to store information for the frontpage of my website, http://claninfectionist.com, I'm adding the tutorials right now, everything thing is going fine, but there is a problem that I forsaw, and lo and behold it happened. I'm one table called tutorials and storing the tutorials with one value being type, (example: photoshop, gimp, apophysis.) I want to use the type column to make a category page, the code I am using is this:

[PHP]$sql = mysql_query('SELECT `type` FROM `tutorials`') or die("Error: ".mysql_error());

while($info = mysql_fetch_array($sql)) {
echo ucfirst($info['type'])."<br />";
}[/PHP]

Since I have more than one of each type of tutorial (actually, right now, I have two of each) its printing out the type for each one, so I'm getting two photoshops, two gimps, and two apophysis'. Is there some code that I can use to only pull out each type once, even if it is in the type field more than once. My first thought was some comparison code, but I've not been doing PHP for long, so I don't really know how. Can anyone give me an easy way (or just any way, if there is no easy way, I'm not too picky) to do this please, I would be very grateful.

The reason that I have the type in there like this, instead of having each type in its own seperate table, is becuase I want to have someone be able to go to http://claninfectionist.com/tutorials/ and it'll show all the different programs we have tutorials for, then if they go to http://claninfectionist.com/tutorials/?cat=photoshop, it'll show all the tutorials for photoshop, then they can go to http://claninfectionist.com/tutorial...tut=GrungeText and it'll show that tutorial. I know this is possible, and relatively simple, so can anyone help me?

~HaLo2FrEeEk
Feb 10 '07 #1
5 1431
ronverdonk
4,258 Expert 4TB
Use the GROUP BY attribute as in:
Expand|Select|Wrap|Line Numbers
  1. SELECT type FROM tables GROUP BY type;
Ronald :cool:
Feb 11 '07 #2
HaLo2FrEeEk
404 256MB
You are amazing, thank you.
Feb 11 '07 #3
HaLo2FrEeEk
404 256MB
Sorry for the double post, but I have a further question.

I want to sort these further by category (I will change the current "type" to "program" and type will become the...type of tutorial, whether that be graphics, video, php, etc...

If I add an extra column to the table, called type (after changing current type to program), how will I sort them so that I can get an output like this:

Graphics:
Apophysis
Gimp
Photoshop

Video:
Vegas 7

Is this possible?

Thank you in advance.
Feb 11 '07 #4
HaLo2FrEeEk
404 256MB
Bump...anyone, please I need some help.
Feb 12 '07 #5
HaLo2FrEeEk
404 256MB
Please!

I need some help folks, I tried to do this on my own but I can't find anything that works.
Feb 12 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Philip D Heady | last post by:
Ok, as some of you may know I'm an Oracle newbie w/ PHP. I'd rather use MySQL but at the office here we use Oracle and boy do I have alot to learn. I'm starting to hate it after using MySQL!! ...
1
by: Dariusz | last post by:
Despite looking at a number of tutorials in books and online examples on pattern matching - I can't quite get my head around it to work... so need some help. What I have now is a variable that...
17
by: Andrew McLean | last post by:
I have a problem that is suspect isn't unusual and I'm looking to see if there is any code available to help. I've Googled without success. Basically, I have two databases containing lists of...
1
by: TG | last post by:
I have a problem trying to get a value from textbox 1 and textbox 2. If those two values match the data in the database then it has to return a third corresponding value to a third textbox (or...
5
by: Stewart | last post by:
Hi there, I have an Access database, which contains the details of company staff and services. The plan is to extract data from this database onto our forthcoming Intranet (no inserting,...
2
by: wertqt | last post by:
hi there, im having a slight problem in matching the user input(textbox's text) with the values in one of the columns from a MS Access database. Im using C#.NET. The situation is this : My...
2
by: julie18881 | last post by:
I may be being really stupid here, i have spent the last 3 hours looking round your site and some other for answers to my problem, but have not had much luck (possibly cuase my brain just isn't...
3
by: BobRoyAce | last post by:
I am using Visual Studio 2008 w/ VB.NET. For the database, I am using SQL Server 2005, which is running on a dedicated server box. I am creating a WinForms application for a client. It is run...
4
by: pavanponnapalli | last post by:
hi, Here is my Code as under: #! /usr/bin/perl -w use DBI; my %hash; my @arr; my @arr1; my @arr2;
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.