thomase
03-31-2009, 10:39 AM
Hi, I'm having a bit of trouble trying to get this to work. The aim is, if $_GET[service] is there it'll run something to only display the data where the id ($result[id]) is also in the other table ($whichtable). If the ID is there when it loops to find the ID it'll display the page which processes the info (include('advanceincludes/bussinfo.php');).
With this, it will currently loop through ONCE and find one correct result. I need it to, once it's found this correct result to loop through again until every result that had an ID in the other table also is displayed (eg, all 18 of them as specificed in $amountOfResults).
I accept there may be better ways of doing this. I have uploaded a picture of what it looks like when it runs (the company shown will be different, depending on which ID it picks to loop through on $result[id] first).
if($_GET[service]){
$arraytotalnew2 = 0;
$amountOfResults = 18; // this will be changed to something which actually counts it later
$streamhostquery = mysql_query("SELECT bussid FROM $whichtable WHERE $_GET[service]='y'") or die("Can't select from the sub catagory product table");
$arraytotal = 0;
//this was in the while to limit how many times it runs $arraytotalnew2 < $arraytotal &&
while($result = mysql_fetch_array($query)){
while($streamhostresult = mysql_fetch_array($streamhostquery)){
echo"before == if : $streamhostresult[bussid] | $result[id] | $arraytotal | $arraytotalnew2 <br/>";
if($streamhostresult[bussid] == $result[id] && $arraytotalnew2 != $amountOfResults){
include('advanceincludes/bussinfo.php');
$totalonpage = $totalonpage + 1;
$totalextraFeatures = $totalextraFeatures + 1;
echo"$streamhostresult[bussid] == $result[id] - if | $arraytotalnew2 <br/>";
$arraytotalnew2 = $arraytotalnew2 + 1;
}//if (id == id)
}//while (streamhostresult)
}//while (result[id])
}//first if (services?)
else{
while($result = mysql_fetch_array($query)){
include('advanceincludes/bussinfo.php');
$totalonpage = $totalonpage + 1;
$totalextraFeatures = $totalextraFeatures + 1;
}
}
With this, it will currently loop through ONCE and find one correct result. I need it to, once it's found this correct result to loop through again until every result that had an ID in the other table also is displayed (eg, all 18 of them as specificed in $amountOfResults).
I accept there may be better ways of doing this. I have uploaded a picture of what it looks like when it runs (the company shown will be different, depending on which ID it picks to loop through on $result[id] first).
if($_GET[service]){
$arraytotalnew2 = 0;
$amountOfResults = 18; // this will be changed to something which actually counts it later
$streamhostquery = mysql_query("SELECT bussid FROM $whichtable WHERE $_GET[service]='y'") or die("Can't select from the sub catagory product table");
$arraytotal = 0;
//this was in the while to limit how many times it runs $arraytotalnew2 < $arraytotal &&
while($result = mysql_fetch_array($query)){
while($streamhostresult = mysql_fetch_array($streamhostquery)){
echo"before == if : $streamhostresult[bussid] | $result[id] | $arraytotal | $arraytotalnew2 <br/>";
if($streamhostresult[bussid] == $result[id] && $arraytotalnew2 != $amountOfResults){
include('advanceincludes/bussinfo.php');
$totalonpage = $totalonpage + 1;
$totalextraFeatures = $totalextraFeatures + 1;
echo"$streamhostresult[bussid] == $result[id] - if | $arraytotalnew2 <br/>";
$arraytotalnew2 = $arraytotalnew2 + 1;
}//if (id == id)
}//while (streamhostresult)
}//while (result[id])
}//first if (services?)
else{
while($result = mysql_fetch_array($query)){
include('advanceincludes/bussinfo.php');
$totalonpage = $totalonpage + 1;
$totalextraFeatures = $totalextraFeatures + 1;
}
}
