INDEX1.PHP, 连接数据库,调出字段名为name,number,并按序组成两排按钮。
这两排按钮输出两个变量为$name,$number,这两个变量组成http://www.name.cn/index2.php?$name+$number
两排按钮里任意一个都可以操作变换URL的相应变量,并自动打开。默认情况下http://www.name.cn/index2.php?name1+number1(name1和number1为数据库各自自动的第一个名字)
如按NAME2键, URL变成 http://www.name.cn/index2.php?name2+number1 自动打开
再按number2, URL变成http://www.name.cn/index2.php?name2+number2 自动打开
……
按键顺序随意这个问题和 http://topic.csdn.net/u/20100624/08/26e83047-833d-48cc-be5b-bf3971c16096.html?8987 类似。
前面那个帖子发错版块了,而且设想也太复杂,没有满意的答案。如果这个问题可以解答,那个帖子的分一并加上。(那个帖子里随意跟个贴,一起给分)
希望这次能得到较详细的答案。

解决方案 »

  1.   

    用javascript控制。
    按钮1响应onclick="sendinfo('type1')"
    按钮2响应onclick="sendinfo('type2')"
    按钮3响应onclick="sendinfo('type3')"var which;
    function sendinfo(which)
    {
       var o1=document.getElementById("name1");
       var o2=document.getElementById("name2");
       var o3=document.getElementById("number1");
       var o4=document.getElementById("number2");   var url="http://www.name.cn/index2.php?";
       if(which=="type1")
          url+=o1.value+"+"+o3.value;
       else if(which=="type2")
          url+=o2.value+"+"+o3.value;
       else if(which=="type3")
          url+=o1.value+"+"+o4.value;
       var args="resizable=yes,scrollbars=no,status=0,width=300, height=150";   window.open(url,"newwindow",args);
    }
      

  2.   

    感谢楼上的JS代码。但是,name1设var o1,name2设var o2,那要是我有100个name的话,要假设100次?
      

  3.   

    其实这个原理有点像搜索引擎:关键字1(字段名1)+关键字A(字段名2),按钮确认输出。只是现在先把所有 字段名1和字段名2里的关键字全部输出,转换为2组按钮,
    2组按钮又分别替代了原先哪个确认输出按钮的功能,即按下任意按钮,根据输出的数值进行匹配超链并打开,
    然后记录最后一次超链地址,等到下次按键时只须替换按键部分的数值并打开超链。重复上面的假设:
    默认情况下http://www.name.cn/index2.php?name1+number1(name1和number1为数据库各自自段的第一个名字)
    如按NAME2键, URL变成 http://www.name.cn/index2.php?name2+number1 自动打开
    再按number2, URL变成http://www.name.cn/index2.php?name2+number2 自动打开
    按name1键,URL变成http://www.name.cn/index2.php?name1+number2 自动打开
    ……
    name和number可以无穷多。
      

  4.   

    那你只需要添加两个变量,一个保存number,一个保存name,在两个条件满足后,自动构建,然后提交。
    这都是JS的事情。
      

  5.   

    感谢楼上的帮助,能不能给段代码?
    具体思路我明白了,但是要把几段JS功能的代码串联起来,对我来说还有点难度。
    还有,PHP代码是否如此?<?php
    mysql_connect("localhost","root","root","root") or die;
    mysql_select_db("books", $db);
    $result = mysql_query("SELECT * FROM list",$db);  
    while ($row = mysql_fetch_array($result)) 
    { echo "<a href=http://www.name.cn/index2.php?".$row["name"]."+".$row["number"].">".$row["name"]."</a><br \>";  }
    mysql_free_result($result);
    ?>
      

  6.   

    另一个坛子有高手回答了。代码如下:<?php 
        $phpself_url=$_SERVER['REQUEST_URI'];
       //获得当前name与number
      list($name,$number)=explode('+',substr($phpself_url,strpos($phpself_url,'?')+1));
    ?>
    //数据库的取值为 $row["name"],$row["number"]
    <?php 
            while($row=mysql_fetch_array('Your SQL')){
                    foreach($row as $key=>$value){//假设只有两列 name,number
                            if($key=="name"){
                              echo "<a href=\"/localhost/index2.php?".$value."+".$number."\">".$value."</a>";
                            }else{
                              echo "<a href=\"/localhost/index2.php?".$name."+".$value."\">".$value."</a>";
                            }
                    }
            }
    ?>
    但是小弟愚钝,将代码进行了设置,得到的结果却是 localhost/index2.php?name1+空 或者 localhost/index2.php?空+number1,不知道自己错在哪?
    还有:如果$name和$number在2个不同的数据表(list1,list2)里,怎么连接呢?
    这里的高手帮忙解析一下。我修改后的代码<?php 
    require_once("connect.php");//连接数据库
    mysql_select_db("book", $db);//数据库名
    $result = mysql_query("SELECT name,number FROM list",$db); //选择数据表
        $phpself_url=$_SERVER['REQUEST_URI'];
        list($name,$number)=explode('+',substr($phpself_url,strpos($phpself_url,'?')+1));
    ?>
    //数据库的取值为 $row["name"],$row["number"]
    <?php 
            while($row=mysql_fetch_array($result)){
                    foreach($row as $key=>$value){//假设只有两列 name,number
                            if($key=="name"){
                              echo "<a href=\"/localhost/index2.php?".$value."+".$number."\">".$value."</a>";
                            }else{
                              echo "<a href=\"/localhost/index2.php?".$name."+".$value."\">".$value."</a>";
                            }
                    }
            }
    ?> 
      

  7.   

    问题解决了,虽然没有采纳LuciferStar的办法,但是还是要感谢热心的人。