Expand|Select|Wrap|Line Numbers
- <?php
- include("../../connect.php");
- $qry="select * from stock";
- $rst=mysql_query($qry) or die("Error in Query.".$qry." ".mysql_error());
- while($row=mysql_fetch_assoc($rst)){
- $item=$row['item'];
- $list[$item]=$row['price'];
- }
- foreach($list as $key =>$value){
- echo $key."-";
- echo $value."<br/>";
- }
- echo $list['coke'];
- ?>
- <script type="text/javascript" language="javascript">
- list = new Array("<?php echo $list[$item]; ?>")
- alert(list);
- </script>
cos the alert is only printing the value the last key "5000"