Re: PHP and JOIN... (I know.. it's easy!)
| From: | Jochem Maas | Date: | Tue, 08 Mar 2005 17:05:06 +0000 |
| Subject: | Re: PHP and JOIN... (I know.. it's easy!) | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-38821@lists.php.net to get a copy of this message | ||
Tristan.Pretty@risk.sungard.com wrote:
Cool. cheers for the quick responce... Well, my flatmate is one of two, I live with a lesbian couple in London... One is a falsh guru, sho recently got into PHP (she's a REAL brain box, and picsk stuff up sooo much quick than us mere mortals!) Hard life init ;-)shucks. :-)
Anyhoo, my prob, in more detail, with table structures (at the bottom!)...
An admin user should be able to:
Select one (or more, though I'm fine with looping, once I get this first one done) file ID number to see who's downloaded it, and see detailed info on them.
So I'm listing a list of all file id No's on page 1.
when the user selects the ID they wanna report on, the MYSQL query should read something like:
1. Get, and count user_id from table captures.
2. get all user info from table users, based on above user_id.
I'll then make a page that looks like this:
file name: User(s)
12.doc user@website.com (12 times)
bob@bill.com (1 times)
bush@dc.gov (2 times)
etc......
I'll make the email addresses/file name links to detailed info, but I'm fine with doing that...
Once I see a few Joins in action based on what I'm trying to do, I'll get it.. I'm self taught (as most of us are right?) and learn better from real
:-)
life example than books...some books are worth their weight in gold. some not.
Please find my table structure below...very good :-). I so *(*^*& busy that I haven't got time to get my head into mySQL mode. so to other listers with some JOIN foo: I've extracted sufficient info from the OP, any care to finalize? :-) (sorry tristan)
=============================== // stores only file id, user id and date etc... CREATE TABLE....captures(idint(11) NOT NULL auto_increment,user_idint(11) NOT NULL default '0',datedate NOT NULL default '0000-00-00',file_idint(8) NOT NULL default '0',page_idint(11) NOT NULL default '0',ipvarchar(255) NOT NULL default '', PRIMARY KEY (id) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=22 ; // all data pertainign to the file CREATE TABLEfiles(file_master_buvarchar(255) NOT NULL default '',idint(8) NOT NULL auto_increment,uploaded_byvarchar(255) NOT NULL default '',uploaded_datedate NOT NULL default '0000-00-00',edited_byvarchar(255) NOT NULL default '',edited_datedate NOT NULL default '0000-00-00',file_titlevarchar(255) NOT NULL default '',file_namevarchar(255) NOT NULL default '',file_catvarchar(255) NOT NULL default '',file_typevarchar(255) NOT NULL default '',file_desctext NOT NULL, PRIMARY KEY (id) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=19 ; // the users who fill out forms, are put here. I do a search each download to see if they're in the database already, based on email address... but that's kinda irrelevent here... ;-) CREATE TABLEusers(idint(11) NOT NULL auto_increment,salutationvarchar(255) NOT NULL default '',forenamevarchar(255) NOT NULL default '',surnamevarchar(255) NOT NULL default '',telvarchar(255) NOT NULL default '',faxvarchar(255) NOT NULL default '',companyvarchar(255) NOT NULL default '',job_titlevarchar(255) NOT NULL default '',streetvarchar(255) NOT NULL default '',street2varchar(255) NOT NULL default '',cityvarchar(255) NOT NULL default '',zipvarchar(255) NOT NULL default '',statevarchar(255) NOT NULL default '',countryvarchar(255) NOT NULL default '',hearvarchar(255) NOT NULL default '',us_optvarchar(255) NOT NULL default '',eu_optvarchar(255) NOT NULL default '', PRIMARY KEY (id) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=13 ; |