Re: doing SELECTS and keeping the array intact with php
julian haffegee schrieb: Hi all, this has been bugging me for some time now. I want to do a mysql select then using php while ($a_row = mysql_fetch_array($result)) { do something to get a small portion of the data } hi julian, how about using this snip $result = mysql_query($sql)or die("fehler:".mysql_error()); $num = mysql_num_rows($result); $erg = array(); for ($i = 0; $i < $num; $i++) { $erg[$i] = array(); $erg[$i] = mysql_fetch_object($result); } i work with it, and its just fine. put it in a function or a class and you wont have to bother about processing the results anymore. have fun. greetz seba --- http://www.helft-sebastian.de http://www.schaudirmaldiean.de http://www.random-link.com -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: doing SELECTS and keeping the array intact with php
mysql_field_seek( resultset, 0 ); PB - julian haffegee wrote: Hi all, this has been bugging me for some time now. I want to do a mysql select then using php while ($a_row = mysql_fetch_array($result)) { do something to get a small portion of the data } and that works fine. Then later I need to access $result as a complete array again. Is there a way I can keep $result array intact and still take a couple values out beforehand. I can get it to work, by doing the select twice, but thats less than ideal. Thanks enormously if you can help Jules -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
RE: doing SELECTS and keeping the array intact with php
http://us2.php.net/manual/en/function.mysql-data-seek.php This lets you set the internal row pointer of the mysql result. In your case you would want mysql_data_seek($result,0). --- Tom Crimmins Interface Specialist Pottawattamie County, Iowa -Original Message- From: julian haffegee Sent: Monday, January 03, 2005 12:31 PM To: MySQL General List Subject: doing SELECTS and keeping the array intact with php Hi all, this has been bugging me for some time now. I want to do a mysql select then using php while ($a_row = mysql_fetch_array($result)) { do something to get a small portion of the data } and that works fine. Then later I need to access $result as a complete array again. Is there a way I can keep $result array intact and still take a couple values out beforehand. I can get it to work, by doing the select twice, but thats less than ideal. Thanks enormously if you can help Jules -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
RE: doing SELECTS and keeping the array intact with php
[snip] this has been bugging me for some time now. I want to do a mysql select then using php while ($a_row = mysql_fetch_array($result)) { do something to get a small portion of the data } and that works fine. Then later I need to access $result as a complete array again. Is there a way I can keep $result array intact and still take a couple values out beforehand. I can get it to work, by doing the select twice, but thats less than ideal. [/snip] More of a PHP question, but use reset($result); instead of a new query http://www.php.net/reset -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
doing SELECTS and keeping the array intact with php
Hi all, this has been bugging me for some time now. I want to do a mysql select then using php while ($a_row = mysql_fetch_array($result)) { do something to get a small portion of the data } and that works fine. Then later I need to access $result as a complete array again. Is there a way I can keep $result array intact and still take a couple values out beforehand. I can get it to work, by doing the select twice, but thats less than ideal. Thanks enormously if you can help Jules -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]