Hello everybody as first!
I'd like to post a variable from an html form to a php file to process a DB query and supposing the result of html form is stored in a variable $choice I'm not able to pass it to the php file to the SELECT statement.
To be more detailed here is the html form:
<head>
<FORM ACTION="find1.php" METHOD="post">
Eneter keyword:<BR>
choice<input type="text" title="choice" name="$choice">
<input type="submit" label="avanti">
</FORM>
</body>
..........................
and here is the php file:
..........................
?php
function HTML_Head() {
echo "";
echo "<body>";
}
function HTML_Foot() {
echo "</body>";
echo "";
}
function find_record() {
/*
connection to ODBC source */
$cnx = odbc_connect( 'annunci' , 'root', '' );
if (!$cnx) {
echo "impossibile connettersi al DataBase";
}
$result= "SELECT * FROM automoto Where nome LIKE '%$choice%";
$cur= odbc_exec($cnx, $result);
if (!$cur) {
echo "Impossibile connettersi al DataBase";
}
echo "<table border=1><tr><th>data</th><th>annuncio</th>".
"<th>prezzo</th><th>nome</th><th>numero</th></tr>\n";
$nbrow=0;
while( odbc_fetch_row( $cur ) ) {
$nbrow++;
$data= odbc_result( $cur, 1 ); // get the field "data"
$annuncio= odbc_result( $cur, 2 ); // get the field "FirstName"
$prezzo= odbc_result( $cur, 3 ); // get the field "LastName"
$nome= odbc_result( $cur, 4 ); // get the field "PhoneNumber"
$numero= odbc_result( $cur, 5 ); // get the field "PhoneNumber"
echo "<tr><td>$data</td><td>$annuncio</td>".
"<td>$prezzo</td><td>$nome</td><td>$numero</td></tr>\n";
}
echo "<tr><td colspan=2>$nbrow entries </td></tr></table>";
odbc_close( $cnx);
}
HTML_Head();
find_record($choice);
HTML_Foot();
?>
Where I'm wrong?
Many thanks for a kind reply
Regs.
Drymax
I'd like to post a variable from an html form to a php file to process a DB query and supposing the result of html form is stored in a variable $choice I'm not able to pass it to the php file to the SELECT statement.
To be more detailed here is the html form:
<head>
<FORM ACTION="find1.php" METHOD="post">
Eneter keyword:<BR>
choice<input type="text" title="choice" name="$choice">
<input type="submit" label="avanti">
</FORM>
</body>
..........................
and here is the php file:
..........................
?php
function HTML_Head() {
echo "";
echo "<body>";
}
function HTML_Foot() {
echo "</body>";
echo "";
}
function find_record() {
/*
connection to ODBC source */
$cnx = odbc_connect( 'annunci' , 'root', '' );
if (!$cnx) {
echo "impossibile connettersi al DataBase";
}
$result= "SELECT * FROM automoto Where nome LIKE '%$choice%";
$cur= odbc_exec($cnx, $result);
if (!$cur) {
echo "Impossibile connettersi al DataBase";
}
echo "<table border=1><tr><th>data</th><th>annuncio</th>".
"<th>prezzo</th><th>nome</th><th>numero</th></tr>\n";
$nbrow=0;
while( odbc_fetch_row( $cur ) ) {
$nbrow++;
$data= odbc_result( $cur, 1 ); // get the field "data"
$annuncio= odbc_result( $cur, 2 ); // get the field "FirstName"
$prezzo= odbc_result( $cur, 3 ); // get the field "LastName"
$nome= odbc_result( $cur, 4 ); // get the field "PhoneNumber"
$numero= odbc_result( $cur, 5 ); // get the field "PhoneNumber"
echo "<tr><td>$data</td><td>$annuncio</td>".
"<td>$prezzo</td><td>$nome</td><td>$numero</td></tr>\n";
}
echo "<tr><td colspan=2>$nbrow entries </td></tr></table>";
odbc_close( $cnx);
}
HTML_Head();
find_record($choice);
HTML_Foot();
?>
Where I'm wrong?
Many thanks for a kind reply
Regs.
Drymax