1 (edited by 2013-12-06 08:00:25)

Topic: fetching successfully the data from MySql database with $_GET OR $_POST

hi to all...........i want to develop a mechanism like if i enter the data throug a form in one php script then the records relevent to that data should be fetched from the MySql database table and should  be displayed in the another php scripted webpage. the narrow code i m assuming is as below....
1) test.php file where the form is ......

          <html>
<body>
<form action = "testing.php" method = "get">
<input type = "text" name = "from" id = "from">
<input type="text" name="to" id="to">
<input type = "submit" name = "submit" value = "submit">
</form>
</body>
</html>

2) the testing.php file in which the fetched data should be displayed is as follows.....


<?php
mysql_connect("localhost", "root", "");
mysql_select_db("date");

function getTree()
{

$result = mysql_query("SELECT * FROM bus WHERE from_here = '".$_GET['from']."' AND to_here ='".$_GET['to']."'");
$row = mysql_fetch_assoc($result);
echo "<table>";
while($row = mysql_fetch_assoc($result))
    {
     echo "<tr><td>".$row['from_here']."</td><td>".$row['to_here']."</td></tr>";
     echo "</table">
        }
}
getTree();
?>
          am i correct in this or i need external things..........please reply as fast as possible.....thanks in advance to the repliers.