MySQL Forums
Forum List  »  Newbie

Re: POST_data from a form as value in a mysql WHERE clause
Posted by: Frederick Ahmed
Date: July 15, 2005 12:43PM

Nathan,

Many thanks for your response.

Here is what I am trying to do. This echoes the postcode and the price but does not connect to the server or carry out the SELECT... WHERE instruction.



<?php
// Defining $Post items
$postcode = $_POST('postcode');
$price=$_POST('price');
echo $postcode;
echo "price is £".$price.".<br/>";

// Connecting, selecting database
$link = mysql_connect('sever', 'user', 'pass')
or die('Could not connect: ' . mysql_error());
echo 'Connected successfully';
mysql_select_db('properties') or die('Could not select database');


// Performing SQL query
$query = 'SELECT * FROM tolet2 WHERE price >= $price';
$result = mysql_query($query) or die('Query failed: ' . mysql_error());

// Printing results in HTML
echo "<table>\n";
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
echo "\t<tr>\n";
foreach ($line as $col_value) {
echo "\t\t<td>$col_value</td>\n";
}
echo "\t</tr>\n";
}
echo "</table>\n";

// Free resultset
mysql_free_result($result);

// Closing connection
mysql_close($link);
?>

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.