dragon2309
P.I Dragon
hey everyone, this is a special callout to people lik cromewell and mgoldb2 and basically anyone who knows PHP well. Below is my current page, you can see it at http://www.simplytrue.co.uk/stocklist/query3.php Obviously its not working jsut rught, lol.
There are several records for each of the selcetions but none get returned etc... its easier if you click the link and see for yourself. As said the code is below and i have no clue what to do with it, ive spen the last 2 hours fiddling and changing but nothign works properly
any help or tips woudl be really great indeed, thanks
dragon
There are several records for each of the selcetions but none get returned etc... its easier if you click the link and see for yourself. As said the code is below and i have no clue what to do with it, ive spen the last 2 hours fiddling and changing but nothign works properly
PHP:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>price Query</title>
</head>
<body>
</head>
<body>
<h1>price Query</h1>
<form id="price_select" action="<?php $PHP_SELF; ?>" method="post">
<p>
Select price:
<select name="price">
<option value="£1.99">£1.99</option>
<option value="£2.99">£2.99</option>
<option value="£3.99">£3.99</option>
</select>
<input type="submit" />
</p>
</form>
<?php
if( ! empty( $_POST["price"] ) )
{
echo '<table border="1">
<tr>
<th><font face="Tahoma">Item Number</font></th>
<th><font face="Tahoma">Description</font></th>
<th><font face="Tahoma">Price</font></th>
<th><font face="Tahoma">Image</font></th>
<th><font face="Tahoma">Information</font></th>
<th bgcolor="#FFECFF"> </th>
<th>Item Number</th>
<th>Description</th>
<th>Price</th>
<th>Image</th>
<th>Information</th>
</tr>
</div>
<tr>
<td bgcolor="#FFECFF"> </td>
<th bgcolor="#FFECFF"> </th>
<th bgcolor="#FFECFF"> </th>
<th bgcolor="#FFECFF"> </th>
<th bgcolor="#FFECFF"> </th>
<th bgcolor="#FFECFF"> </th>
<th bgcolor="#FFECFF"> </th>
<th bgcolor="#FFECFF"> </th>
<th bgcolor="#FFECFF"> </th>
<th bgcolor="#FFECFF"> </th>
<th bgcolor="#FFECFF"> </th>
</tr>';
require "dbinfo.php";
// Connect to MySQL DBMS
if (!($connection = @ mysql_connect(DB_HOSTNAME, DB_USERNAME, DB_PASSWORD)))
showerror();
// Use the cars database
if (!mysql_select_db(DB_DATABASENAME, $connection))
showerror();
// Create SQL statement
$price = $_POST["price"];
$query = "SELECT * FROM ad_brac WHERE Price='$price'";
// Execute SQL statement
if (!($result = @ mysql_query ($query, $connection)))
showerror();
// Display results
// starts counter at 0
$counter=0;
while ($row = @ mysql_fetch_array($result))
// checks if counter/2 has no remainder, as in 0 (first item), 2 (third item), and, if so, starts a row
if($counter % 2 == 0){
echo "<tr>";
}
echo "<td>{$row['StockCode']}</td>
<td>{$row['Description']}</td>
<td>{$row['Price']}</td>
<td><p><a href='{$row['IMGURL']}'><img src='{$row['IMG']}'></img></p></td>
<td><center><a href='{$row['URL']}'>$row[url]</a></center></td>";
echo "</table>";
// checks if counter+1/2 has no remainder, as in 1 (2nd item), 3 (fouth item), and, if so, ends a row
if(($counter+1) % 2 == 0){
echo "</tr>";
}
else
{ echo '<td bgcolor="#FFECFF"> </td>';}
// adds one to the counter
$counter++;
}
?>
</body>
</html>
dragon