I am trying to puzzle out just how to obtain this PHP statement

$wpdb->get_results("SELECT verb, display_name AS organization, inline_the FROM
userorganizations U, organizations O WHERE U.org_id = O.ID AND 
U.user_id=$author_id", OBJECT);

To goes something similar to the next:

John works best for Initech, is the owner of John's Tasty Pastry, and creates for that New You are able to Occasions

I'm able to do just about everything except determine a great way to place the bolded "and" up above: I'm not sure how you can iterate right through to right before the ultimate row, make a move special, then run the ultimate row.

Automatically, get_results() returns a numerically indexed object from the results. It's not hard to determine the number of results you've by setting that resist a flexible after which using count() to determine the number of results you've.


$results = $wpdb->get_results(..., OBJECT);

foreach($results as $result) {
    if($result == $results[count($results) - 1]) echo '<strong>and</strong>';
    ... The rest of your loop here ...