l4cky Posted January 26, 2011 Share Posted January 26, 2011 :'( Hi!! I have big problems and I am pretty new to php and mysql. Here's what I want to do. I have 3 databases (mysql): DB 1 info: Paddler ID, first name, last name, as Paddler ID primary key DB 2 exercise: Exercise ID, Paddler ID, Practice ID, Push-up, Abs DB 3 practicedate: Practice ID, Date Now what I want to do 2 things: 1) Print a table for each paddler as titled "first name, last name" where rows = Push ups & abs ; columns are Dates 2) Print a table for each exercice (as titled "push ups" and "abs") where rows = first name and last name ; columns are Dates I want to get it autmaticly printed if for each paddler ID found on DB2, so if a paddler is added, there will be less trouble. I have i have to use some array, but I don't really know.. also I think I need to link databases too It's hard for me to accomplish it because I am new, any help? Haven't slep a while because of that Quote Link to comment https://forums.phpfreaks.com/topic/225693-havent-slept-for-14hours-can-u-help-with-code/ Share on other sites More sharing options...
Zurev Posted January 26, 2011 Share Posted January 26, 2011 :'( Hi!! I have big problems and I am pretty new to php and mysql. Here's what I want to do. I have 3 databases (mysql): DB 1 info: Paddler ID, first name, last name, as Paddler ID primary key DB 2 exercise: Exercise ID, Paddler ID, Practice ID, Push-up, Abs DB 3 practicedate: Practice ID, Date Now what I want to do 2 things: 1) Print a table for each paddler as titled "first name, last name" where rows = Push ups & abs ; columns are Dates 2) Print a table for each exercice (as titled "push ups" and "abs") where rows = first name and last name ; columns are Dates I want to get it autmaticly printed if for each paddler ID found on DB2, so if a paddler is added, there will be less trouble. I have i have to use some array, but I don't really know.. also I think I need to link databases too It's hard for me to accomplish it because I am new, any help? Haven't slep a while because of that 14 hours of not sleeping is a lot? Seems to be the average imo... Anyway, just to clear things up, do you have any code you can provide for us to start with? Also, are they 3 different databases, or tables within a database? If it's the former, are you restricted to switching it to the latter? Quote Link to comment https://forums.phpfreaks.com/topic/225693-havent-slept-for-14hours-can-u-help-with-code/#findComment-1165307 Share on other sites More sharing options...
l4cky Posted January 26, 2011 Author Share Posted January 26, 2011 :'( Hi!! I have big problems and I am pretty new to php and mysql. Here's what I want to do. I have 3 databases (mysql): DB 1 info: Paddler ID, first name, last name, as Paddler ID primary key DB 2 exercise: Exercise ID, Paddler ID, Practice ID, Push-up, Abs DB 3 practicedate: Practice ID, Date Now what I want to do 2 things: 1) Print a table for each paddler as titled "first name, last name" where rows = Push ups & abs ; columns are Dates 2) Print a table for each exercice (as titled "push ups" and "abs") where rows = first name and last name ; columns are Dates I want to get it autmaticly printed if for each paddler ID found on DB2, so if a paddler is added, there will be less trouble. I have i have to use some array, but I don't really know.. also I think I need to link databases too It's hard for me to accomplish it because I am new, any help? Haven't slep a while because of that 14 hours of not sleeping is a lot? Seems to be the average imo... Anyway, just to clear things up, do you have any code you can provide for us to start with? Also, are they 3 different databases, or tables within a database? If it's the former, are you restricted to switching it to the latter? You're right, 3 tables my bad!! I haven't started anything working, garbage them delete them, cuz I can't think of something, don'T know where to start lol I am still working on it. Actually havent slept for 14 days, but had been working on it for 2-3 days. But the biggest problem is like I want to speak German while I can only use google translate (my newbness to php). What does " restricted to switching it to the latter?" stands for? Quote Link to comment https://forums.phpfreaks.com/topic/225693-havent-slept-for-14hours-can-u-help-with-code/#findComment-1165326 Share on other sites More sharing options...
PinoyProgrammer Posted January 26, 2011 Share Posted January 26, 2011 Use the join statement of mysql. Something like: SELECT fname, lname, pusups, abs, date FROM table1 t1 LEFT JOIN table2 t2 (t2.praddlerid=t1.id) LEFT JOIN table3 t3 (t3.exerciseid=t2.exercciseid) Quote Link to comment https://forums.phpfreaks.com/topic/225693-havent-slept-for-14hours-can-u-help-with-code/#findComment-1165330 Share on other sites More sharing options...
l4cky Posted January 30, 2011 Author Share Posted January 30, 2011 :confused: :confused: :'( I wanna give up!! i am so confused , can anyone help? i tried that and can't even write the correct syntax sigh, can anyone takes a llook of that? i want to make an array of tables... <? include("../sql.php"); $r = mysql_query("SELECT * FROM paddlerinfo t1 LEFT JOIN pushup t2 on t2.paddler_id=t1.id LEFT JOIN practicedate t3 on t3.practice=t2.practice_id ORDER BY t1.firstname ASC "); while ($row = mysql_fetch_array($r)) { if (t2.paddler_id=t1.id [sup]EXISTS AND PRINT THE ID ONLY ONCE[/sup]){ echo $row['firstname']; echo "<br>"; echo "<table border='1' cellpadding='0' cellspacing='0' style='font-family: monospace'> <tr>"; echo "<td> date </td>"; $result = mysql_query("EXPLAIN pushup"); while ($row = mysql_fetch_assoc($result)) { if (in_array($row["Field"], array("paddler_id", "practice_id", "p_id"))) continue; echo "<td>", htmlentities($row["Field"]), "</td>" ; /[sup]/THIS IS SUPPOSED TO PRINT ALL COLUMN TITLE AS THE T3 COLUMNS[/sup] } echo [sup]VALUES OF PRACTICEDATE T3 AND VALUES OF EXERCICES FROM T3 COLUMNS[/sup]; echo "</tr> </table>"; mysql_free_result($r); mysql_free_result($result); mysql_close(); ?> Quote Link to comment https://forums.phpfreaks.com/topic/225693-havent-slept-for-14hours-can-u-help-with-code/#findComment-1167253 Share on other sites More sharing options...
doddsey_65 Posted January 30, 2011 Share Posted January 30, 2011 can you write exactly how you want it to look when you open the webpage? Quote Link to comment https://forums.phpfreaks.com/topic/225693-havent-slept-for-14hours-can-u-help-with-code/#findComment-1167256 Share on other sites More sharing options...
l4cky Posted January 30, 2011 Author Share Posted January 30, 2011 can you write exactly how you want it to look when you open the webpage? Thanks for replying! My target is: Once page opens it list all paddlers name (only those id who existed has stats into the pushuptable) using <li><a href="#paddlerfirstname">paddlerfirstname</a> Then Make a table name titled as "first paddler name" Then the table where columns = different type of push ups (which are the fields of table pushup except 3 fields (p_id, paddler_id, practice_id) and where rows are the dates of practices (which is a field of table 3 practicedate) Quote Link to comment https://forums.phpfreaks.com/topic/225693-havent-slept-for-14hours-can-u-help-with-code/#findComment-1167264 Share on other sites More sharing options...
doddsey_65 Posted January 30, 2011 Share Posted January 30, 2011 so to clarify: All Paddler First Name List Here Paddler First Name -------------------------------------------- | pushup 1 | pushup 2 | pushup 3 | pushup 4| -------------------------------------------- | date 1 | date 2 | date 3 | date 4 | -------------------------------------------- is that right? Quote Link to comment https://forums.phpfreaks.com/topic/225693-havent-slept-for-14hours-can-u-help-with-code/#findComment-1167266 Share on other sites More sharing options...
l4cky Posted January 30, 2011 Author Share Posted January 30, 2011 so to clarify: All Paddler First Name List Here Paddler First Name -------------------------------------------- | pushup 1 | pushup 2 | pushup 3 | pushup 4| -------------------------------------------- | date 1 | date 2 | date 3 | date 4 | -------------------------------------------- is that right? More like this : -------------------------------------------- | pushup 1 | pushup 2 | pushup 3 | pushup 4| -------------------------------------------- | date 1 | value1 | value 2 | value3 | value 4| -------------------------------------------- | date 2 | value1 | value 2 | value3 | value 4| -------------------------------------------- Thanks!! Quote Link to comment https://forums.phpfreaks.com/topic/225693-havent-slept-for-14hours-can-u-help-with-code/#findComment-1167267 Share on other sites More sharing options...
l4cky Posted January 30, 2011 Author Share Posted January 30, 2011 Quote Link to comment https://forums.phpfreaks.com/topic/225693-havent-slept-for-14hours-can-u-help-with-code/#findComment-1167364 Share on other sites More sharing options...
doddsey_65 Posted January 31, 2011 Share Posted January 31, 2011 so what is date 1 and date 2 in the database? is it the practicedate table column DATE? if so then what is value 1 and value 2 in the database? Quote Link to comment https://forums.phpfreaks.com/topic/225693-havent-slept-for-14hours-can-u-help-with-code/#findComment-1167570 Share on other sites More sharing options...
l4cky Posted January 31, 2011 Author Share Posted January 31, 2011 so what is date 1 and date 2 in the database? is it the practicedate table column DATE? if so then what is value 1 and value 2 in the database? hey! yes it is the practice table column DATE. Value 1 and 2 and etc.. are # of pushups of table pushup So basicly the tables in the DB are Table paddlerinfo id firstname Table pushup paddler_id practice_number wide_push_ups normal_push_ups miliraty_push_ups table practicedate practice_id date and join table 2 and 1 where paddler_id table 2 = id table 1 ; join table 3 and 2 where practice_number table 2 = practice_id table 3 Quote Link to comment https://forums.phpfreaks.com/topic/225693-havent-slept-for-14hours-can-u-help-with-code/#findComment-1167667 Share on other sites More sharing options...
l4cky Posted February 8, 2011 Author Share Posted February 8, 2011 um.. it's not solved . why is it marked as solved? Quote Link to comment https://forums.phpfreaks.com/topic/225693-havent-slept-for-14hours-can-u-help-with-code/#findComment-1171345 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.