okay this sounds more like a multi tier query then just a one step job.
This sounds like it would be an ideal AJAX style page. where it walks thru the process 1 step at a time, where after a user selects an option it goes and grabs the information for the next field
some psuedo code of how i would do it is
Code:
<form name="info" action="_something_">
<label for="getWhat">
getWhat: // Field Name so user doesnt just have the dropdown
<select name="fromWhat" onchange="getInfo(getWhat, fromWhat, formName,tableName); return false">
<option value="false" selected="selected">--Choose Value--</option>
<option value="{NAME}">{NAME}</option>
<option value="{NAME}">{NAME}</option>
<option value="{NAME}">{NAME}</option>
</select>
</label>
<label for="{getWhat}">
getWhat: // Field Name so user doesnt just have the dropdown
{POPULATED FROM QUERY REQUEST}
</label>
</form>
that for the html portion then your AJAX function would be.
Code:
<script type="javascript">
function getInfo(getWhat, fromWhat,formName,tableName)
{
/* Checks if AJAX is possible and the default value is not the one selected */
if(ajax && document.formName.fromWhat.value != false)
{
// get info for next category
var results = builtQuery("SELECT fields FROM "+tableName+" WHERE "+getWhat+" = '"+fromWhat+"'");
// handle the info & parse back to the page
parseResults(results,getWhat, formName);
}
else
{
// some error handler
}
}
</script>
Edit:
Code:
function parseResponse(results, getWhat, formName)
{
// print results
dom create element(select, formName, getWhat becomes the fromWhat (select name="fromWhat") onselect="getInfo(...)");
for(var i = 0; i<results.length; i++)
dom create elements(option, results[i] - name & value);
}
the above is a very crude psuedo code example of how you could parse the additional categories
Bookmarks