本帖最后由 mahuatengBC 于 2013-01-09 11:35:57 编辑

解决方案 »

  1.   

    动态的数据我是这么打算的//查询奖品表(非必中奖)(数量和名字)
    $sql="select * from luck where rate <> 10000 ";
    $rs=mysql_query($sql);
    $rsCount=mysql_num_rows($rs);
    $rateArr=array();
    $nameArr=array();
    while($row=mysql_fetch_array($rs))
    {
    array_push($rateArr,$row['rate']);
    array_push($nameArr,$row['name']);
    }
    $array=array();
    for($i=0;$i<$rsCount;$i++)
    {
    $array=array_merge(array_fill(0,$rateArr[$i],$nameArr[$i]));
    }echo count($array);
    print_r($array);但是打印出来,只有一种数据,数据没有累加到 $array  
      

  2.   

    $totleArr = array();
    while($row=mysql_fetch_array($rs))
    {
      $totleArr = array_merge(array_fill(0, $row['rate'], $row['name']));
    }
      

  3.   

    怎么漏掉一个?
    $totleArr = array();
    while($row=mysql_fetch_array($rs))
    {
      $totleArr = array_merge($totleArr, array_fill(0, $row['rate'], $row['name']));
    }
      

  4.   


    //查询奖品表(非必中奖)(数量和名字)
    $sql="select * from luck where rate <> 10000 ";
    $rs=mysql_query($sql);
    $rsCount=mysql_num_rows($rs);
    $array=array();
    while($row=mysql_fetch_array($rs))
    {
    $array=array_merge(array_fill(0,$row['rate'],$row['name']));
    }echo count($array);
    print_r($array);$totleArr=array();
    $totleArr = array_merge(array_fill(0, 20, "ipad mini"), array_fill(0, 50, "无线电压力锅"), array_fill(0, 80, "撒旦撒旦"), array_fill(0, 9850, "未中奖"));打印出来就只有  20个“撒旦撒旦” 这款奖品 ,其他的不见了,
      

  5.   

    $totleArr=array();
    while($row=mysql_fetch_array($rs))
    {
    $totleArr=array_merge($totleArr,array_fill(0,$row['rate'],$row['name']));
    }
    $totleArr=array_merge($totleArr,array_fill(0, $less, "未中奖"));
    shuffle($totleArr);这么弄就对了,谢谢大神们了...