Jump to content

Question about MySQL query... I think.


foreverhex

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!
Link to comment
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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.