0

I'm making some dynamic drop down boxes for a site that get their contents from a database, i belive i have the correct code to do this

<?php
echo "Product Code";
$sql = "SELECT DISTINCT Product_Code FROM product_supplier";
$result = mysql_query($sql, $odbc) or die("could not run");



echo"<select name = Product_Code>";
echo"<option value = All >All</option>";

while($row=mysql_fetch_object($result))
{
echo "<option value = '".$row->Product_Code."'>$row->Product_Code</option>";

}

echo"</select>";
echo "</p>";
?>

Whenever i try to run it in the webpage it brings this error

Warning: mysql_query() expects parameter 2 to be resource, null given in F:\xampp\xampp\htdocs\G4U\G4U\purchase.php on line 30

Can anybody see whats wrong with it???

2
Contributors
4
Replies
6
Views
7 Years
Discussion Span
Last Post by Atomika3000
0

There's something wrong with the $odbc link identifier. Please show the section where you have defined that.

0

There's something wrong with the $odbc link identifier. Please show the section where you have defined that.

$odbc? wheres that go???

Here is the page code if it help?

<html>
<head>
<title>Gardens 4 U |  Purchase</title>
<link href="styles.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
#container #mainContent h1 {
	text-align: center;
}
#container #mainContent form table {
	text-align: right;
	font-size: 12px;
}
-->
</style>
</head>

<body class="thrColFixHdr">

<div id="container">
  <div id="header">
    <h1>&nbsp;</h1>
  </div>
  <div id="mainContent">
<h2>Purchase</h2>
<p>&nbsp;</p>
<p>
  <?php
echo "Product Code";
$sql = "SELECT DISTINCT Product_Code FROM product_supplier";
$result = mysql_query($sql, $odbc) or die("could not run");
echo"<select name = Product_Code>";
while($row=mysql_fetch_object($result))
{
echo "<option value = '".$row->Product_Code."'>$row->Product_Code</option>";

}

echo"</select>";
echo "</p>";
?>
<p>&nbsp;</p>
  </div>
  <div id="footer">
    <p>Privacy | Access | Contact</p>
  </div>
</div>
</body>
</html>
0

New problem though, i now need another list box (thingy) with the products supplier in, but i want it to show the suppliers related to that product only.

Any Ideas How?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.