post problem

Reply

Join Date: Nov 2007
Posts: 16
Reputation: dbayo is an unknown quantity at this point 
Solved Threads: 0
dbayo dbayo is offline Offline
Newbie Poster

post problem

 
0
  #1
Apr 9th, 2008
hello..i have a problem when i try to post the value from form 2.php to form 4.php..this form name 2.php..i make a table in this form.the problem is, i cannot post all the value that i wrote, it just take the last value for the proccess..anybody?..plz help me..u can try run dis coding..im not very good in english to explain..tq

this is form 2.php.
  1. <?php
  2.  
  3. $con = mysql_connect("localhost","root","");
  4. if (!$con)
  5. {
  6. die('Could not connect: ' . mysql_error());
  7. }
  8. mysql_select_db("kptm", $con);
  9. $result = mysql_query("SELECT * FROM student ORDER BY NAMA");
  10.  
  11.  
  12.  
  13.  
  14. echo"<form name='kptm' form method='POST' action='4.php'>";
  15. echo"<h1 align='center'> Student Statement</h1>";
  16.  
  17.  
  18.  
  19. echo"<table border='2'align='center'>";
  20. echo"<p align='center'>SUBJECT : UNIX (TK 213)";
  21. echo "<tr> ";
  22. echo"<p align='center'>";
  23. echo"<td width='20'>Bil";
  24. echo"<td width='230'> Nama Pelajar";
  25. echo"<td width='100'> Ic Pelajar";
  26. echo"<td width='80'> UJIAN 1 &nbsp&nbsp n/15";
  27. echo"<td width='80'> UJIAN 2 &nbsp&nbsp n/15";
  28. echo"<td width='90'> TUGASAN &nbsp&nbsp n/15";
  29. echo"<td width='70'> KUIZ &nbsp&nbsp n/5";
  30. echo"<td width='70'> CARRY MARK &nbsp&nbsp n/50";
  31. echo"<td width='60'> Final Exam &nbsp&nbsp n/50";
  32. echo"<td width='60'> Jumlah &nbsp&nbsp n/100";
  33. echo"</tr>";
  34. echo"</table>";
  35.  
  36.  
  37.  
  38. for ($i=1;$i<=10; $i++)
  39. {
  40.  
  41.  
  42. echo"<table border='2'align='center'>";
  43.  
  44.  
  45. while ($row = mysql_fetch_array($result))
  46. {
  47. echo "<tr> ";
  48.  
  49. $Nama = $row["NAMA"];
  50. $Ic = $row["IC"];
  51.  
  52.  
  53. echo"<td width='18'>$i";
  54.  
  55. echo"<td width='230'><input type=text name=nama value='$Nama' size=35 maxlength=5 >\t ";
  56. echo"<td width='100'><input type=text name=nama value='$Ic' size=12 max length=5 >\t ";
  57. echo"<td width='80'><input type=text name=ujian1 size=9 max length=5 >\t ";
  58. echo"<td width='80'><input type=text name=ujian2 size=9 max length=5 >\t ";
  59. echo"<td width='90'><input type=text name=tugasan size=11 max length=5 >\t ";
  60. echo"<td width='70'><input type=text name=kuiz size=6 max length=5 >\t ";
  61. echo"<td width='70'><input type=text name=carry size=8 ><br/> ";
  62. echo"<td width='60'><input type=text name=final size=6 ><br/> ";
  63. echo"<td width='60'><input type=text name=final2 size=6 ><br/> ";
  64.  
  65. echo"</tr>";
  66.  
  67. echo"</tr>";
  68.  
  69. }
  70. echo"</table>";
  71.  
  72. }
  73.  
  74.  
  75.  
  76. echo"<p align='center'><button type='submit' align='center' name='Button'><img src='images/apply.png' alt='save' align='center' width='40' height='40'></button>&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp<button type='submit' align='center' name='Button'><img src='images/cancel.png' alt='save' align='center' width='40' height='40'>";
  77.  
  78.  
  79. ?>


this form name 4.php


  1. <?php
  2. $Final2=null;
  3. $gred=null;
  4.  
  5.  
  6.  
  7. $con = mysql_connect("localhost","root","");
  8. if (!$con)
  9. {
  10. die('Could not connect: ' . mysql_error());
  11. }
  12. mysql_select_db("kptm", $con);
  13. $result = mysql_query("SELECT NAMA FROM student ORDER BY NAMA");
  14.  
  15.  
  16. $Nama=$_POST["nama"];
  17. $Ujian1=$_POST["ujian1"];
  18.  
  19. $Ujian2=$_POST["ujian2"];
  20.  
  21. $Tugasan=$_POST["tugasan"];
  22.  
  23. $Kuiz=$_POST["kuiz"];
  24. $Final=$_POST["final"];
  25.  
  26.  
  27.  
  28.  
  29. $carry = $Ujian1+$Ujian2+$Tugasan+$Kuiz;
  30. $Final2= $carry+$Final;
  31.  
  32.  
  33. echo"<form name='kptm' form method='POST' >";
  34. echo"<h1 align='center'> Penyata Markah Peperiksaan Akhir</h1>";
  35.  
  36.  
  37.  
  38. echo"<table border='2'align='center'>";
  39. echo"<p align='center'>SUBJEK : SISTEM UNIX (TK 213)";
  40. echo "<tr> ";
  41. echo"<p align='center'>";
  42. echo"<td width='20'>Bil";
  43. echo"<td width='230'> Nama Pelajar";
  44. echo"<td width='80'> UJIAN 1 &nbsp&nbsp n/15";
  45. echo"<td width='80'> UJIAN 2 &nbsp&nbsp n/15";
  46. echo"<td width='90'> TUGASAN &nbsp&nbsp n/15";
  47. echo"<td width='70'> KUIZ &nbsp&nbsp n/5";
  48. echo"<td width='70'> CARRY MARK &nbsp&nbsp n/50";
  49. echo"<td width='60'> Final Exam &nbsp&nbsp n/50";
  50. echo"<td width='60'> Jumlah &nbsp&nbsp n/100";
  51. echo"<td width='60'> Gred ";
  52. echo"</tr>";
  53. echo"</table>";
  54.  
  55.  
  56.  
  57. for ($i=1; $i<=18; $i++)
  58. {
  59. echo"<table border='2'align='center'>";
  60. while ($row = mysql_fetch_array($result))
  61. {
  62.  
  63. echo "<tr> ";
  64.  
  65. $Nama = $row["NAMA"];
  66.  
  67.  
  68.  
  69. if (($Final2 > 0) && ($Final2 <= 39))
  70. {
  71. $gred='F';
  72. }
  73. else if (($Final2 >= 40 ) && ($Final2 <= 49))
  74. {
  75. $gred='D';
  76. }
  77. else if (($Final2 >= 50) && ($Final2 <= 54))
  78. {
  79. $gred='C+';
  80. }
  81. else if (($Final2 >=55) && ($Final2 <= 59))
  82. {
  83. $gred='C';
  84. }
  85. else if (($Final2 >= 60) && ($Final2 <= 64))
  86. {
  87. $gred='B-';
  88. }
  89. else if (($Final2 >=65) && ($Final2 <= 69))
  90. {
  91. $gred='B';
  92. }
  93. else if (($Final2 >=70) && ($Final2 <= 74))
  94. {
  95. $gred='B+';
  96. }
  97. else if (($Final2 > 74) && ($Final2 <85))
  98. {
  99. $gred= 'A-';
  100. }
  101. else if(($Final2 > 85) && ($Final2 <= 100))
  102. {
  103. $gred='A';
  104. }
  105.  
  106.  
  107. echo "<tr> ";
  108.  
  109.  
  110. echo"<td width='18'>$i";
  111.  
  112. echo"<td width='230'><input type=text name=nama".$i." value='$Nama' size=34 max length=5 >\t ";
  113. echo"<td width='80'><input type=text name=ujian1".$i." value='$Ujian1' size=10 max length=5 >\t ";
  114. echo"<td width='80'><input type=text name=ujian2".$i." value='$Ujian2'size=9 max length=5 >\t ";
  115. echo"<td width='90'><input type=text name=tugasan".$i." value='$Tugasan'size=11 max length=5 >\t ";
  116. echo"<td width='70'><input type=text name=kuiz".$i." value='$Kuiz'size=6 max length=5 >\t ";
  117. echo"<td width='70'><input type=text name=carry".$i." value='$carry' size=8 ><br/> ";
  118. echo"<td width='60'><input type=text name=final value='$Final' size=6 ><br/> ";
  119. echo"<td width='60'><input type=text name=final2 value='$Final2' size=6 ><br/> ";
  120. echo"<td width='60'><input type=text name=gred value='$gred' size=6 ><br/> ";
  121.  
  122. echo"</tr>";
  123.  
  124. echo"</tr>";
  125.  
  126. }
  127. echo"</table>";
  128.  
  129. }
  130.  
  131.  
  132.  
  133. echo"<p>";
  134. echo"<p>";
  135. echo"<p align='center'><button type='submit' align='center' name='Button'><img src='images/apply.png' alt='save' align='center' width='40' height='40'></button>&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp<button type='submit' align='center' name='Button'><img src='images/cancel.png' alt='padam' align='center' width='40' height='40'>";
  136.  
  137.  
  138. ?>
Last edited by peter_budo; Apr 11th, 2008 at 9:18 pm. Reason: Keep It Organized - plase use [code] tags
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 145
Reputation: queenc is an unknown quantity at this point 
Solved Threads: 4
queenc's Avatar
queenc queenc is offline Offline
Junior Poster

Re: post problem

 
0
  #2
Apr 9th, 2008
ya u have written the code like tat.
  1. for ($i=1;$i<=10; $i++)
  2. {
  3. echo"<table border='2'align='center'>";
  4. while ($row = mysql_fetch_array($result))
  5. {
  6. echo "<tr> ";
  7. $Nama = $row["NAMA"];
  8. $Ic = $row["IC"];
  9. echo"<td width='18'>$i";

to my knowledge only after the loop execution the data will be sent to the next page,
$nama,$Ic value will be changing ...the last value will get stored when u try to post the data
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the PHP Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC