| | |
show results on same page
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Apr 2008
Posts: 35
Reputation:
Solved Threads: 0
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?
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.
•
•
Join Date: Jun 2008
Posts: 40
Reputation:
Solved Threads: 2
ei.. if you want you're result on the same page use:
then you're php code for the result on the top of you're html..
hope this help
enim
php Syntax (Toggle Plain Text)
<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.
•
•
Join Date: Jun 2008
Posts: 40
Reputation:
Solved Threads: 2
like:
is that what you mean.. processing from other page
enim
php Syntax (Toggle Plain Text)
<?php //index.php <form action="otherPage.php" method="post"><form> ?> <?php //otherPage.php if($result) { // use meta tag here or header("Location: index.php"); } ?>
is that what you mean.. processing from other page
enim
•
•
Join Date: Apr 2008
Posts: 35
Reputation:
Solved Threads: 0
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
•
•
•
•
like:
php Syntax (Toggle Plain Text)
<?php //index.php <form action="otherPage.php" method="post"><form> ?> <?php //otherPage.php if($result) { // use meta tag here or header("Location: index.php"); } ?>
is that what you mean.. processing from other page
enim
•
•
Join Date: Sep 2008
Posts: 9
Reputation:
Solved Threads: 0
php Syntax (Toggle Plain Text)
$dbh=mysql_connect ("localhost", "user", "pwd") or die('Cannot connect to the database because: ' . mysql_error()); mysql_select_db ("dbname"); // display records page wise code starts: $adjacents = 3; $tbl_name="feedback"; $display = "SELECT COUNT(*) as num FROM $tbl_name"; $total_pages = mysql_fetch_array(mysql_query($display)); $total_pages = $total_pages[num]; /* Setup vars for query. */ $targetpage = "dispfeed.php"; //your file name (the name of this file) $limit = 5; //how many items to show per page $page = $_GET['page']; if($page) $start = ($page - 1) * $limit; //first item to display on this page else $start = 0; //if no page var is given, set start to 0 /* Get data. */ $display = "SELECT * FROM $tbl_name order by id desc LIMIT $start, $limit"; $rs = mysql_query($display); /* Setup page vars for display. */ if ($page == 0) $page = 1; //if no page var is given, default to 1. $prev = $page - 1; //previous page is page - 1 $next = $page + 1; //next page is page + 1 $lastpage = ceil($total_pages/$limit); //lastpage is = total pages / items per page, rounded up. $lpm1 = $lastpage - 1; //last page minus 1 /* Now we apply our rules and draw the pagination object. We're actually saving the code to a variable in case we want to draw it more than once. */ $pagination = ""; if($lastpage > 1) { $pagination .= "<div class=\"pagination\">"; //previous button if ($page > 1) // $pagination.= "<a href=\"$targetpage?page=$prev\">? previous</a>"; (if display by asc...) $pagination.= "<a href=\"$targetpage?page=$prev\">? NEXT</a>"; else // $pagination.= "<span class=\"disabled\">? previous</span>"; (if display by asc...) $pagination.= "<span class=\"disabled\">? NEXT</span>"; //pages if ($lastpage < 7 + ($adjacents * 2)) //not enough pages to bother breaking it up { for ($counter = 1; $counter <= $lastpage; $counter++) { if ($counter == $page) $pagination.= "<span class=\"current\">$counter</span>"; else $pagination.= "<a href=\"$targetpage?page=$counter\">$counter</a>"; } } elseif($lastpage > 5 + ($adjacents * 2)) //enough pages to hide some { //close to beginning; only hide later pages if($page < 1 + ($adjacents * 2)) { for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++) { if ($counter == $page) $pagination.= "<span class=\"current\">$counter</span>"; else $pagination.= "<a href=\"$targetpage?page=$counter\">$counter</a>"; } $pagination.= "..."; $pagination.= "<a href=\"$targetpage?page=$lpm1\">$lpm1</a>"; $pagination.= "<a href=\"$targetpage?page=$lastpage\">$lastpage</a>"; } //in middle; hide some front and some back elseif($lastpage - ($adjacents * 2) > $page && $page > ($adjacents * 2)) { $pagination.= "<a href=\"$targetpage?page=1\">1</a>"; $pagination.= "<a href=\"$targetpage?page=2\">2</a>"; $pagination.= "..."; for ($counter = $page - $adjacents; $counter <= $page + $adjacents; $counter++) { if ($counter == $page) $pagination.= "<span class=\"current\">$counter</span>"; else $pagination.= "<a href=\"$targetpage?page=$counter\">$counter</a>"; } $pagination.= "..."; $pagination.= "<a href=\"$targetpage?page=$lpm1\">$lpm1</a>"; $pagination.= "<a href=\"$targetpage?page=$lastpage\">$lastpage</a>"; } //close to end; only hide early pages else { $pagination.= "<a href=\"$targetpage?page=1\">1</a>"; $pagination.= "<a href=\"$targetpage?page=2\">2</a>"; $pagination.= "..."; for ($counter = $lastpage - (2 + ($adjacents * 2)); $counter <= $lastpage; $counter++) { if ($counter == $page) $pagination.= "<span class=\"current\">$counter</span>"; else $pagination.= "<a href=\"$targetpage?page=$counter\">$counter</a>"; } } } //next button if ($page < $counter - 1) // $pagination.= "<a href=\"$targetpage?page=$next\">next ?</a>"; (if display by asc...) $pagination.= "<a href=\"$targetpage?page=$next\">PREV ?</a>"; else // $pagination.= "<span class=\"disabled\">next ?</span>"; (if display by asc...) $pagination.= "<span class=\"disabled\">PREV ?</span>"; $pagination.= "</div>\n"; } // display records page wise code ends: if (mysql_num_rows($rs)>0) { while($row=mysql_fetch_array($rs)) { ?> </p> </p> <table width = "62%" height="164" border="1" align="center" cellpadding="1" cellspacing="1"> <tr> <td width="10%" height="23" valign="top" bgcolor="#0099FF" class="style27"><span class="style22"> Id. </span></td> <td colspan="4" valign="top" class="style27"><div align="justify"><span class="style27"><font face = tahoma><?php echo $row[0];?></span></div></td> <td width="26%" rowspan="9" align="center" valign="middle"> <!-- <a href = "<?php echo $row[9];?>"> --> <img src = "<?php echo $row[9];?>" width="125" height="125" border=0 /> </a> </td> </tr> <tr class="style27"> <td height="23" valign="top" bgcolor="#0099FF" class="style18"><span class="style28"> Name </span></td> <td colspan="4" valign="top" class="style18"><div align="justify"><span class="style27"><font face = tahoma><?php echo $row[1];?></span></div></td> </tr> <tr class="style27"> <td height="23" valign="top" bgcolor="#0099FF" class="style18"><span class="style28"> Email </span></td> <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> </tr> <tr class="style27"><td height="23" valign="top" bgcolor="#0099FF" class="style18"><span class="style28">Gender </span></td> <td colspan="4" valign="top" class="style18"><div align="justify"><span class="style27"><font face = tahoma><?php echo $row[3];?></span></div></td> <tr class="style27"> <td height="23" valign="top" bgcolor="#0099FF" class="style18"><span class="style28">Hobbies</span></td> <td width="16%" valign="top" class="style18"><div align="justify"><span class="style27"><font face = tahoma><?php echo $row[4];?></span></div></td> <td width="16%" valign="top" class="style18"><div align="justify"><span class="style27"><font face = tahoma><?php echo $row[5];?></span></div></td> <td width="15%" valign="top" class="style18"><div align="justify"><span class="style27"><font face = tahoma><?php echo $row[6];?></span></div></td> <td width="17%" valign="top" class="style18"><div align="justify"><span class="style27"><font face = tahoma><?php echo $row[7];?></span></div></td> </tr> <tr class="style27"> <td height="23" valign="top" bgcolor="#0099FF" class="style18"><span class="style28"> Age </span></td> <td colspan="4" valign="top" class="style18"><div align="justify"><span class="style27"><font face = tahoma><?php echo $row[8];?></span></div></td> </tr> <tr class="style27"> <td height="23" valign="top" bgcolor="#0099FF" class="style18"><span class="style28"> Comments </span></td> <td colspan="4" valign="top" class="style18"><div align="justify"><span class="style27"><font face = tahoma><?php echo $row[10];?></span></div></td> </tr> <tr class="style27"> <td height="23" valign="top" bgcolor="#0099FF" class="style18"><span class="style28"> Date&Time </span></td> <td colspan="4" valign="top" class="style18"><div align="justify"><span class="style27"><font face = tahoma><?php echo $row[11];?></span></div></td> </tr> </table> <?php } } else { echo "<font color = red size=5> No Records Founded!</font>"; } ?> <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.
![]() |
Similar Threads
- redirect and show results from txtbox to txtbox (VB.NET)
- Send/receieve XML through HTTP (ASP.NET)
- Cross page posting confusion (ASP.NET)
- php results from form - stuck (PHP)
- search and results question. (PHP)
- IE 6 Links & Search Results being Hijacked [HijackThisLog Included] (Viruses, Spyware and other Nasties)
- Pagination - not displaying results properly, please help! (PHP)
- Page hangs or displays connection pooling max size error (ASP.NET)
- Showing results of a form in new window (HTML and CSS)
Other Threads in the PHP Forum
- Previous Thread: PHP MySQL Code Works But Still Fills Error Logs with one error
- Next Thread: beginer's javascript..
| Thread Tools | Search this Thread |
# 5.2.10 access alexa apache api array beginner binary broken cakephp checkbox class clean clients cms code cron curl database date directory display dissertation dynamic echo echo$_get[x]changingitintovariable... email encode error fairness file files folder form forms function functions google href htaccess html image images include indentedsubcategory insert ip javascript joomla legislation limit link local login mail memberships menu mlm multiple multipletables mysql mysqlquery newsletters oop open paypal pdf persist php problem provider query radio random recursion remote rss script search server sessions sms sockets source space spam sql syntax system table tutorial update upload url validator variable video web youtube





