thomase
09-14-2008, 10:36 AM
I'm having a little difficulty trying to work out how to do something.
This is the original code which works fine:
if($_GET[order] == highestrated){
$query = mysql_query("SELECT * FROM users WHERE auth='2' AND sex='$btype' ORDER BY avg DESC LIMIT $l1 , $l2") or die("hr olmadi");
echo"Currently ordered by Highest Rating to Lowest.";
}
Now people can do more 'advanced searches' and if they do one I'd like to be able to have something in that so if they've done an advance search it will only show certain IDs.
I have another table which has the options for the advance search. This successfully echos out all the correct results:
if(($_GET[service])){
$streamhostquery = mysql_query("SELECT bussid FROM streamhost WHERE $_GET[service]='y'") or die("dfdfdsf");
while ($streamhostresult = mysql_fetch_array($streamhostquery)){
echo "$streamhostresult[bussid], ";
}}
Basically, I want the list that the echo does, to work in my first bit of php, if the website's visitor selects to do a more advance search.
I tried something with a while statement...I did just make this up so I'm not surprised it didn't work:
if($_GET[order] == highestrated){
$query = mysql_query("SELECT * FROM users WHERE auth='2' AND sex='$btype' "
while ($streamhostresult = mysql_fetch_array($streamhostquery)){
echo "OR id='$streamhostresult[bussid]'";
}"
ORDER BY avg DESC LIMIT $l1 , $l2") or die("hr olmadi");
echo"Currently ordered by Highest Rating to Lowest.";
}
The mysql_query is still in the code, just not at this bit. Now I can't get this to work.
Basically, the problem is, just putting $streamhostresult[bussid] in an "id=''" would work if there was only one result, but as there will be more than that with if statements and things how can I put that into my mysql_query.
Sure this is really simple, I just can't find anything on it - I have tried looking at arrays. Cheers :)
This is the original code which works fine:
if($_GET[order] == highestrated){
$query = mysql_query("SELECT * FROM users WHERE auth='2' AND sex='$btype' ORDER BY avg DESC LIMIT $l1 , $l2") or die("hr olmadi");
echo"Currently ordered by Highest Rating to Lowest.";
}
Now people can do more 'advanced searches' and if they do one I'd like to be able to have something in that so if they've done an advance search it will only show certain IDs.
I have another table which has the options for the advance search. This successfully echos out all the correct results:
if(($_GET[service])){
$streamhostquery = mysql_query("SELECT bussid FROM streamhost WHERE $_GET[service]='y'") or die("dfdfdsf");
while ($streamhostresult = mysql_fetch_array($streamhostquery)){
echo "$streamhostresult[bussid], ";
}}
Basically, I want the list that the echo does, to work in my first bit of php, if the website's visitor selects to do a more advance search.
I tried something with a while statement...I did just make this up so I'm not surprised it didn't work:
if($_GET[order] == highestrated){
$query = mysql_query("SELECT * FROM users WHERE auth='2' AND sex='$btype' "
while ($streamhostresult = mysql_fetch_array($streamhostquery)){
echo "OR id='$streamhostresult[bussid]'";
}"
ORDER BY avg DESC LIMIT $l1 , $l2") or die("hr olmadi");
echo"Currently ordered by Highest Rating to Lowest.";
}
The mysql_query is still in the code, just not at this bit. Now I can't get this to work.
Basically, the problem is, just putting $streamhostresult[bussid] in an "id=''" would work if there was only one result, but as there will be more than that with if statements and things how can I put that into my mysql_query.
Sure this is really simple, I just can't find anything on it - I have tried looking at arrays. Cheers :)
