Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,195,210 members, 7,957,474 topics. Date: Tuesday, 24 September 2024 at 01:19 PM |
Nairaland Forum / Science/Technology / Programming / Please How Do I Print This Data From MY Database. MYSQL, PHP (2043 Views)
I Need To Deal With My Database. / Free Online Training For Html/css, Javascript, Jquery, Mysql, Php, Java, Android / Problem Trying To Connect To My Database (2) (3) (4)
Please How Do I Print This Data From MY Database. MYSQL, PHP by Thirdwrist(m): 3:39am On Dec 29, 2016 |
Please fellow programmers, I have been going through this wahala on how to print data from database in a specific way: I have four tables i want to print data from simultaneously: memories, comment, users and likes, All at the same time . The issues is that i don't know what proper command to use, I have read joins but its either i dont understand or it cant be used for this measure. this is what i want to do: There a couple of data in the memories, i want to display each memories and with its comments, and the person who posted it, with the number of likes it received, all on the same page. and the above repeat again on the same page. Please I need help. Biko
|
Re: Please How Do I Print This Data From MY Database. MYSQL, PHP by paranorman(m): 4:18am On Dec 29, 2016 |
MySQL joins will solve your problem. Take your time and learn simple join examples from W3school website. |
Re: Please How Do I Print This Data From MY Database. MYSQL, PHP by onedayatime(m): 9:45am On Dec 29, 2016 |
can you upload the codes so as to study the code? |
Re: Please How Do I Print This Data From MY Database. MYSQL, PHP by Craigston: 12:34pm On Dec 29, 2016 |
You must be doing something wrong if you have four tables for that. Can you describe the structure of each table so we can know what relationships exist between your data entities? |
Re: Please How Do I Print This Data From MY Database. MYSQL, PHP by onedayatime(m): 1:23pm On Dec 29, 2016 |
Craigston: without what he said, no help can be rendered... 1 Like |
Re: Please How Do I Print This Data From MY Database. MYSQL, PHP by Thirdwrist(m): 2:45am On Jan 01, 2017 |
onedayatime: Here are the codes, thanks for the above info, I have made some improvement on my database after the analysis above... I am really grateful, but though the issues still persists.
The new comments table is attached below...
|
Re: Please How Do I Print This Data From MY Database. MYSQL, PHP by Thirdwrist(m): 2:48am On Jan 01, 2017 |
paranorman onedayatime Craigston onedayatime Dhtml18 dhtml |
Re: Please How Do I Print This Data From MY Database. MYSQL, PHP by onedayatime(m): 9:23am On Jan 01, 2017 |
it is the sql code that you should upload. It might be that the tables are not well structured and if well structured, I can help you on how to retrieve from the tables. You will still use join |
Re: Please How Do I Print This Data From MY Database. MYSQL, PHP by Craigston: 10:57am On Jan 01, 2017 |
onedayatime:Yea, we need to see his actual queries. Also try doing this, Thirdwrist: Go to your mysql executable, run it in a console, login as the appropriate user and select the database you're using. Then for each table in the database, execute the SQL statement "DESCRIBE tableName; > tableName_structure.txt" That will save the structure of each table you specify to the corresponding TXT file. Post the output of each file here, together with your SQL queries. That will make your problem much easier to solve. |
Re: Please How Do I Print This Data From MY Database. MYSQL, PHP by paranorman(m): 2:00pm On Jan 01, 2017 |
I don't know if your tables are properly normalized, But if you wanna extract data from four tables, you needa use Sql joins. If you can't post the tables' structures here, post the tables and how the are related, I mean the primary keys in a table and the corresponding foreign key in a related table. I will check out your code when I get on PC |
Re: Please How Do I Print This Data From MY Database. MYSQL, PHP by Thirdwrist(m): 2:06pm On Jan 01, 2017 |
Well the sql is in two parts: the first one pulls out the data for all memories stored by one user: SELECT * FROM memories WHERE m_author= '{$_SESSION['user_id']}' And the second attempts to retrieve all comments that individually belongs to those memories above:SELECT * FROM comments WHERE article_id = 3; Please how do I go bout it, so i can print each post(memories) with its own comment below
|
Re: Please How Do I Print This Data From MY Database. MYSQL, PHP by onedayatime(m): 8:22am On Jan 02, 2017 |
you've not shown us the real mysql code you use..you are only showing us the one mix with php. that only access the table. Do what craigson said you should do Craigston:you've not shown us the real mysql code you use..you are only showing us the one mix with php. that only access the table. Do what craigson said you should do. Or in phpMyAdmin click on the database you are working on and then click on export on the navigation. After exporting, you can upload the codes here. P.s. Mentioning names dosent mean users whose name you mentioned will solve it for you. What if non of them is online? What if I don't even visit the programming forum? Or I visit and I don't even click on your post? Just post your question and whoever wanna help you will help |
Re: Please How Do I Print This Data From MY Database. MYSQL, PHP by daPretender: 9:40am On Jan 02, 2017 |
Re: Please How Do I Print This Data From MY Database. MYSQL, PHP by onedayatime(m): 10:02am On Jan 02, 2017 |
no light for my area o. My lapi ba3 is down and d pix is no sharp |
Re: Please How Do I Print This Data From MY Database. MYSQL, PHP by onedayatime(m): 10:05am On Jan 02, 2017 |
better still, write out the names of the tables and the fields and columns under each table |
Re: Please How Do I Print This Data From MY Database. MYSQL, PHP by kudaisi(m): 11:21am On Jan 03, 2017 |
I'm not really sure what you want, but I made a rough code based on what you've described and I hope it meets your requirement. Attached is a screenshot of the resulting output looks like and here is the code: <html> Disclaimer: Use the code at your own risk.
|
Re: Please How Do I Print This Data From MY Database. MYSQL, PHP by Nobody: 7:55pm On Jan 04, 2017 |
it seem to me that d front-end web app is a forum site. and i got d feeling dat d database.name table was never created with specified class functions that dispays dz information in rows for each users, but clustered abt in 4 separate tables. in cases lyk dz a single container table wuld have bin inplemented in the first place to specify each user with their attributes organised neatly in multi-rows. i m curious to knw if u av solved d abv problem till now? well, u are still going to code a mysql query syntax to JOIN the tables. and since u want to merge the four tables into one, it can be tricky n confusing but knowing ur primary key and foreign key will make the work much easier. meaning to really get d whole wrap upstairs, u shuld first join tb1 to tb2 to form tb2, then join tb2 to tb3 to form tb3 then finally join tb3 to tb4 to form 4tb? i knw its confusing but JOIN or subquery is d only way. or u jst first identify a link-register tha wuld act as d foreign key among all d four data tables. |
Re: Please How Do I Print This Data From MY Database. MYSQL, PHP by onedayatime(m): 8:04am On Jan 05, 2017 |
Coin2naira:you can do what he says or write the names of the tables and its field. E.g. table comments: id, article_id, etc. table article: id, likes, mention etc. Other tables as well. |
Re: Please How Do I Print This Data From MY Database. MYSQL, PHP by interjames: 10:45am On Jan 05, 2017 |
He needs a very straight and simple answer lets not complicate the whole issue, take your time to learn everything about SQL queries then you can manipulate as much as you can |
(1) (Reply)
Question on Java Development / Programming Vs Networking / Top 100 Africa's Most Innovative Startups To Follow In 2014
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 54 |