ksumanth Posted February 2, 2013 Share Posted February 2, 2013 Hello guys, I created one form called Events in that 9 fields there like Id, Title, Eventdesc, video1,video2,video3,video4,video5,video6. This is storing in database and while fetching data from database to frontend. i need to display all the videos video1,video2,video3,video4,video5,video6 for the particular event. For that i need to fetch all the columns for particular row can any suggest me Regards, Sumanth Quote Link to comment https://forums.phpfreaks.com/topic/273949-fetching-column-values-for-particular-row/ Share on other sites More sharing options...
jcbones Posted February 2, 2013 Share Posted February 2, 2013 To answer the question explicitly, you should have a primary key column, most people call this the id, and make it an integer auto-incremented. I'm not sure that is what your id is set up as. Then you can call any row by "WHERE id=". For pointers, your posted structure is going to limit you for future expansion (scaling). I would suggest that you normalize your database, which would include making 2 tables. 1 for events, and 1 for video's. In this way, you could have many more than 6 video's for every event, and could easily add pics, comments, or any other thing you might think of. Example: tables CREATE TABLE IF NOT EXISTS `events` ( `id` int(11) NOT NULL AUTO_INCREMENT, `title` varchar(25) NOT NULL, `description` text NOT NULL, `event_date` datetime NOT NULL, PRIMARY KEY (`id`) ); CREATE TABLE IF NOT EXISTS `videos` ( `id` int(11) NOT NULL AUTO_INCREMENT, `event` int(11) NOT NULL, `title` varchar(20) NOT NULL, `url` varchar(255) NOT NULL, PRIMARY KEY (`id`) ); Now you can access all your video's for any event, 100's if you wish. To add pictures, music, comments, etc, just add the relevant table, and join it to the events with the event to event.id column. "SELECT e.title, e.description, v.title AS vidTitle, v.url FROM events AS e JOIN videos AS v ON e.id = v.event WHERE e.id = 1"; Quote Link to comment https://forums.phpfreaks.com/topic/273949-fetching-column-values-for-particular-row/#findComment-1409717 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.