php - Populate two javascript arrays from the same MySQL Query -
i'm trying fill 2 arrays (time2 , text) same query ($result), first array filled, , don't understand why...
note i'm invoked same query, because order rand () functionality implemented, , when need values of array positions, correct value should appear. , that's why can't create identical query.
possible do?
//array time var time2 = [<?php $title=$_get["title"]; $result = mysql_query("select tag, round(avg(timecode)) timecode, group_id tags tags.filename = '".$title."' group group_id, tag order rand()"); while($row = mysql_fetch_array($result)) { $timecode = $row['timecode']; print $timecode; print ","; }?>] //array text var text = [<?php while($row = mysql_fetch_array($result)) { $tag = $row['tag']; print "'"; print $tag; print "'"; print ","; }?>]
mysql_fetch_array cursor based function. run end of result set , stop. calling again still return 'end of result set'.
.. , it's deprecated.
you should:
- switch pdo or mysqli
- read out whole result set local var , loop on create javascript
Comments
Post a Comment