Hi all,
i tried this code but its giving error
fatal error: Call to undefined function equals() in D:\xampp\htdocs\demo\contractor_new.php on line 152

<?php 	
	include 'database.php';

	if(category.equals("sercategory"))
	{
$result = mysql_query("SELECT * FROM  service_category ");

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

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

?>

There is no function called equals. Have you written a function called equals ?
Btw, == is the comparison operator. if($value1 == $value2)

Hi i have written like is the sytax is correct......actually what i wanted to do here is, based on the category it has to dispaly the list of values from db. on the same page, but i am not getting pls help me out..........

<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>
-->

<?php
/*
	include 'database.php';

	if(category==("sercategory"))
	{
$result = mysql_query("SELECT * FROM  service_category ");

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

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

if(category==("servicetype"))

should be,

if($_POST['category'] == "servicetype") {
//do this
}

Hi i wrote the code like this, the o/p for this code is

vehicle Inspection
batteryservice
oil canhge
smog check
brakes
minor engine repair
four wheel alignment


error

it wont select the other table contents......if i write if condition for all of the three select option it will just display error, 3 times for 3 select option. so i wrote like this it will display only service category contents and rest of the thing error....so what to do......

<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';
}

mysql_close();

?>

</body>
</html>

What are you exactly trying to do ? It would be really helpful if you use code tags to wrap your code.

I think you have to restrict the select condition by using where clause based on your service_category..


try this:

<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 where category_name='".$_POST['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';
}

mysql_close();

?>

</body>
</html>

Let me know where u have specified these service category,service type,services...
These are fro different tables...
Tel me i will help you..

yes service_category, service_type, services are the different tables

Hi,

my problem is from the 3 select option if user chooses one among them, it should display the contents of that particular table on the same page , their itself, and by default will set it to service_category...

Hi i tried but its giving error
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in D:\xampp\htdocs\newdemo\Testing2.php on line 26
error

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.