I've been trying to find the best way to do this for a while now but cannot figure it out.
I have a simple dropdown which auto populates based on an SQL query. When you press "search" I need it to go to a page with the url extension ?id=x
where x is the id of the option they selected.
$locations = $wpdb->get_results( $wpdb->prepare(
"SELECT * FROM wp_places_index WHERE visible='Y' ORDER BY place_name ASC") );
?>
<form id="find-buses-form" method="post" action="places_index.php">
<select class="default-value" type="text" name="from">
<option>Please select...</option>
<?php
foreach($locations as $location)
{
echo "<option>".$location->place_name."</option>";
// maybe this? echo "<input type=\"hidden\" name=\"id\">".$location->id."</input>";
}
?>
</select>
<input type="submit" name="submit" value="Show me" />
</form>
I think I may need to make it go to an external page which uses $_POST to pull that hidden field but I'd rather do it on one page.
I've achieved this before out of wordpress using something like this:
while ($row = mysql_fetch_array($result))
{
$picture = $row['Image'];
if($picture == ""){
$picture= "thumbnails/no-image-small.png";
}
$product_ID = $row["ProductID"];
But wordpress does not like the mysql_fetch_array
:( Any advise?