Here's the deal. I'm a PHP newbie. Well, I'm a coding newbie, period. I'm the technical support/network administrator in my company, but I've been given the task of creating a very basic search page for people to browse our products. What they want are drop down boxes for people to search by. Right now, we have 3: region, equipment type and company. All I've gotten to work so far is to search just by region, not the others.
I need to do two things:
I need to refine my code so that an "ALL" option is included for each drop down menu. Let's say you want everything in the south region. You select south, then all and all and it will give you all products that are just in the south.
I also need to be able to refine the search to include searching by 1 of any field or 2 fields. Meaning if you just want cable equipment type, it gives just that. Or if you want cable equipment type in the south region, it gives just that.
Here is the code I have and here is a test page on which it goes:
http://acscable.com/test/test.php
Code: Select all
<html>
<head>
<title>PHP Test</title>
</head>
<body>
<form action="<?php echo $_SERVER['PHP_SELF'];?>" method="GET">
<select name="region">
<option value="S">South</option>
<option value="e;N"e;>North</option>
<option value="e;C"e;>Central</option>
<option value="e;W"e;>West</option>
</select>
<?
$username="e;ABC"e;;
$password="e;123"e;;
$database="e;acscable_tmobile"e;;
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "e;Unable to select database"e;);
if ($_GETї"e;region"e;] <> "e;"e;)
{
$query="e;select * from tmobile where region = '"e; . $_GETї"e;region"e;] . "e;'"e;;
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
$i=0;
while ($i < $num)
{
$region=mysql_result($result,$i,"e;region"e;);
$manu_part_num=mysql_result($result,$i,"e;manu_part_num"e;);
$acs_part_num=mysql_result($result,$i,"e;acs_part_num"e;);
$equipment_type=mysql_result($result,$i,"e;equipment_type"e;);
$project=mysql_result($result,$i,"e;project"e;);
$description=mysql_result($result,$i,"e;description"e;);
echo "e;<br><br><b>Region:</b> $region <br><b>Manufacturer Part #:</b> $manu_part_num<br><b>ACS Part #:</b> $acs_part_num<br><b>Equipment Type</b>: $equipment_type<br><b>Project:</b> $project<br><b>Description:</b> $description<br><hr><br>"e;;
$i++;
}
}
?>
<select name="e;Equipment Type"e;>
<option value="e;SB"e;>Nokia SB Equipment</option>
<option value="e;HYBL"e;>HyperLink Blue</option>
<option value="e;C"e;>Cabling</option>
</select>
<?
if ($_GETї"e;equipment_type"e;] <> "e;"e;)
{
$query="e;select * from tmobile where equipment_type = '"e; . $_GETї"e;equipment_type"e;] . "e;'"e;;
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
$i=0;
while ($i < $num)
{
$region=mysql_result($result,$i,"e;region"e;);
$manu_part_num=mysql_result($result,$i,"e;manu_part_num"e;);
$acs_part_num=mysql_result($result,$i,"e;acs_part_num"e;);
$equipment_type=mysql_result($result,$i,"e;equipment_type"e;);
$project=mysql_result($result,$i,"e;project"e;);
$description=mysql_result($result,$i,"e;description"e;);
echo "e;<br><br><b>Region:</b> $region <br><b>Manufacturer Part #:</b> $manu_part_num<br><b>ACS Part #:</b> $acs_part_num<br><b>Equipment Type</b>: $equipment_type<br><b>Project:</b> $project<br><b>Description:</b> $description<br><hr><br>"e;;
$i++;
}
}
?>
<select name="e;Project"e;>
<option value="e;Ericson"e;>Ericson</option>
<option value="e;Nokia"e;>Nokia</option>
</select>
<INPUT TYPE=SUBMIT VALUE="e;Submit"e;>
<?
if ($_GETї"e;project"e;] <> "e;"e;)
{
$query="e;select * from tmobile where project = '"e; . $_GETї"e;project"e;] . "e;'"e;;
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
$i=0;
while ($i < $num)
{
$region=mysql_result($result,$i,"e;region"e;);
$manu_part_num=mysql_result($result,$i,"e;manu_part_num"e;);
$acs_part_num=mysql_result($result,$i,"e;acs_part_num"e;);
$equipment_type=mysql_result($res's the deal. I'm a PHP newbie. Well, I'm a coding newbie, period. I'm the technical support/network administrator in my company, but I've been given the task of creating a very basic search page for people to browse our products. What they want are drop down boxes for people to search by. Right now, we have 3: region, equipment type and company. All I've gotten to work so far is to search just by region, not the others.
I need to do two things:
I need to refine my code so that an "ALL" option is included for each drop down menu. Let's say you want everything in the south region. You select south, then all and all and it will give you all products that are just in the south.
I also need to be able to refine the search to include searching by 1 of any field or 2 fields. Meaning if you just want cable equipment type, it gives just that. Or if you want cable equipment type in the south region, it gives just that.
Here is the code I have and here is a test page on which it goes:
http://acscable.com/test/test.phpCode: Select all
<html>
<head>
<title>PHP Test</title>
</head>
<body>
<form action="<?php echo $_SERVER['PHP_SELF'];?>" method="GET">
<select name="region">
<option value="S">South</option>
<option value="N">North</option>
<option value="C">Central</option>
<option value="W">West</option>
</select>
<?
$username="ABC";
$password="123";
$database="acscable_tmobile";
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
if ($_GET["region"] <> "")
{
$query="select * from tmobile where region = '" . $_GET["region"] . "'";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
$i=0;
while ($i < $num)
{
$region=mysql_result($result,$i,"region");
$manu_part_num=mysql_result($result,$i,"manu_part_num");
$acs_part_num=mysql_result($result,$i,"acs_part_num");
$equipment_type=mysql_result($result,$i,"equipment_type");
$project=mysql_result($result,$i,"project");
$description=mysql_result($result,$i,"description");
echo "<br><br><b>Region:</b> $region <br><b>Manufacturer Part #:</b> $manu_part_num<br><b>ACS Part #:</b> $acs_part_num<br><b>Equipment Type</b>: $equipment_type<br><b>Project:</b> $project<br><b>Description:</b> $description<br><hr><br>";
$i++;
}
}
?>
<select name="Equipment Type">
<option value="SB">Nokia SB Equipment</option>
<option value="HYBL">HyperLink Blue</option>
<option value="C">Cabling</option>
</select>
<?
if ($_GET["equipment_type"] <> "")
{
$query="select * from tmobile where equipment_type = '" . $_GET["equipment_type"] . "'";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
$i=0;
while ($i < $num)
{
$region=mysql_result($result,$i,"region");
$manu_part_num=mysql_result($result,$i,"manu_part_num");
$acs_part_num=mysql_result($result,$i,"acs_part_num");
$equipment_type=mysql_result($result,$i,"equipment_type");
$project=mysql_result($result,$i,"project");
$description=mysql_result($result,$i,"description");
echo "<br><br><b>Region:</b> $region <br><b>Manufacturer Part #:</b> $manu_part_num<br><b>ACS Part #:</b> $acs_part_num<br><b>Equipment Type</b>: $equipment_type<br><b>Project:</b> $project<br><b>Description:</b> $description<br><hr><br>";
$i++;
}
}
?>
<select name="Project">
<option value="Ericson">Ericson</option>
<option value="Nokia">Nokia</option>
</select>
<INPUT TYPE=SUBMIT VALUE="Submit">
<?
if ($_GET["project"] <> "")
{
$query="select * from tmobile where project = '" . $_GET["project"] . "'";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
$i=0;
while ($i < $num)
{
$region=mysql_result($result,$i,"region");
$manu_part_num=mysql_result($result,$i,"manu_part_num");
$acs_part_num=mysql_result($result,$i,"acs_part_num");
$equipment_type=mysql_result($result,$i,"equipment_type");
$project=mysql_result($result,$i,"project");
$description=mysql_result($result,$i,"description");
echo "<br><br><b>Region:</b> $region <br><b>Manufacturer Part #:</b> $manu_part_num<br><b>ACS Part #:</b> $acs_part_num<br><b>Equipment Type</b>: $equipment_type<br><b>Project:</b> $project<br><b>Description:</b> $description<br><hr><br>";
$i++;
}
}
?>
</body>
</html>Thanks in Advance,
Chris
P.S - I created a user specifically available to the public with only select privileges, so I should be safe from exploits.
JCART | Please use
Code: Select all
tags when posting php code. Review [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/colorthe south region. You select south, then all and all and it will give you all products that are just in the south.
I also need to be able to refine the search to include searching by 1 of any field or 2 fields. Meaning if you just want cable equipment type, it gives just that. Or if you want cable equipment type in the south region, it gives just that.
Here is the code I have and here is a test page on which it goes:
http://acscable.com/test/test.phpCode: Select all
<html>
<head>
<title>PHP Test</title>
</head>
<body>
<form action="e;<?php echo $_SERVERї'PHP_SELF'];?>"e; method="e;GET"e;>
<select name="e;region"e;>
<option value="e;S"e;>South</option>
<option value="e;N"e;>North</option>
<option value="e;C"e;>Central</option>
<option value="e;W"e;>West</option>
</select>
<?
$username="e;ABC"e;;
$password="e;123"e;;
$database="e;acscable_tmobile"e;;
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "e;Unable to select database"e;);
if ($_GETї"e;region"e;] <> "e;"e;)
{
$query="e;select * from tmobile where region = '"e; . $_GETї"e;region"e;] . "e;'"e;;
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
$i=0;
while ($i < $num)
{
$region=mysql_result($result,$i,"e;region"e;);
$manu_part_num=mysql_result($result,$i,"e;manu_part_num"e;);
$acs_part_num=mysql_result($result,$i,"e;acs_part_num"e;);
$equipment_type=mysql_result($result,$i,"e;equipment_type"e;);
$project=mysql_result($result,$i,"e;project"e;);
$description=mysql_result($result,$i,"e;description"e;);
echo "e;<br><br><b>Region:</b> $region <br><b>Manufacturer Part #:</b> $manu_part_num<br><b>ACS Part #:</b> $acs_part_num<br><b>Equipment Type</b>: $equipment_type<br><b>Project:</b> $project<br><b>Description:</b> $description<br><hr><br>"e;;
$i++;
}
}
?>
<select name="e;Equipment Type"e;>
<option value="e;SB"e;>Nokia SB Equipment</option>
<option value="e;HYBL"e;>HyperLink Blue</option>
<option value="e;C"e;>Cabling</option>
</select>
<?
if ($_GETї"e;equipment_type"e;] <> "e;"e;)
{
$query="e;select * from tmobile where equipment_type = '"e; . $_GETї"e;equipment_type"e;] . "e;'"e;;
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
$i=0;
while ($i < $num)
{
$region=mysql_result($result,$i,"e;region"e;);
$manu_part_num=mysql_result($result,$i,"e;manu_part_num"e;);
$acs_part_num=mysql_result($result,$i,"e;acs_part_num"e;);
$equipment_type=mysql_result($result,$i,"e;equipment_type"e;);
$project=mysql_result($result,$i,"e;project"e;);
$description=mysql_result($result,$i,"e;description"e;);
echo "e;<br><br><b>Region:</b> $region <br><b>Manufacturer Part #:</b> $manu_part_num<br><b>ACS Part #:</b> $acs_part_num<br><b>Equipment Type</b>: $equipment_type<br><b>Project:</b> $project<br><b>Description:</b> $description<br><hr><br>"e;;
$i++;
}
}
?>
<select name="e;Project"e;>
<option value="e;Ericson"e;>Ericson</option>
<option value="e;Nokia"e;>Nokia</option>
</select>
<INPUT TYPE=SUBMIT VALUE="e;Submit"e;>
<?
if ($_GETї"e;project"e;] <> "e;"e;)
{
$query="e;select * from tmobile where project = '"e; . $_GETї"e;project"e;] . "e;'"e;;
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
$i=0;
while ($i < $num)
{
$region=mysql_result($result,$i,"e;region"e;);
$manu_part_num=mysql_result($result,$i,"e;manu_part_num"e;);
$acs_part_num=mysql_result($result,$i,"e;acs_part_num"e;);
$equipment_type=mysql_result($result,$i,"e;equipment_type"e;);
$project=mysql_result($result,$i,"e;project"e;);
$description=mysql_result($result,$i,"e;description"e;);
echo "e;<br><br><b>Region:</b> $region <br><b>Manufacturer Part #:base because I know how SQL works (how to write a statement to do what I want), I just don't know how to get it to work well with PHP.
Here's the deal. I'm a PHP newbie. Well, I'm a coding newbie, period. I'm the technical support/network administrator in my company, but I've been given the task of creating a very basic search page for people to browse our products. What they want are drop down boxes for people to search by. Right now, we have 3: region, equipment type and company. All I've gotten to work so far is to search just by region, not the others.
I need to do two things:
I need to refine my code so that an "ALL" option is included for each drop down menu. Let's say you want everything in the south region. You select south, then all and all and it will give you all products that are just in the south.
I also need to be able to refine the search to include searching by 1 of any field or 2 fields. Meaning if you just want cable equipment type, it gives just that. Or if you want cable equipment type in the south region, it gives just that.
Here is the code I have and here is a test page on which it goes:
http://acscable.com/test/test.phpCode: Select all
<html>
<head>
<title>PHP Test</title>
</head>
<body>
<form action="<?php echo $_SERVER['PHP_SELF'];?>" method="GET">
<select name="region">
<option value="S">South</option>
<option value="N">North</option>
<option value="C">Central</option>
<option value="W">West</option>
</select>
<?
$username="ABC";
$password="123";
$database="acscable_tmobile";
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
if ($_GET["region"] <> "")
{
$query="select * from tmobile where region = '" . $_GET["region"] . "'";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
$i=0;
while ($i < $num)
{
$region=mysql_result($result,$i,"region");
$manu_part_num=mysql_result($result,$i,"manu_part_num");
$acs_part_num=mysql_result($result,$i,"acs_part_num");
$equipment_type=mysql_result($result,$i,"equipment_type");
$project=mysql_result($result,$i,"project");
$description=mysql_result($result,$i,"description");
echo "<br><br><b>Region:</b> $region <br><b>Manufacturer Part #:</b> $manu_part_num<br><b>ACS Part #:</b> $acs_part_num<br><b>Equipment Type</b>: $equipment_type<br><b>Project:</b> $project<br><b>Description:</b> $description<br><hr><br>";
$i++;
}
}
?>
<select name="Equipment Type">
<option value="SB">Nokia SB Equipment</option>
<option value="HYBL">HyperLink Blue</option>
<option value="C">Cabling</option>
</select>
<?
if ($_GET["equipment_type"] <> "")
{
$query="select * from tmobile where equipment_type = '" . $_GET["equipment_type"] . "'";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
$i=0;
while ($i < $num)
{
$region=mysql_result($result,$i,"region");
$manu_part_num=mysql_result($result,$i,"manu_part_num");
$acs_part_num=mysql_result($result,$i,"acs_part_num");
$equipment_type=mysql_result($result,$i,"equipment_type");
$project=mysql_result($result,$i,"project");
$description=mysql_result($result,$i,"description");
echo "<br><br><b>Region:</b> $region <br><b>Manufacturer Part #:</b> $manu_part_num<br><b>ACS Part #:</b> $acs_part_num<br><b>Equipment Type</b>: $equipment_type<br><b>Project:</b> $project<br><b>Description:</b> $description<br><hr><br>";
$i++;
}
}
?>
<select name="Project">
<option value="Ericson">Ericson</option>
<option value="Nokia">Nokia</option>
</select>
<INPUT TYPE=SUBMIT VALUE="Submit">
<?
if ($_GET["project"] <> "")
{
$query="select * from tmobile where project = '" . $_GET["project"] . "'";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
$i=0;
while ($i < $num)
{
$region=mysql_result($result,$i,"region");
$manu_part_num=mysql_result($result,$i,"manu_part_num");
$acs_part_num=mysql_result($result,$i,"acs_part_num");
$equipment_type=mysql_result($result,$i,"equipment_type");
$project=mysql_result($result,$i,"project");
$description=mysql_result($result,$i,"description");
echo "<br><br><b>Region:</b> $region <br><b>Manufacturer Part #:</b> $manu_part_num<br><b>ACS Part #:</b> $acs_part_num<br><b>Equipment Type</b>: $equipment_type<br><b>Project:</b> $project<br><b>Description:</b> $description<br><hr><br>";
$i++;
}
}
?>
</body>
</html>Here's the deal. I'm a PHP newbie. Well, I'm a coding newbie, period. I'm the technical support/network administrator in my company, but I've been given the task of creating a very basic search page for people to browse our products. What they want are drop down boxes for people to search by. Right now, we have 3: region, equipment type and company. All I've gotten to work so far is to search just by region, not the others.
I need to do two things:
I need to refine my code so that an "ALL" option is included for each drop down menu. Let's say you want everything in the south region. You select south, then all and all and it will give you all products that are just in the south.
I also need to be able to refine the search to include searching by 1 of any field or 2 fields. Meaning if you just want cable equipment type, it gives just that. Or if you want cable equipment type in the south region, it gives just that.
Here is the code I have and here is a test page on which it goes:
http://acscable.com/test/test.php
Code: Select all
<html>
<head>
<title>PHP Test</title>
</head>
<body>
<form action="<?php echo $_SERVER['PHP_SELF'];?>" method="GET">
<select name="region">
<option value="S">South</option>
<option value="N">North</option>
<option value="C">Central</option>
<option value="W">West</option>
</select>
<?
$username="ABC";
$password="123";
$database="acscable_tmobile";
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
if ($_GET["region"] <> "")
{
$query="select * from tmobile where region = '" . $_GET["region"] . "'";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
$i=0;
while ($i < $num)
{
$region=mysql_result($result,$i,"region");
$manu_part_num=mysql_result($result,$i,"manu_part_num");
$acs_part_num=mysql_result($result,$i,"acs_part_num");
$equipment_type=mysql_result($result,$i,"equipment_type");
$project=mysql_result($result,$i,"project");
$description=mysql_result($result,$i,"description");
echo "<br><br><b>Region:</b> $region <br><b>Manufacturer Part #:</b> $manu_part_num<br><b>ACS Part #:</b> $acs_part_num<br><b>Equipment Type</b>: $equipment_type<br><b>Project:</b> $project<br><b>Description:</b> $description<br><hr><br>";
$i++;
}
}
?>
<select name="Equipment Type">
<option value="SB">Nokia SB Equipment</option>
<option value="HYBL">HyperLink Blue</option>
<option value="C">Cabling</option>
</select>
<?
if ($_GET["equipment_type"] <> "")
{
$query="select * from tmobile where equipment_type = '" . $_GET["equipment_type"] . "'";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
$i=0;
while ($i < $num)
{
$region=mysql_result($result,$i,"region");
$manu_part_num=mysql_result($result,$i,"manu_part_num");
$acs_part_num=mysql_result($result,$i,"acs_part_num");
$equipment_type=mysql_result($result,$i,"equipment_type");
$project=mysql_result($result,$i,"project");
$description=mysql_result($result,$i,"description");
echo "<br><br><b>Region:</b> $region <br><b>Manufacturer Part #:</b> $manu_part_num<br><b>ACS Part #:</b> $acs_part_num<br><b>Equipment Type</b>: $equipment_type<br><b>Project:</b> $project<br><b>Description:</b> $description<br><hr><br>";
$i++;
}
}
?>
<select name="Project">
<option value="Ericson">Ericson</option>
<option value="Nokia">Nokia</option>
</select>
<INPUT TYPE=SUBMIT VALUE="Submit">
<?
if ($_GET["project"] <> "")
{
$query="select * from tmobile where project = '" . $_GET["project"] . "'";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
$i=0;
while ($i < $num)
{
$region=mysql_result($result,$i,"region");
$manu_part_num=mysql_result($result,$i,"manu_part_num");
$acs_part_num=mysql_result($result,$i,"acs_part_num");
$equipment_type=mysql_result($result,$i,"equipment_type");
$project=mysql_result($result,$i,"project");
$description=mysql_result($result,$i,"description");
echo "<br><br><b>Region:</b> $region <br><b>Manufacturer Part #:</b> $manu_part_num<br><b>ACS Part #:</b> $acs_part_num<br><b>Equipment Type</b>: $equipment_type<br><b>Project:</b> $project<br><b>Description:</b> $description<br><hr><br>";
$i++;
}
}
?>
</body>
</html>Thanks in Advance,
Chris
P.S - I created a user specifically available to the public with only select privileges, so I should be safe from exploits.
JCART | Pleasetabase because I know how SQL works (how to write a statement to do what I want), I just don't know how to get it to work well with PHP.
Here's the deal. I'm a PHP newbie. Well, I'm a coding newbie, period. I'm the technical support/network administrator in my company, but I've been given the task of creating a very basic search page for people to browse our products. What they want are drop down boxes for people to search by. Right now, we have 3: region, equipment type and company. All I've gotten to work so far is to search just by region, not the others.
I need to do two things:
I need to refine my code so that an "ALL" option is included for each drop down menu. Let's say you want everything in the south region. You select south, then all and all and it will give you all products that are just in the south.
I also need to be able to refine the search to include searching by 1 of any field or 2 fields. Meaning if you just want cable equipment type, it gives just that. Or if you want cable equipment type in the south region, it gives just that.
Here is the code I have and here is a test page on which it goes:
http://acscable.com/test/test.php
Code: Select all
<html>
<head>
<title>PHP Test</title>
</head>
<body>
<form action="<?php echo $_SERVER['PHP_SELF'];?>" method="GET">
<select name="region">
<option value="S">South</option>
<option value="e;N"e;>North</option>
<option value="e;C"e;>Central</option>
<option value="e;W"e;>West</option>
</select>
<?
$username="e;ABC"e;;
$password="e;123"e;;
$database="e;acscable_tmobile"e;;
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "e;Unable to select database"e;);
if ($_GETї"e;region"e;] <> "e;"e;)
{
$query="e;select * from tmobile where region = '"e; . $_GETї"e;region"e;] . "e;'"e;;
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
$i=0;
while ($i < $num)
{
$region=mysql_result($result,$i,"e;region"e;);
$manu_part_num=mysql_result($result,$i,"e;manu_part_num"e;);
$acs_part_num=mysql_result($result,$i,"e;acs_part_num"e;);
$equipment_type=mysql_result($result,$i,"e;equipment_type"e;);
$project=mysql_result($result,$i,"e;project"e;);
$description=mysql_result($result,$i,"e;description"e;);
echo "e;<br><br><b>Region:</b> $region <br><b>Manufacturer Part #:</b> $manu_part_num<br><b>ACS Part #:</b> $acs_part_num<br><b>Equipment Type</b>: $equipment_type<br><b>Project:</b> $project<br><b>Description:</b> $description<br><hr><br>"e;;
$i++;
}
}
?>
<select name="e;Equipment Type"e;>
<option value="e;SB"e;>Nokia SB Equipment</option>
<option value="e;HYBL"e;>HyperLink Blue</option>
<option value="e;C"e;>Cabling</option>
</select>
<?
if ($_GETї"e;equipment_type"e;] <> "e;"e;)
{
$query="e;select * from tmobile where equipment_type = '"e; . $_GETї"e;equipment_type"e;] . "e;'"e;;
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
$i=0;
while ($i < $num)
{
$region=mysql_result($result,$i,"e;region"e;);
$manu_part_num=mysql_result($result,$i,"e;manu_part_num"e;);
$acs_part_num=mysql_result($result,$i,"e;acs_part_num"e;);
$equipment_type=mysql_result($result,$i,"e;equipment_type"e;);
$project=mysql_result($result,$i,"e;project"e;);
$description=mysql_result($result,$i,"e;description"e;);
echo "e;<br><br><b>Region:</b> $region <br><b>Manufacturer Part #:</b> $manu_part_num<br><b>ACS Part #:</b> $acs_part_num<br><b>Equipment Type</b>: $equipment_type<br><b>Project:</b> $project<br><b>Description:</b> $description<br><hr><br>"e;;
$i++;
}
}
?>
<select name="e;Project"e;>
<option value="e;Ericson"e;>Ericson</option>
<option value="e;Nokia"e;>Nokia</option>
</select>
<INPUT TYPE=SUBMIT VALUE="e;Submit"e;>
<?
if ($_GETї"e;project"e;] <> "e;"e;)
{
$query="e;select * from tmobile where project = '"e; . $_GETї"e;project"e;] . "e;'"e;;
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
$i=0;
while ($i < $num)
{
$region=mysql_result($result,$i,"e;region"e;);
$manu_part_num=mysql_result($result,$i,"e;manu_part_num"e;);
$acs_part_num=mysql_result($result,$i,"e;acs_part_num"e;);
$equipment_type=mysql_result($result,$i,"e;equipment_type"e;);
$project=mysql_result($result,$i,"e;project"e;);
$description=mysql_result($result,$i,"e;description"e;);
echo "e;<br><br><b>Region:</b> $region <br&aand company. All I've gotten to work so far is to search just by region, not the others.
I need to do two things:
I need to refine my code so that an "ALL" option is included for each drop down menu. Let's say you want everything in the south region. You select south, then all and all and it will give you all products that are just in the south.
I also need to be able to refine the search to include searching by 1 of any field or 2 fields. Meaning if you just want cable equipment type, it gives just that. Or if you want cable equipment type in the south region, it gives just that.
Here is the code I have and here is a test page on which it goes:
http://acscable.com/test/test.phpCode: Select all
<html>
<head>
<title>PHP Test</title>
</head>
<body>
<form action="e;<?php echo $_SERVERї'PHP_SELF'];?>"e; method="e;GET"e;>
<select name="e;region"e;>
<option value="e;S"e;>South</option>
<option value="e;N"e;>North</option>
<option value="e;C"e;>Central</option>
<option value="e;W"e;>West</option>
</select>
<?
$username="e;ABC"e;;
$password="e;123"e;;
$database="e;acscable_tmobile"e;;
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "e;Unable to select database"e;);
if ($_GETї"e;region"e;] <> "e;"e;)
{
$query="e;select * from tmobile where region = '"e; . $_GETї"e;region"e;] . "e;'"e;;
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
$i=0;
while ($i < $num)
{
$region=mysql_result($result,$i,"e;region"e;);
$manu_part_num=mysql_result($result,$i,"e;manu_part_num"e;);
$acs_part_num=mysql_result($result,$i,"e;acs_part_num"e;);
$equipment_type=mysql_result($result,$i,"e;equipment_type"e;);
$project=mysql_result($result,$i,"e;project"e;);
$description=mysql_result($result,$i,"e;description"e;);
echo "e;<br><br><b>Region:</b> $region <br><b>Manufacturer Part #:</b> $manu_part_num<br><b>ACS Part #:</b> $acs_part_num<br><b>Equipment Type</b>: $equipment_type<br><b>Project:</b> $project<br><b>Description:</b> $description<br><hr><br>"e;;
$i++;
}
}
?>
<select name="e;Equipment Type"e;>
<option value="e;SB"e;>Nokia SB Equipment</option>
<option value="e;HYBL"e;>HyperLink Blue</option>
<option value="e;C"e;>Cabling</option>
</select>
<?
if ($_GETї"e;equipment_type"e;] <> "e;"e;)
{
$query="e;select * from tmobile where equipment_type = '"e; . $_GETї"e;equipment_type"e;] . "e;'"e;;
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
$i=0;
while ($i < $num)
{
$region=mysql_result($result,$i,"e;region"e;);
$manu_part_num=mysql_result($result,$i,"e;manu_part_num"e;);
$acs_part_num=mysql_result($result,$i,"e;acs_part_num"e;);
$equipment_type=mysql_result($result,$i,"e;equipment_type"e;);
$project=mysql_result($result,$i,"e;project"e;);
$description=mysql_result($result,$i,"e;description"e;);
echo "e;<br><br><b>Region:</b> $region <br><b>Manufacturer Part #:</b> $manu_part_num<br><b>ACS Part #:</b> $acs_part_num<br><b>Equipment Type</b>: $equipment_type<br><b>Project:</b> $project<br><b>Description:</b> $description<br><hr><br>"e;;
$i++;
}
}
?>
<select name="e;Project"e;>
<option value="e;Ericson"e;>Ericson</option>
<option value="e;Nokia"e;>Nokia</option>
</select>
<INPUT TYPE=SUBMIT VALUE="e;Submit"e;>
<?
if ($_GETї"e;project"e;] <> "e;"e;)
{
$query="e;select * from tmobile where project = '"e; . $_GETї"e;project"e;] . "e;'"e;;
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
$i=0;
while ($i < $num)
{
$region=mysql_result($result,$i,"e;region"e;);
$manu_part_num=mysql_result($result,$i,"e;manu_part_num"e;);
$acs_part_num=mysql_result($result,$i,"e;acs_part_num"e;);
$equipment_type=mysql_result($result,$i,"e;equipment_type"e;);
$project=mysql_result($result,$i,"e;project"e;);
$description=mysql_result($result,$i,"e;description"e;);
echo "e;<br><br><b>Region:</b> $region <br><b>Manufacturer Part #:</b> $manu_part_num<br><b>ACS Part #:</b> $acs_part_num<br><b>Equipment Type</b>: $equipment_type<br>&an, equipment type and company. All I've gotten to work so far is to search just by region, not the others.
I need to do two things:
I need to refine my code so that an "ALL" option is included for each drop down menu. Let's say you want everything in the south region. You select south, then all and all and it will give you all products that are just in the south.
I also need to be able to refine the search to include searching by 1 of any field or 2 fields. Meaning if you just want cable equipment type, it gives just that. Or if you want cable equipment type in the south region, it gives just that.
Here is the code I have and here is a test page on which it goes:
http://acscable.com/test/test.phpCode: Select all
<html>
<head>
<title>PHP Test</title>
</head>
<body>
<form action="<?php echo $_SERVER['PHP_SELF'];?>" method="GET">
<select name="region">
<option value="S">South</option>
<option value="N">North</option>
<option value="C">Central</option>
<option value="W">West</option>
</select>
<?
$username="ABC";
$password="123";
$database="acscable_tmobile";
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
if ($_GET["region"] <> "")
{
$query="select * from tmobile where region = '" . $_GET["region"] . "'";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
$i=0;
while ($i < $num)
{
$region=mysql_result($result,$i,"region");
$manu_part_num=mysql_result($result,$i,"manu_part_num");
$acs_part_num=mysql_result($result,$i,"acs_part_num");
$equipment_type=mysql_result($result,$i,"equipment_type");
$project=mysql_result($result,$i,"project");
$description=mysql_result($result,$i,"description");
echo "<br><br><b>Region:</b> $region <br><b>Manufacturer Part #:</b> $manu_part_num<br><b>ACS Part #:</b> $acs_part_num<br><b>Equipment Type</b>: $equipment_type<br><b>Project:</b> $project<br><b>Description:</b> $description<br><hr><br>";
$i++;
}
}
?>
<select name="Equipment Type">
<option value="SB">Nokia SB Equipment</option>
<option value="HYBL">HyperLink Blue</option>
<option value="C">Cabling</option>
</select>
<?
if ($_GET["equipment_type"] <> "")
{
$query="select * from tmobile where equipment_type = '" . $_GET["equipment_type"] . "'";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
$i=0;
while ($i < $num)
{
$region=mysql_result($result,$i,"region");
$manu_part_num=mysql_result($result,$i,"manu_part_num");
$acs_part_num=mysql_result($result,$i,"acs_part_num");
$equipment_type=mysql_result($result,$i,"equipment_type");
$project=mysql_result($result,$i,"project");
$description=mysql_result($result,$i,"description");
echo "<br><br><b>Region:</b> $region <br><b>Manufacturer Part #:</b> $manu_part_num<br><b>ACS Part #:</b> $acs_part_num<br><b>Equipment Type</b>: $equipment_type<br><b>Project:</b> $project<br><b>Description:</b> $description<br><hr><br>";
$i++;
}
}
?>
<select name="Project">
<option value="Ericson">Ericson</option>
<option value="Nokia">Nokia</option>
</select>
<INPUT TYPE=SUBMIT VALUE="Submit">
<?
if ($_GET["project"] <> "")
{
$query="select * from tmobile where project = '" . $_GET["project"] . "'";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
$i=0;
while ($i < $num)
{
$region=mysql_result($result,$i,"region");
$manu_part_num=mysql_result($result,$i,"manu_part_num");
$acs_part_num=mysql_result($result,$i,"acs_part_num");
$equipment_type=mysql_result($result,$i,"equipment_type");
$project=mysql_result($result,$i,"project");
$description=mysql_result($result,$i,"description");
echo "<br><br><b>Region:</b> $region <br><b>Manufacturer Part #:</b> $manu_part_num<br><b>ACS Part #:</b> $acs_part_num<br><b>Equipment Type</b>: $equipment_type<br><b>Project:</b> $project<br><b>Description:</b> $description<br><hr><br>";
$i++;
}
}
?>
</body>
</html>Thanks in Advance,
Chris
P.S - I created a user specifically available to the public with only select privileges, so I should be safe from exploits.
JCART | Please use
Code: Select all
tags when posting php code. Review [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]