Re: [jposwald] Question about searching
Hi,
What you need to do is to select 2 sets of records from the database instead of using the beta_lookupReferringRecords() function.
Your select statements would look something like this:
<?php
list($marcaRecords,$marcaMetaData)=getRecords(array(
'tableName'=>'marca',
));
list($modeloRecords,$modeloMetaData)=getRecords(array(
'tableName' => 'modelo',
'where' => "marca='".mysql_escape(@$_REQUEST['marca'])."'",
))
?>
This loads all of the records from "marca" into $marcaRecords. $modeloRecords will hold all of the records from modelo that have the same marca as the one selected (If none has been selected, it will be blank.).
All that's left after that is to display the select boxes. You could use something like this:
<form name="marca" action="?" method="post">
<select name="marca">
<?php foreach ($marcaRecords as $record): ?>
<option value="<?php echo $record['num'];?>"><?php echo $record['title'];?></option>
<?php endforeach ?>
</select>
<input type="submit" value="Go" />
</form>
<?php if($modeloRecords): ?>
<form name="modelo" action="?" method="post">
<select name="modelo">
<?php foreach($modeloRecords as $record): ?>
<option value="<?php echo $record['num'];?>"><?php echo $record['title'];?></option>
<?php endforeach ?>
</select>
</form>
<?php endif ?>
The code:
<?php if($modeloRecords): ?>
means it will only display the second select box it the first form has been submitted, and there are values in $modeloRecords. You'll have to change the names a bit to match what you have in the database.
Hope this helps.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/