Re: Result problem

From: Date: Wed, 25 Apr 2007 22:34:42 +0000
Subject: Re: Result problem
References: 1 2 3 4 5 6 7  Groups: php.general 
Request: Send a blank email to php-general+get-253799@lists.php.net to get a copy of this message
That would be correct --- it should be extract($sql); in that code. Like I said earlier (or was it another thread?) I'm going slightly retarded this afternoon. Another 30-60 minutes and I'm hitting happy hour for a beer, where the closest things to a computer screen in the place are the cash register, jukebox, and a Megatouch machine.... none of which I'll be near. On 4/25/07, Richard Lynch <ceo@l-i-e.com> wrote:
Almost for sure, he meant 'extract' where he put 'expand'... On Wed, April 25, 2007 4:42 pm, Daniel Brown wrote:
    It looks like it's a combination of what everyone's been
suggesting. Try this rewritten code: <?
    $sql ="SELECT * FROM payment_request WHERE status_code = 'P'";
    $result = mssql_query($sql) or die(mssql_error());
    while ($row = mssql_fetch_array($result)) {
        expand($row);
        $all[] = $id;
    }
    print_r($all);
?> print_r ($sql_record); On 4/25/07, Dan Shirah <mrsquash2@gmail.com> wrote:
No, I am trying to figure out why my query is only returning the last record that matches instead of all the records that match. On 4/25/07, Daniel Brown <parasane@gmail.com> wrote:
    Are you trying to just print this to the screen?  If so, refer
to
the modified snippet I sent you a bit ago. On 4/25/07, Dan Shirah < mrsquash2@gmail.com > wrote:
I'm sorry, perhaps I confused everyone by including the print_r. My table has 79 records all with a status_code of 'P' that this "should" be returning. But instead of all the results returning, all I am getting back is row 79. On 4/25/07, Richard Lynch < ceo@l-i-e.com> wrote:
On Wed, April 25, 2007 3:56 pm, Dan Shirah wrote:
Any ideas why my query only returns the very last record
that matches
the criteria specified?? $sql_record ="SELECT * FROM payment_request WHERE
status_code = 'P'";
$result_record = mssql_query($sql_record) or
die(mssql_error());
if(!empty($result_record)) { while ($row_record = mssql_fetch_array($result_record)) {
     $id_record = $row_record['id'];
} } print_r ($sql_record); The result of the print_r displays only the last record that
matches
the query criteria. I tried a foreach instead of a while with
no luck.
You do the 'print_r' *AFTER* you've run through all the
records.
Move that line *INSIDE* the loop, and it will print each one
as it
goes through. This will be more clear if you indent better, though that may
just be
email messing up, not your real code. Every time you type a '{', indent by one tab. Stay indented until you type a '}' The "flow" of the program is then seen by skimming with the
eyes
downward on the left side, and the 'print_r' being outside the
loop
will be more obvious, with practice. -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So?
-- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107
-- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107 -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107

« previous php.general (#253799) next »