billborric Posted April 26, 2010 Share Posted April 26, 2010 Hi, I am having problems with the following code only adding the very first record and no others... mysql_data_seek($result1, 0); while ($stkrecord = mysql_fetch_array($result1, MYSQL_ASSOC)) { $stkrecord["id"] = ""; $stkrecord["invno"] = $newinvno; // insert cloned copy of the original record $s1 = "`".implode(array_keys($stkrecord), '`,`')."`"; $s2 = "'".implode(array_values($stkrecord), "','")."'"; $sql2 = "INSERT INTO `arinvtra` ($s1) VALUES ($s2)"; //echo($sql); mysql_query($sql2); } ...for some reason the 'while' is returning FALSE after the first record, exiting the loop and continuing with code following it. I can mix and match the records, to see if there is one particular record causing the problem, but each record when used as the first will all be saved. After a couple of hours on this, some help would be really appreciated. Thanks Link to comment https://forums.phpfreaks.com/topic/199724-mysql_fetch_array-only-displaying-first-record/ Share on other sites More sharing options...
billborric Posted April 26, 2010 Author Share Posted April 26, 2010 Found the problem. Turns out I had a unique index set on one of the fields which prevented the other records from being added. Link to comment https://forums.phpfreaks.com/topic/199724-mysql_fetch_array-only-displaying-first-record/#findComment-1048282 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.