Dynadot .com transfer sale, only $10.12 with coupon code DYNA12, available while supplies last, ends October 31, 2026.

Php - Checking ID number against another database table (loops) - little help please

SpaceshipSpaceship
SpaceshipSpaceship
SpaceshipSpaceship
Watch

thomase

Established Member
Impact
3
Basically, when the code below runs it'll output this...How come the bussID: XXXX loop only runs for the first one, and not for each of the userID: xxxx? If that makes sense? I need to check each userID against the bussIDs...and if they match it'll echo "woo" (well, in real life it'll do something better, but for testing that's fine!)

userID: 3193



bussID: 3223
bussID: 3226
bussID: 3243
bussID: 3193 woo
bussID: 3242
bussID: 3196
bussID: 3241
bussID: 3240
bussID: 3238
bussID: 3239
bussID: 3221
bussID: 3220
bussID: 3217
bussID: 3218
bussID: 3224
bussID: 3225
bussID: 3222
bussID: 3219



userID: 3221


userID: 3219

PHP:
//let's get all the user IDs from the users table
while($result = mysql_fetch_array($query)){
echo "<br/>userID: $result[id] ";

echo"<br/><br/><br/>"; //TRIAL FORMATTING ONLY - REMOVE LATER

//Get the bussIDs and do any of these IDs match any of the bussIDs in the other services table?
while($extraServicesResult = mysql_fetch_array($extraServices)){
echo "<br/>bussID: $extraServicesResult[bussid] ";

//if they do, let's output the data for that company
if($extraServicesResult[bussid] == $result[id]){

echo"woo";    // include('advanceincludes/bussinfo.php'); (correct output when all working)
}
}//end of while($extraServicesResult

echo"<br/><br/><br/>"; //TRIAL FORMATTING ONLY - REMOVE LATER
}
 
Last edited:
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
Not really understanding what you mean. What is your SQL command?
 
0
•••
You can probably do what you are asking using a join sql statement. I can't really give you more information than that, because you haven't posted the SQL.
 
0
•••
I can't see anything wrong with the code you posted. I suspect your query is only returning 1 result.
 
0
•••
Yes, we need to see the query because if you're LIMIT'ing the results or otherwise adding parameters WHERE, not all results are being checked perhaps. This being the case you would not return the results you want.

Also, "woo" may not wind up inline properly due to your formatting. It will be "<br /><br /><br />" lines below.

Finally,

Not sure what you mean here but trying adding quotes or var signifier:
PHP:
$extraServicesResult['bussid'] == $result['id']

-RageD
 
0
•••
DomainEasy: flexible LTO options. Close more domain deals with financing.

We're social

Escrow.com
Spaceship
Escrowly
CryptoExchange.com
Domain Recover

NamePros updates

Parking: find your domains by pasting a list
You can now paste a list of domain names into the search box at the top of the Parking menu. Put one name on each line. Your domain list...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back