Jump to content

Archived

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

foreverhex

Question about MySQL query... I think.

Recommended Posts

This is the second time Ive posted on the MySQL part of phpfreaks. Add Im really new at the SQL aspect of php. So help if you can please.

I have a table. i want to be able to do a query where the url will say art.php?medium=photo , and it will show only photos instead of drawing ands what not. Not the table already has the rows set up, for this to work... I believe. Ive been researching this so I got a concept but its hard to find exactualy what you want if you dont know what its call. Also, how would you make it so that the return is in order by newest to oldest. Thanks for the help!

Share this post


Link to post
Share on other sites
First read the [url=http://dev.mysql.com/doc/refman/5.0/en/tutorial.html]MySQL tutorial[/url].  It'll take you through the basics.  Also see [url=http://www.php.net/manual/en/ref.mysql.php]PHP's MySQL functions[/url].

For your project you'll need to use the $_GET PHP superglobal to fetch the "?medium=photo" portion (I don't know if you knew that already).  Your MySQL table, [i]at minimum[/i], will need a TIMESTAMP (or DATETIME) field, probably an ENUM field for the "drawing," "photo," etc. categorization, a VARCHAR field for the title, and, if you have user-submitted artwork, some level of unsigned integer to correlate to the user id.

A query on your hypothetical table might look something like this:

[code]

SELECT * FROM artwork WHERE type='Photo' ORDER BY date;

[/code]

You also must decide if you want to store the image in the database or in a file on the server in which case you'll either need to store the filename or name the file according to the database entry's id.

Share this post


Link to post
Share on other sites
Yeah, I know the php elements of the project. It was just the pulling of the info I need. What you explained makes since. I going to read and then probably come back, lol. Thx

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.