How to show the php result on the same page

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Ruchi choudhary
    New Member
    • Nov 2012
    • 22

    How to show the php result on the same page

    Actually I want the result of php on the same page.It is code that i used(naip1.html )
    Code:
    <?php
    if(isset($_POST['submit'])) 
    {
    $dbhost = "localhost";
    $dbuser = "root";
    $dbpass = "";
    $dbname = "purchase";
    	//Connect to MySQL Server
    mysql_connect($dbhost, $dbuser, $dbpass);
    	//Select Database
    mysql_select_db($dbname) or die(mysql_error());
    	// Retrieve data from Query String
    
    $Fileno = $_GET['Fileno'];
    
    
    $query = "SELECT * FROM naiptwo WHERE Fileno LIKE '%$Fileno%'";
    $qry_result = mysql_query($query) or die(mysql_error());
    
    print "<table width=200 border=1>\n"; 
    
    print"\t<tr><th>Sanctionamt</th><th>
    Availableamt</th><th>Dateoffirstrelease</th><th>
    Amtoffirstrelease</th><th>Dateofsecondrelease</th><th>Amtofsecondrelease</th><th>Netamt</th><th>Fileno</th><th>fil
    
    einitiation</th><th>nameofindenter</th><th>materialreceivedpurchasedandpaymentreleased
    </th><th>nameoffirm</th><th>completeaddressoffirm</th><th>head</th><th>subhead</th><th>sanctioneddate</th><th
    
    >sanctionedamt</th><th>progressivebal</th><th>sanctionedbal</th><th>billdate</th><th>billamt</th><th>billbal</th><
    
    th>percentage</th></tr>\n";
    
    while ($get_info = mysql_fetch_row($qry_result)){ 
    print "<tr>\n"; 
    foreach ($get_info as $field) 
    print "\t<td><font face=arial size=2/>$field</font></td>\n"; 
    print "</tr>\n"; 
    } 
    print "</table>\n"; 
    }
    ?> 
    
    <html>
    <body>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >
    <head>
    	<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
    	<title>genome analysis lab</title>
    <link rel="stylesheet" type="text/css" media="screen" href="dbpage.css" />
    </head>
    <body>
    
    <div id="container">
    	<div id="intro">
    		<div id="pageHeader">
    			<h1><span>Genome Analysis Lab</span></h1>
    			<h2><span>Purchase database</span></h2>
    		</div>
    <form method="GET" action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>">
    
    &nbsp;&nbsp;
    &nbsp;&nbsp;File no:<br/>
    &nbsp;&nbsp;
    &nbsp;&nbsp;<input type="varchar" name="Fileno" size="30"/><br/><br>
    
    &nbsp;&nbsp;
    &nbsp;&nbsp; <input type="submit" name="submit" value="Submit">
    </form>
    <div id="linkList">
    		<div id="linkList2">
    			<div id="lselect">
    				<ul>
    					<li><a href="date2.html">2008-09</a></li>
    					<li><a href="naipyr2.html">2009-10</a></li>
    					<li><a href="naipyr3.html">2010-11</a></li>
    					<li><a href="naipyr4.html">2011-12</a></li>
    					<li><a href="naipyr5.html">2012-13</a></li>
    				</ul>
    			</div>
    
    
    
    
    
    </body>
    </html>
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    You need to print out your results in the body of the document. Not at the very top.

    Comment

    • Ruchi choudhary
      New Member
      • Nov 2012
      • 22

      #3
      thanx for reply.I do this but it show error you do not have permission to access the server.
      Code:
      <?php
      if(isset($_POST['submit'])) 
      {
      $dbhost = "localhost";
      $dbuser = "root";
      $dbpass = "";
      $dbname = "purchase";
      	//Connect to MySQL Server
      mysql_connect($dbhost, $dbuser, $dbpass);
      	//Select Database
      mysql_select_db($dbname) or die(mysql_error());
      	// Retrieve data from Query String
      
      $Fileno = $_GET['Fileno'];
      
      
      $query = "SELECT * FROM naiptwo WHERE Fileno LIKE '%$Fileno%'";
      $qry_result = mysql_query($query) or die(mysql_error());
      
      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
      <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >
      <head>
      	<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
      	<title>genome analysis lab</title>
      <link rel="stylesheet" type="text/css" media="screen" href="dbpage.css" />
      </head>
      <body>
      
      <div id="container">
      	<div id="intro">
      		<div id="pageHeader">
      			<h1><span>Genome Analysis Lab</span></h1>
      			<h2><span>Purchase database</span></h2>
      		</div>
      <form method="GET" action="<?php echo $_SERVER['PHP_SELF']; ?>">
      
      &nbsp;&nbsp;
      &nbsp;&nbsp;File no:<br/>
      &nbsp;&nbsp;
      &nbsp;&nbsp;<input type="varchar" name="Fileno" size="30"/><br/><br>
      print "<table width=200 border=1>\n"; 
      
      print"\t<tr><th>Sanctionamt</th><th>
      Availableamt</th><th>Dateoffirstrelease</th><th>
      Amtoffirstrelease</th><th>Dateofsecondrelease</th><th>Amtofsecondrelease</th><th>Netamt</th><th>Fileno</th><th>fil
      
      einitiation</th><th>nameofindenter</th><th>materialreceivedpurchasedandpaymentreleased
      </th><th>nameoffirm</th><th>completeaddressoffirm</th><th>head</th><th>subhead</th><th>sanctioneddate</th><th
      
      >sanctionedamt</th><th>progressivebal</th><th>sanctionedbal</th><th>billdate</th><th>billamt</th><th>billbal</th><
      
      th>percentage</th></tr>\n";
      
      while ($get_info = mysql_fetch_row($qry_result)){ 
      print "<tr>\n"; 
      foreach ($get_info as $field) 
      print "\t<td><font face=arial size=2/>$field</font></td>\n"; 
      print "</tr>\n"; 
      } 
      print "</table>\n"; 
      }
      ?> 
      
      &nbsp;&nbsp;
      &nbsp;&nbsp; <input type="submit" name="submit" value="Submit">
      </form>
      <br>
      <div id="linkList">
      		<div id="linkList2">
      			<div id="lselect">
      				<ul>
      					<li><a href="date2.html">2008-09</a></li>
      					<li><a href="naipyr2.html">2009-10</a></li>
      					<li><a href="naipyr3.html">2010-11</a></li>
      					<li><a href="naipyr4.html">2011-12</a></li>
      					<li><a href="naipyr5.html">2012-13</a></li>
      				</ul>
      			</div>
      
      
      
      
      
      </body>
      </html>

      Comment

      • Rabbit
        Recognized Expert MVP
        • Jan 2007
        • 12517

        #4
        Then you need to check your server settings and make sure you have it set up correctly. If you need further help diagnosing the permission issue, you will have to create a new thread for it as we only allow one question per thread and that is a different issue than your original question.

        Comment

        Working...