Re: Result problem
| From: | Dan Shirah | Date: | Wed, 25 Apr 2007 21:33:41 +0000 |
| Subject: | Re: Result problem | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-253774@lists.php.net to get a copy of this message | ||
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 themodified 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:matchesAny ideas why my query only returns the very last record that'P'";the criteria specified?? $sql_record ="SELECT * FROM payment_request WHERE status_code =-- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107$result_record = mssql_query($sql_record) or die(mssql_error()); if(!empty($result_record)) { while ($row_record = mssql_fetch_array($result_record)) {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?$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.