Hi.....is this code right.........

<html>
<head><title>auto alto system</title></head>
<body>
<table>
<tr>
<td> category</td>
<td><select name="category">
                        <option value="sercategory">service category</option>
                        <option value="servicetype">service type</option>
						<option value="services">services</option>
                       	
	   </select></td>  
</tr>
</table>
<?php

	include 'database.php';

	  
	$result = mysql_query("SELECT * FROM  service_category ");

while($row = mysql_fetch_array($result))
{
echo $row['servicec'];
echo "<br />";
}
	
	
 if($_POST['category'] == "servicetype") 
{
$result = mysql_query("SELECT * FROM  service_type ");
while($row = mysql_fetch_array($result))
{
echo $row['servicet'];
echo "<br />";
echo 'error';
}
}
else
{
	echo 'error';
}
 if($_POST['category'] == "services") 
{
$result = mysql_query("SELECT * FROM  services  ");

while($row = mysql_fetch_array($result))
{
echo $row['servicess'];
echo "<br />";
}
}
else
{
	echo 'error';
}



mysql_close();

?>

</body>
</html>

Recommended Answers

All 2 Replies

The Code above is not in the correct meaning:
Means:
The php script will execute first...
So if($_POST == "services") ,this line is selected by user,
so u will get this error:
Notice: Undefined variable: result in E:\web\forumsnetwork\frontend\saneg.php on line 7

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in E:\web\forumsnetwork\frontend\saneg.php on line 7

Notice: Undefined index: category in E:\web\forumsnetwork\frontend\saneg.php on line 14
error
Notice: Undefined index: category in E:\web\forumsnetwork\frontend\saneg.php on line 28
error

So,first you have to decide what you are trying to do..
Tel me what is your task has to do..

Thanks.

Hi,
actually what i wanted to do ......is

There are 3 options to select . as soon as i select some option it has to display something based on the selected option. on the same page.

actually i got it the code i wrote was wrong ,

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.