Need help building a query form for my php......
Posted: Wed Dec 02, 2009 4:51 am
Hi I am a newbie in php programming and I am just wondering if anybody here can help me on this matter....
I am trying to create a php that has a form where user can search certain thing from a database, meaning when let say I type a certain word in textbox and the program will search the database that is connected to the program.....
This is as far as what I have done
<?
$dbc=odbc_connect("denggi","","");
if (!$dbc)
{exit("Connection Failed: ".$dbc);}
$query="SELECT * FROM msjp_sample";
$rs=odbc_exec($dbc,$query);
if(!$rs)
{exit("Error in SQL");}
echo '<h3>MS Access Powered Database</h3>';
while(odbc_fetch_row($rs))
{
$e_name=odbc_result($rs,"NAMA");
$bulan=odbc_result($rs,"BULAN");
$e_date=odbc_result($rs,"ONSET");
echo '<b>Nama:</b>'.$e_name.'<br>';
echo '<b>Bulan</b>'.$bulan.'<br /> <b>Date:</b>'.$e_date.'<br />
<hr/>';
}
odbc_close($dbc);
echo"</table>"
?>
Based on the code... I have already managed to connect the programming with the database...... I am currently need to know how can I make query with a textbox if I need to search for anything from a certain column within the table......
I am trying to create a php that has a form where user can search certain thing from a database, meaning when let say I type a certain word in textbox and the program will search the database that is connected to the program.....
This is as far as what I have done
<?
$dbc=odbc_connect("denggi","","");
if (!$dbc)
{exit("Connection Failed: ".$dbc);}
$query="SELECT * FROM msjp_sample";
$rs=odbc_exec($dbc,$query);
if(!$rs)
{exit("Error in SQL");}
echo '<h3>MS Access Powered Database</h3>';
while(odbc_fetch_row($rs))
{
$e_name=odbc_result($rs,"NAMA");
$bulan=odbc_result($rs,"BULAN");
$e_date=odbc_result($rs,"ONSET");
echo '<b>Nama:</b>'.$e_name.'<br>';
echo '<b>Bulan</b>'.$bulan.'<br /> <b>Date:</b>'.$e_date.'<br />
<hr/>';
}
odbc_close($dbc);
echo"</table>"
?>
Based on the code... I have already managed to connect the programming with the database...... I am currently need to know how can I make query with a textbox if I need to search for anything from a certain column within the table......