Jump to content

l4cky

Members
  • Posts

    13
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

l4cky's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. what do you mean? i am new to php and sql i would like to put on my website the stats of team members.. how can i do that?
  2. I want to make a table for each paddler_id (Field) which exists into pushup Database My code for paddler_id = 1 is require "../sql.php"; $result = mysql_query("EXPLAIN pushup"); $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 "); $r1 = mysql_query("SELECT * FROM pushup where paddler_id =1 ORDER BY practice_id ASC "); echo "<table width='30%' border='1' cellpadding='0' cellspacing='0' style='font-family: monospace'>"; echo "<tr>"; echo "<td>DATE</td>"; while ($row = mysql_fetch_array($result)) { if (in_array($row["Field"], array("paddler_id", "practice_id", "p_id"))) continue; echo "<td>",($row["Field"]), "</td>"; } echo "</tr>"; while (($data = mysql_fetch_array($r1, MYSQL_ASSOC)) !== FALSE) { unset($data["p_id"],$data["paddler_id"]); echo "<tr>"; foreach ($data as $k => $v) { echo "<td>"; echo"$v"; echo "</td>"; } echo "</tr>"; } echo "</table>"; mysql_free_result($result); mysql_free_result($r); mysql_free_result($r1); mysql_close(); The problem is on line $r1 = mysql_query("SELECT * FROM pushup where paddler_id =1 ORDER BY practice_id ASC "); I want to put something which makes it paddler_id = X where x = 2,3,4,5... and x exists in database and do not print twice the x (because that database may have rows where x = same id How do i do that??
  3. um.. it's not solved . why is it marked as solved?
  4. 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
  5. 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!!
  6. 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)
  7. :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(); ?>
  8. 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?
  9. :'( 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
  10. Hi wow!! Thank you for so fast reply! Your skills really impressed me, and I got to check out some stuffs I don't understand yet on what you write so I can learn I gave me an error on mysql_free_result($row); on index.php page, I changed it to mysql_free_result($result); and error is gone. Waiting for you to confirm. I also add the ?> of the end of insert page. Wow big thanks to you, I can keep continuing my work !! Thanks so much!!
  11. Hi guys, I am pretty new to php and mysql, so please don't only tell me what to do without showing me. Would be very appreciated. Thanks in advance!! Here is what I am trying to do. I am trying to use php to print the fields a table in Mysql into a form page called index.php. I think I sucessfully did it, but not the best way (mixing php and html, because I couldn't figure it out how to do it seperately) Everything looks good, except when I press submit and now we go to the insert_stats.php where the error: Warning: Invalid argument supplied for foreach() in /insert_stats.php on line 8 insert_stats.php <? include("sql.php"); $paddler = $_POST['paddler'] ; $practice = $_POST['practice'] ; $header = $_POST['header'] ; [b]foreach ($header as $value) [/b] { $insert="INSERT INTO pushup ($header) VALUES ('$value')"; mysql_query($insert) OR die(mysql_error()) ; } $insert2="INSERT INTO pushup (paddler_id , practice_id) VALUES ('$paddler' , '$practice')"; mysql_query($insert2) OR die(mysql_error()) ; mysql_close(); ?> index.php <table width="250" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"> <tr> <form id="pushup" name="pushup" method="post" action="insert_stats.php"> <td> <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF"> <tr> <td colspan="3" bgcolor="#E6E6E6"><strong>IDENTIFICATION</strong> </td> </tr> <tr> <td width="80%">Paddler ID</td> <td width="2%">:</td> <td width="18%"><input name="paddler" type="text" id="paddler" size="1" /></td> </tr> <tr> <td>Practice #</td> <td>:</td> <td><input name="practice" type="text" id="practice" size="1" /></td> </tr> <tr> <td colspan="3" bgcolor="#E6E6E6"><strong>ADD FITNESS STATS</strong> </td> </tr> <? include("sql.php"); $result = mysql_query("SELECT * FROM pushup"); $printed_headers = false; while ( $row = mysql_fetch_array($result) ) { if ( !$printed_headers ) { //print the headers once: echo "<tr>"; foreach ( array_keys($row) AS $header ) { if($header == 'paddler_id' || $header == 'practice_id' || $header == 'p_id') continue; if ( !is_int($header) ) { echo "<td>$header</td><td>:</td><td><input name='".$header."' type=\"text\" id='".$header."' size=\"1\" /></td></tr>"; } } $printed_headers = true; } } mysql_free_result($result); mysql_close(); ?> <tr> <td><input type="reset" name="Submit2" value="Reset" /></td> <td> </td> <td><input type="submit" name="Submit" value="Submit" /></td> </table> </td> </form> </tr> </table>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.