ryanewing Posted December 27, 2007 Share Posted December 27, 2007 I am very new to PHP and MySQL. I have a table, users, information such as a primary "id", a "firstname" and "lastname". I also have a table, events, that has three fields: fbla101, php101, and marketing. Each of these is populated with an "id" from the previous table. This is an example of what my events table looks like: fbla101 php101 marketing 4 4 5 [/td][td]5 I am having trouble displaying the firstname and lastname field for all of the "id"s under fbla101, or any other field in the events table. Any help would really be appreciated. Quote Link to comment Share on other sites More sharing options...
phpjabbers Posted December 27, 2007 Share Posted December 27, 2007 Hi write your db table structure so I can write you the query you need. from the information you provided your query should be something like: select t1.fbla101, t2.firstname, t2.lastname from users as t1, events as t2 where t2.fbla101 = t1.id Quote Link to comment Share on other sites More sharing options...
ryanewing Posted December 27, 2007 Author Share Posted December 27, 2007 This is a very simple version of my two tables. users table: id firstname lastname 1ryanewing events table: fbla101 php101 marketing 1 [/td][td]1 Anything ideas? Quote Link to comment Share on other sites More sharing options...
ryanewing Posted December 28, 2007 Author Share Posted December 28, 2007 :-\ Is this the wrong forum? Is it too complicated? Is it too easy? Did I not provide enough information? I think phpjabbers gave me what I need, but I don't know how to display the data. Is it time to move my question to the php forum? Quote Link to comment Share on other sites More sharing options...
revraz Posted December 28, 2007 Share Posted December 28, 2007 SELECT users.firstname, users.lastname FROM users WHERE users.id=events.fbla101 OR users.id=events.php101 OR users.id=events.marketing; Try something like that. Quote Link to comment Share on other sites More sharing options...
ryanewing Posted December 29, 2007 Author Share Posted December 29, 2007 Hey revraz, I am getting an error with that query: MySQL said: #1054 - Unknown column 'events.fbla101' in 'where clause' Does anyone have any explanation? Quote Link to comment Share on other sites More sharing options...
drranch Posted December 29, 2007 Share Posted December 29, 2007 The query does not recognize the column on the events table Table name: events Column name: fbla101 double check to see if the column exists and if it does check to make sure your fbla101 in your query matches the name of the column and you will also want to check and make sure your table name is the same as the table name your using in your mysql query events Quote Link to comment Share on other sites More sharing options...
ryanewing Posted December 29, 2007 Author Share Posted December 29, 2007 I checked and checked again; my table is indeed called "events" and there are three fields that are "fbla101" "php101" and "marketing". All of them throw an error. SELECT users.firstname, users.lastname FROM users WHERE users.id=events.fbla101 OR users.id=events.php101 OR users.id=events.marketing #1054 - Unknown column 'events.fbla101' in 'where clause' I am running this through the SQL tab in phpMyAdmin on my webhost. Quote Link to comment Share on other sites More sharing options...
revraz Posted December 29, 2007 Share Posted December 29, 2007 See if this is better SELECT users.firstname, users.lastname FROM users, events WHERE users.id=events.fbla101 OR users.id=events.php101 OR users.id=events.marketing; Quote Link to comment Share on other sites More sharing options...
ryanewing Posted December 29, 2007 Author Share Posted December 29, 2007 With that query I get two columns, a "firstname" and a "lastname". The number of rows are correct, but everything is blank. There are no names under the columns. Would this have something to do with my data types? Quote Link to comment Share on other sites More sharing options...
revraz Posted December 29, 2007 Share Posted December 29, 2007 How do you want it to look? We didn't include the events field names in the SELECT statement since you said you just wanted to see first/last name. Quote Link to comment Share on other sites More sharing options...
ryanewing Posted December 29, 2007 Author Share Posted December 29, 2007 I am trying to create a page that will display the names of the users that have signed up for the different events. Example: Users that have signed up for FBLA 101: John Smith Jane Doe Rev Raz Users that have signed up for PHP 101: Bill Gates John Doe Rev Raz etc... Is this a little clearer? Quote Link to comment Share on other sites More sharing options...
revraz Posted December 30, 2007 Share Posted December 30, 2007 Using PHP? Quote Link to comment Share on other sites More sharing options...
ryanewing Posted December 30, 2007 Author Share Posted December 30, 2007 Yes, using PHP and MySQL. Quote Link to comment Share on other sites More sharing options...
ryanewing Posted January 3, 2008 Author Share Posted January 3, 2008 Does anyone have an idea on how to do this? I'm guessing I'll need some sort of loop, but I don't know where to go with that thought. Quote Link to comment Share on other sites More sharing options...
ryanewing Posted January 6, 2008 Author Share Posted January 6, 2008 Would I have more luck with this over in the PHP forum? Quote Link to comment Share on other sites More sharing options...
fenway Posted January 6, 2008 Share Posted January 6, 2008 I'm just reading this now... could you restate your question? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.