Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi I have form for searching one of four types here is my syntax for select :
$query = "SELECT * FROM '$jobs' WHERE location ='$search'";
$jobs should show one of this:
<select name="jobs" class="box">
<option value="" class="box">Select...</option>
<option value="admin_jobs" class="box">Admin Jobs</option>
<option value="retail_jobs" class="box">Retail Jobs</option>
<option value="beauty_jobs" class="box">Beauty Jobs</option>
<option value="promotion_jobs" class="box">Promotion Jobs</option>
</select>So I can seperatly search one of this four tables
I have problem to put this together with my PHP script which look like this
<?
if ($search) // perform search only if a string was entered.
{
mysql_connect("localhost","root","") or die ("Problem connecting to Database");$query = "SELECT * FROM '$jobs' WHERE location ='$search'";
$result = mysql_db_query("prolinc", $query);
if ($result)
{
echo "Here are the results:
";
echo "<table width=90% align=center border=0><tr>
<td align=center bgcolor=#00FFFF>Position</td>
<td align=center bgcolor=#00FFFF>Location</td>
<td align=center bgcolor=#00FFFF>Salary</td>
<td align=center bgcolor=#00FFFF>Duration</td>
</tr>";while ($r = mysql_fetch_array($result)) { // Begin while
$salary = $r["salary"];
$location = $r["location"];
$position = $r["position"];
$duration = $r["duration"];
$sdesc = $r["sdesc"];
$requirements = $r["requirements"];
$company = $r["company"];
echo "
<tr> <td colspan=4 bgcolor=\"#333333\"></td></tr>
<tr>
<td>$position</td>
<td>$location</td>
<td>$salary</td>
<td>$duration</td></tr>
<tr> <td colspan=4 bgcolor=\"#ffffa0\">$sdesc</td></tr>
<tr> <td colspan=4 bgcolor=\"#333333\"></td></tr>";
} // end whileecho "</table>";
}else { echo "problems...."; }
}
else {
echo "Search string is empty.
Go back and type a string to search";
}?>
as you can see if I will replace $jobs using one of admin_jobs or other it will start search this one table - can you advice how can I doo it so I can choose one ;/

there was easy way just I have this:
$query = "SELECT * FROM '$jobs' WHERE location ='$search'";
and I change it to :
$jobs=$_POST['jobs'];
$query = "SELECT * FROM $jobs WHERE location ='$search'";and it works fine :)

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |