Jump to content


Photo

Question about MySQL query... I think.


  • Please log in to reply
2 replies to this topic

#1 foreverhex

foreverhex
  • Members
  • PipPipPip
  • Advanced Member
  • 91 posts

Posted 10 July 2006 - 06:57 PM

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!

#2 Wildbug

Wildbug
  • Members
  • PipPipPip
  • Advanced Member
  • 1,149 posts

Posted 10 July 2006 - 08:18 PM

First read the MySQL tutorial.  It'll take you through the basics.  Also see PHP's MySQL functions.

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, at minimum, 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:


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


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.
Twice a day my clock works PERFECTLY!  I can't figure out what's wrong with it.

#3 foreverhex

foreverhex
  • Members
  • PipPipPip
  • Advanced Member
  • 91 posts

Posted 10 July 2006 - 08:28 PM

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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users