Now I want to creat an easy form for customer such that
enter a product name and then display the product id.
Code: Select all
<?php
define ('HOSTNAME', 'localhost');
define ('USERNAME', 'root');
define ('PASSWORD', 'root_password');
define ('DATABASE_NAME', 'joomla_15');
function query_db($qstring) {
$db = mysql_connect(HOSTNAME, USERNAME, PASSWORD) or
die (mysql_error());
mysql_select_db(DATABASE_NAME);
$query = " SELECT * FROM product WHERE name IS "$qstring" ";
$result = mysql_query($query);
while ($row = mysql_fetch_array($result)){
print $row[0];
}
mysql_free_result($result);
mysql_close();
}
?>
<html>
<head>
<title>Building a Form</title>
</head>
<body>
<?php
$search = $_GET["search"];
$self = $_SERVER['PHP_SELF'];
if ($search !=NULL) {
print "The search string is: <strong>$search</strong>.";
query_db($search);
}
else {
print ('
<form action="'.$self.'" method="GET">
<label>Search:
<input type="text" name="search" id="search" />
</label>
<input type="submit" value="Search Now!" />
</form>
');
}
?>
</body>
</html>
After click "Search Now!" I got always the frontpage of joomla.
Can anyone give me some hints?
Thx!
Or is there another easy way to bulid such a form with any extension?
I'm newbie for joomla.
Thanks for your help!