我把网页分成俩个部分.  左侧全是图片  当我点击左侧图片 在右侧保存图片..  当我点第二张图片 第一张图片扔在.第二张图片也能保存在上面..点第三张图片.前俩张仍然在..  现在我出现的问题就是 点一张图片 就替换前面的图片的...请高手帮助解决呀...

解决方案 »

  1.   

    上代碼,肯定是该+=写成=了
    或是js 该append写成=了
      

  2.   

    <?php
    session_start();
    $coon=mysql_connect("localhost","root","phpwind.net");mysql_select_db("caidan",$coon);mysql_query("set names gb2312");//error_reporting(0); $cid=$_GET[cid];
    $images=$_GET[name];
    $_SESSION[cid]=$cid;
    $_SESSION[images]=$images;      /*    echo '<pre>';
    print_r($cai);
    echo '</pre>';
    echo '<hr />';
    echo '<pre>';
    print_r($_SESSION['images']);
    echo '</pre>';*/
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>无标题文档</title>
    </head>
    <body>
    <form id="form1" name="form1" method="post" action="">
      <table width="184" border="1">
      <tr>
      <?php
    $ck="select*from caidan";
    $ckl=mysql_query($ck);while($row=mysql_fetch_assoc($ckl)){
       
    ?> 
      
        
          <td width="174" align="center"><a href="tu.php?cid=<?php echo $row['id'] ?>&&&&&&name=<?php echo $row['images'] ?>"><img src="images/<?php echo $row[images] ?>.jpg" width="100" height="100" border="0" /></a></td>
      
      <?php
       $i++;
        if($i==2){
      $i=0;
      echo "</tr>";
        }
    }
      ?>      </tr>
      </table>
    </form>   <?php
    $q="select*from caidan where id=$cid";
    $p=mysql_query($q);
    $rop=mysql_fetch_assoc($p); $name=$rop['images'];    
     $cai=$_SESSION['cai'];   
     
     $cai[$goods_id]=array('id'=>$cid,'images'=>$name);
    echo '<pre>';
       print_r($cai[$goods_id]);
    echo '</pre>';$_SESSION['cai']=$cai;
     echo '<pre>';
       //print_r($_SESSION['cai']);
    echo '</pre>';  
    ?><p>&nbsp;</p>
    <table width="190" border="1">
      <tr>    <td width="189" align="center"><img src="images/<?php echo $images ?>.jpg" width="100" height="100" /></td>  </tr>
    </table>
    </body>
    </html>
      

  3.   

    我的心太乱啊
    本页是tu.php吗,点击后页面刷新了
    值都没了,就得到你传的一个src
    <table width="190" border="1">
      <tr>
      <td width="189" align="center"><img src="images/<?php echo $images ?>.jpg" width="100" height="100" /></td>
      </tr>
    </table>
    这儿你也没循环,就会一直是一条数据的
    你页面上好多session没用的,还有 print_r
    $q="select*from caidan where id=$cid";//你查过了,数据没用上啊
    你是不是想点左边图片,添加到右边表格里