show results on same page

Reply

Join Date: Apr 2008
Posts: 35
Reputation: cali_dotcom is an unknown quantity at this point 
Solved Threads: 0
cali_dotcom cali_dotcom is offline Offline
Light Poster

show results on same page

 
0
  #1
Aug 19th, 2008
hi,
i'm a newbie programmer and i just built a website with a poll. the page is completely in html and linked to the php script processing the poll result in the action attribute of the form tag. my problem is the results of the poll comes up in a new page but i need the results of the poll to appear just under the poll itself on the same page. can anybody help me with that?
Last edited by cali_dotcom; Aug 19th, 2008 at 11:32 pm.
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 40
Reputation: enim213 is an unknown quantity at this point 
Solved Threads: 2
enim213 enim213 is offline Offline
Light Poster

Re: show results on same page

 
0
  #2
Aug 19th, 2008
ei.. if you want you're result on the same page use:

  1. <form method="post" action="<?php echo $_SERVER['PHP_SELF'];"></form>

then you're php code for the result on the top of you're html..
hope this help

enim
Last edited by enim213; Aug 19th, 2008 at 11:53 pm.
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 35
Reputation: cali_dotcom is an unknown quantity at this point 
Solved Threads: 0
cali_dotcom cali_dotcom is offline Offline
Light Poster

Re: show results on same page

 
0
  #3
Aug 20th, 2008
i thought about this option, but that would mean i have to put the php and html code on the same page, right? is there any way i could do this without putting the php and html codes on the page?
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 40
Reputation: enim213 is an unknown quantity at this point 
Solved Threads: 2
enim213 enim213 is offline Offline
Light Poster

Re: show results on same page

 
0
  #4
Aug 20th, 2008
like:
  1. <?php
  2. //index.php
  3. <form action="otherPage.php" method="post"><form>
  4. ?>
  5.  
  6. <?php
  7. //otherPage.php
  8. if($result)
  9. {
  10. // use meta tag here or header("Location: index.php");
  11. }
  12. ?>

is that what you mean.. processing from other page

enim
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 35
Reputation: cali_dotcom is an unknown quantity at this point 
Solved Threads: 0
cali_dotcom cali_dotcom is offline Offline
Light Poster

Re: show results on same page

 
0
  #5
Aug 22nd, 2008
yes this is exactly what i mean. the problem is that when i code this way, the result of the poll does not appear right underneath the poll questions but instaed on a different page. do you have any suggestions as to how i could solve this problem



Originally Posted by enim213 View Post
like:
  1. <?php
  2. //index.php
  3. <form action="otherPage.php" method="post"><form>
  4. ?>
  5.  
  6. <?php
  7. //otherPage.php
  8. if($result)
  9. {
  10. // use meta tag here or header("Location: index.php");
  11. }
  12. ?>

is that what you mean.. processing from other page

enim
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 9
Reputation: kashif farooq is an unknown quantity at this point 
Solved Threads: 0
kashif farooq kashif farooq is offline Offline
Newbie Poster

Re: show results on same page

 
0
  #6
Jul 24th, 2009
  1. $dbh=mysql_connect ("localhost", "user", "pwd") or die('Cannot connect to the database because: ' . mysql_error());
  2.  
  3. mysql_select_db ("dbname");
  4. // display records page wise code starts:
  5.  
  6. $adjacents = 3;
  7. $tbl_name="feedback";
  8.  
  9. $display = "SELECT COUNT(*) as num FROM $tbl_name";
  10. $total_pages = mysql_fetch_array(mysql_query($display));
  11. $total_pages = $total_pages[num];
  12.  
  13. /* Setup vars for query. */
  14.  
  15. $targetpage = "dispfeed.php"; //your file name (the name of this file)
  16. $limit = 5; //how many items to show per page
  17. $page = $_GET['page'];
  18.  
  19. if($page)
  20. $start = ($page - 1) * $limit; //first item to display on this page
  21. else
  22. $start = 0; //if no page var is given, set start to 0
  23.  
  24.  
  25. /* Get data. */
  26.  
  27. $display = "SELECT * FROM $tbl_name order by id desc LIMIT $start, $limit";
  28. $rs = mysql_query($display);
  29.  
  30. /* Setup page vars for display. */
  31.  
  32. if ($page == 0) $page = 1; //if no page var is given, default to 1.
  33. $prev = $page - 1; //previous page is page - 1
  34. $next = $page + 1; //next page is page + 1
  35. $lastpage = ceil($total_pages/$limit); //lastpage is = total pages / items per page, rounded up.
  36. $lpm1 = $lastpage - 1; //last page minus 1
  37.  
  38. /*
  39. Now we apply our rules and draw the pagination object.
  40. We're actually saving the code to a variable in case we want to draw it more than once.
  41. */
  42.  
  43. $pagination = "";
  44. if($lastpage > 1)
  45. {
  46. $pagination .= "<div class=\"pagination\">";
  47.  
  48. //previous button
  49. if ($page > 1)
  50. // $pagination.= "<a href=\"$targetpage?page=$prev\">? previous</a>"; (if display by asc...)
  51. $pagination.= "<a href=\"$targetpage?page=$prev\">? NEXT</a>";
  52. else
  53. // $pagination.= "<span class=\"disabled\">? previous</span>"; (if display by asc...)
  54. $pagination.= "<span class=\"disabled\">? NEXT</span>";
  55.  
  56. //pages
  57.  
  58. if ($lastpage < 7 + ($adjacents * 2)) //not enough pages to bother breaking it up
  59. {
  60. for ($counter = 1; $counter <= $lastpage; $counter++)
  61. {
  62. if ($counter == $page)
  63. $pagination.= "<span class=\"current\">$counter</span>";
  64. else
  65. $pagination.= "<a href=\"$targetpage?page=$counter\">$counter</a>";
  66. }
  67. }
  68.  
  69. elseif($lastpage > 5 + ($adjacents * 2)) //enough pages to hide some
  70. {
  71. //close to beginning; only hide later pages
  72. if($page < 1 + ($adjacents * 2))
  73. {
  74. for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++)
  75. {
  76. if ($counter == $page)
  77. $pagination.= "<span class=\"current\">$counter</span>";
  78. else
  79. $pagination.= "<a href=\"$targetpage?page=$counter\">$counter</a>";
  80. }
  81. $pagination.= "...";
  82. $pagination.= "<a href=\"$targetpage?page=$lpm1\">$lpm1</a>";
  83. $pagination.= "<a href=\"$targetpage?page=$lastpage\">$lastpage</a>";
  84. }
  85. //in middle; hide some front and some back
  86.  
  87. elseif($lastpage - ($adjacents * 2) > $page && $page > ($adjacents * 2))
  88. {
  89. $pagination.= "<a href=\"$targetpage?page=1\">1</a>";
  90. $pagination.= "<a href=\"$targetpage?page=2\">2</a>";
  91. $pagination.= "...";
  92. for ($counter = $page - $adjacents; $counter <= $page + $adjacents; $counter++)
  93. {
  94. if ($counter == $page)
  95. $pagination.= "<span class=\"current\">$counter</span>";
  96. else
  97. $pagination.= "<a href=\"$targetpage?page=$counter\">$counter</a>";
  98. }
  99. $pagination.= "...";
  100. $pagination.= "<a href=\"$targetpage?page=$lpm1\">$lpm1</a>";
  101. $pagination.= "<a href=\"$targetpage?page=$lastpage\">$lastpage</a>";
  102. }
  103. //close to end; only hide early pages
  104. else
  105. {
  106. $pagination.= "<a href=\"$targetpage?page=1\">1</a>";
  107. $pagination.= "<a href=\"$targetpage?page=2\">2</a>";
  108. $pagination.= "...";
  109. for ($counter = $lastpage - (2 + ($adjacents * 2)); $counter <= $lastpage; $counter++)
  110. {
  111. if ($counter == $page)
  112. $pagination.= "<span class=\"current\">$counter</span>";
  113. else
  114. $pagination.= "<a href=\"$targetpage?page=$counter\">$counter</a>";
  115. }
  116. }
  117. }
  118.  
  119. //next button
  120. if ($page < $counter - 1)
  121. // $pagination.= "<a href=\"$targetpage?page=$next\">next ?</a>"; (if display by asc...)
  122. $pagination.= "<a href=\"$targetpage?page=$next\">PREV ?</a>";
  123. else
  124. // $pagination.= "<span class=\"disabled\">next ?</span>"; (if display by asc...)
  125. $pagination.= "<span class=\"disabled\">PREV ?</span>";
  126.  
  127. $pagination.= "</div>\n";
  128. }
  129.  
  130. // display records page wise code ends:
  131.  
  132. if (mysql_num_rows($rs)>0)
  133. {
  134. while($row=mysql_fetch_array($rs))
  135. {
  136. ?>
  137. </p>
  138. </p>
  139. <table width = "62%" height="164" border="1" align="center" cellpadding="1" cellspacing="1">
  140. <tr>
  141. <td width="10%" height="23" valign="top" bgcolor="#0099FF" class="style27"><span class="style22"> Id. </span></td>
  142. <td colspan="4" valign="top" class="style27"><div align="justify"><span class="style27"><font face = tahoma><?php echo $row[0];?></span></div></td>
  143.  
  144.  
  145. <td width="26%" rowspan="9" align="center" valign="middle">
  146. <!-- <a href = "<?php echo $row[9];?>"> -->
  147. <img src = "<?php echo $row[9];?>" width="125" height="125" border=0 />
  148. </a>
  149. </td>
  150. </tr>
  151. <tr class="style27">
  152. <td height="23" valign="top" bgcolor="#0099FF" class="style18"><span class="style28"> Name </span></td>
  153. <td colspan="4" valign="top" class="style18"><div align="justify"><span class="style27"><font face = tahoma><?php echo $row[1];?></span></div></td>
  154. </tr>
  155. <tr class="style27">
  156. <td height="23" valign="top" bgcolor="#0099FF" class="style18"><span class="style28"> Email </span></td>
  157. <td colspan="4" valign="top" class="style18"><div align="justify"><span class="style27"><font face = tahoma><a href = "mailto:<?php echo $row[2];?>"><?php echo $row[2];?></a></span></div></td>
  158. </tr>
  159. <tr class="style27"><td height="23" valign="top" bgcolor="#0099FF" class="style18"><span class="style28">Gender </span></td>
  160. <td colspan="4" valign="top" class="style18"><div align="justify"><span class="style27"><font face = tahoma><?php echo $row[3];?></span></div></td>
  161. <tr class="style27">
  162. <td height="23" valign="top" bgcolor="#0099FF" class="style18"><span class="style28">Hobbies</span></td>
  163. <td width="16%" valign="top" class="style18"><div align="justify"><span class="style27"><font face = tahoma><?php echo $row[4];?></span></div></td>
  164. <td width="16%" valign="top" class="style18"><div align="justify"><span class="style27"><font face = tahoma><?php echo $row[5];?></span></div></td>
  165. <td width="15%" valign="top" class="style18"><div align="justify"><span class="style27"><font face = tahoma><?php echo $row[6];?></span></div></td>
  166. <td width="17%" valign="top" class="style18"><div align="justify"><span class="style27"><font face = tahoma><?php echo $row[7];?></span></div></td>
  167. </tr>
  168. <tr class="style27">
  169. <td height="23" valign="top" bgcolor="#0099FF" class="style18"><span class="style28"> Age </span></td>
  170. <td colspan="4" valign="top" class="style18"><div align="justify"><span class="style27"><font face = tahoma><?php echo $row[8];?></span></div></td>
  171. </tr>
  172.  
  173. <tr class="style27">
  174. <td height="23" valign="top" bgcolor="#0099FF" class="style18"><span class="style28"> Comments </span></td>
  175. <td colspan="4" valign="top" class="style18"><div align="justify"><span class="style27"><font face = tahoma><?php echo $row[10];?></span></div></td>
  176. </tr>
  177.  
  178. <tr class="style27">
  179. <td height="23" valign="top" bgcolor="#0099FF" class="style18"><span class="style28"> Date&Time </span></td>
  180. <td colspan="4" valign="top" class="style18"><div align="justify"><span class="style27"><font face = tahoma><?php echo $row[11];?></span></div></td>
  181. </tr>
  182.  
  183.  
  184. </table>
  185.  
  186. <?php
  187. }
  188. }
  189. else
  190. {
  191. echo "<font color = red size=5> No Records Founded!</font>";
  192. }
  193.  
  194. ?>
  195.  
  196. <center><?=$pagination?></center>
Last edited by peter_budo; Jul 24th, 2009 at 3:31 pm. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 16
Reputation: joe1987 is an unknown quantity at this point 
Solved Threads: 0
joe1987 joe1987 is offline Offline
Newbie Poster

Re: show results on same page

 
0
  #7
Jul 24th, 2009
put the table in a form and only put the method example:
<form name="Form1" method="POST"> and do not put any action and in the form put a submit button with name = "submit"
that is how when submit button is pressed then the page will submit on herself
Reply With Quote Quick reply to this message  
Reply

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


Thread Tools Search this Thread



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

©2003 - 2009 DaniWeb® LLC