Search the Community
Showing results for tags 'array while php mysql'.
-
Hello all, I have a problem with a while bucle and an array, here is the code: I have 2 querys, the result of query 1 is stored into an array and the second query is handled with while. The problem is the $bib variable have always NULL as value, but it's wrong, ... $sql="select distinct(biblionumber) from biblioitems where biblionumber in(select biblionumber from issn_master where issn1 in($lista)or issn2 in($lista) or issnL in ($lista))"; $qry = mysql_query($sql); $sql1="select embargo,fondo,tipo_fondo from stage1 where grupo='".$grupo."' and issn in(select issn1 from issn_master where issn1 in($lista)) or issn in(select issn2 from issn_master where issn2 in($lista));"; $qry1 = mysql_query($sql1); $data = array(); while ($row = mysql_fetch_assoc($qry)) { $data[] = $row[biblionumber]."\n"; } $bib=implode("\n",$row[biblionumber]); while($row1 = mysql_fetch_assoc($qry1)) { $inc++; $sql_item= "insert into items (biblionumber,biblioitemnumber,itype,enumchron,booksellerid,itemcallnumber,barcode,homebranch,holdingbranch,notforloan,damaged,itemlost,wthdrawn,timestamp)values('".$bib."','".$bib."','".$row1[tipo]."','".$row1[fondo]."','".$row1[embargo]."','".$grupo."-".$inc.$row1['type']."-".$bib."','".$grupo."-".$inc.$row1['type']."-".$bib."','".$grupo."','".$grupo."',0,0,0,0,'".$date."')"; echo $sql_item; } If you execute this: foreach($data as $bib){ echo $bib; } Then the result is: 21758 68314 I don't see what is wrong in my code. The correct result expected is: insert into items (biblionumber,biblioitemnumber,itype,enumchron,booksellerid,itemcallnumber,barcode,homebranch,holdingbranch,notforloan,damaged,itemlost,wthdrawn,timestamp)values(21758'',21758'',21758'','1996-','','MHUPA-1-21758','MHUPA-1-21758','MHUPA','MHUPA',0,0,0,0,'')insert into items (biblionumber,biblioitemnumber,itype,enumchron,booksellerid,itemcallnumber,barcode,homebranch,holdingbranch,notforloan,damaged,itemlost,wthdrawn,timestamp)values(68314'',68314'','68314','2001-','','MHUPA-2-68314','MHUPA-2-68314','MHUPA','MHUPA',0,0,0,0,'') Some on can help? Thanks a lot in advance