josephbupe
Registered User.
- Local time
 - Today, 11:49
 
- Joined
 - Jan 31, 2008
 
- Messages
 - 247
 
Hi,
I am beginning to learn PHP and mySQL starting on a simple movies database.
Data was loading okay from mySQL database in one of my PHP pages (select.php) with a SELECT statement until i included a few codes to query data through a form. What is happening now is that when I open this page, data does not appear immediately until I run a query through a form then it will appear below the same form in a data-grid layout.
However, I need help to fetch and display all the data in mySQL database when the page is opened first, and if possible re-query the data-grid when the search form is cleared.
Here is my code:
	
	
	
		
I will appreciate.
Joseph
 I am beginning to learn PHP and mySQL starting on a simple movies database.
Data was loading okay from mySQL database in one of my PHP pages (select.php) with a SELECT statement until i included a few codes to query data through a form. What is happening now is that when I open this page, data does not appear immediately until I run a query through a form then it will appear below the same form in a data-grid layout.
However, I need help to fetch and display all the data in mySQL database when the page is opened first, and if possible re-query the data-grid when the search form is cleared.
Here is my code:
		Code:
	
	
	<html>
<head>
<title>SELECT data in mySQL database</title>
</head>
<body>
<form name="frmSearch" method="get" action="<?=$_SERVER['SCRIPT_NAME'];?>">
  <table width="599" border="1">
    <tr>
      <th>Keyword
      <input name="txtKeyword" type="text" id="txtKeyword" value="<?=$_GET["txtKeyword"];?>">
      <input type="submit" value="Search"></th>
    </tr>
  </table>
</form>
<?
if($_GET["txtKeyword"] != "")
    {
    $objConnect = mysql_connect("localhost","joseph","encrypted") or die(mysql_error());
    $objDB = mysql_select_db("movies");
    // Search By Title or Year or Country
    $strSQL  = "SELECT * FROM movies WHERE (mtitle LIKE '%".$_GET["txtKeyword"]."%'  or mcountry LIKE '%".$_GET["txtKeyword"]."%')";
    $objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
    $Num_Rows = mysql_num_rows($objQuery);
...etc
	I will appreciate.
Joseph