You are here: Re: PHP MySQL Single Iteration for data manipulation « PHP Programming Language « IT news, forums, messages
Re: PHP MySQL Single Iteration for data manipulation

Posted by Gdell on 12/18/16 11:51

PK is {QuestionNumber INT}
"Jerry Stuckle" <jstucklex@attglobal.net> wrote in message
news:L6idnc-MdLNxATzZnZ2dnUVZ_rqdnZ2d@comcast.com...
> Garry wrote:
>> How do I cycle through a MySQL query result one row at a time so that I
>> can do some work on each individual row, instead of having the whole
>> query scroll by. I need to have the ability to post each row to a form
>> and then work on it, posting the results, then go on to the next row.
>>
>>
>> Thank You in Advance for your putting me on the right track.
>>
>>
>>
>
> Garry,
>
> You can't do it with a loop. You'll have to fetch a single row each time.
>
> You could do it something like:
>
> $last = 0;
> $result = mysql_query("SELECT * FROM myTable WHERE id > $last ORDER BY
> id LIMIT 1");
> if ($result) { // Ensure it worked
> if (mysql_num_rows() > 0) { // And returned data
> $data = mysql_fetch_array($result);
> // Process the row
> $last = $data['id'];
> }
> else {
> // End of data
> }
> }
> else {
> // Process the mysql error
> }
>
> Assuming id is a unique integer > 0 (or at least unique within other WHERE
> clause settings).
>
> --
> ==================
> Remove the "x" from my email address
> Jerry Stuckle
> JDS Computer Training Corp.
> jstucklex@attglobal.net
> ==================

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация