RE: [PHP-DB] Result is not empty
| From: | Kevin Schaaps | Date: | Fri, 23 Nov 2001 13:42:49 +0000 |
| Subject: | RE: [PHP-DB] Result is not empty | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-14555@lists.php.net to get a copy of this message | ||
I do, however, want to notice that your tip worked IB :)
THanks again,
Kevin
-----Oorspronkelijk bericht-----
Van: Indioblanco [mailto:indioblanco@centralcoasthealing.net]
Verzonden: vrijdag 23 november 2001 6:30
Aan: Paul DuBois
CC: Kevin Schaaps; php-db@lists.php.net
Onderwerp: Re: [PHP-DB] Result is not empty
yes, of course you're right-- gotta stop working so late... the use of
the while statement where it wasn't needed threw me off, I guess.
Paul DuBois wrote:
>> Take out the while statement--
>> i.e. simply use:
>>
>> $row = mysql_fetch_array($result);
>>
>> the way you have things constructed now, the while statement
>> evaluates true on the first iteration and $row equals the result row
>> from the query. Because the while returned true, it is evaluated a
>> second time, returns false, and $row = NULL.
>>
>> -ib
>
>
> Why would that matter? He still sets the column variables on the first
> iteration? Yes, he needs no while loop, but the variables that are
> set inside the loop should remain set after the loop terminates.
>
>
>>
>> Kevin Schaaps wrote:
>>
>>> Greetings once again,
>>>
>>> Today I hope to have a challenge for you. :)
>>>
>>> I've created a query which returns 1 record. This is confirmed when
>>> testing
>>> it in MySQL itself.
>>> Now PHP sees that there is 1 record in the result, but is completely
>>> unwilling to show the information.
>>> The css responsible for that page does not change the color of the
>>> text so
>>> it should (like all the rest of the page is) be visible.
>>>
>>> Please help :)
>>>
>>> Yours,
>>>
>>> Kevin
>>>
>>> ____________________________________________
>>> $query = "SELECT concat(rank_tbl.abbreviation, ' ',
>>> character_tbl.name, ' ',
>>> character_tbl.surname) as CO,
>>> character_tbl.ircnick, character_tbl.email FROM
>>> character_tbl, rank_tbl, sim_tbl WHERE sim_tbl.co = character_tbl.id
>>> AND character_tbl.rank = rank_tbl.id AND sim_tbl.co =
>>> character_tbl.id AND character_tbl.rank = rank_tbl.id
>>> AND sim_tbl.id = $sim_id";
>>>
>>> $result = mysql_query($query);
>>> $num_rows = mysql_num_rows($result);
>>>
>>> if ($num_rows == 1)
>>> {
>>> while ($row = mysql_fetch_array($result));
>>> {
>>> $co = $row["CO"];
>>> $nick = $row["ircnick"];
>>> $email = $row["email"];
>>> };
>>> echo "
>>> <table>
>>> <tr>
>>> <td width=\"50\"></td>
>>> <td width=\"125\">CO:<td>
>>> <td><a
>>> href=\"$email\">$co</a></td>
>>> </tr>
>>> <tr>
>>> <td width=\"50\"></td>
>>> <td width=\"125\">IRC NICK<td>
>>> <td>$nick</td>
>>> </tr>
>>> <tr>
>>> <td width=\"50\"></td>
>>> <td width=\"125\"><td>
>>> <td></td>
>>> </tr>
>>> </table>";
>>> }
>>> else
>>> {
>>> echo "<br> <p class=\"medium\">No Commanding Officer
>>>
>>> assigned to
>>> $name</p>";
>>> };
>>
>
>
>
>
>