php将值传递给另一个php

时间:2014-01-08 02:48:09

标签: php mysql

在这里,我从MySQL DB中获取了一组值并将其显示在列表中。我需要传递用户点击的特定值,就像Google一样。

PHP代码段:

if(mysql_num_rows($sql1)>0){
    while($row=mysql_fetch_array($sql1)){
        echo '<a href="#"><li>'.$row['shop_name'].'</a></li>';
    }
}
else{
    echo '<li>'.'No Results Found'.'</li>';
} 

1 个答案:

答案 0 :(得分:2)

试试这个:

if(mysql_num_rows($sql1)>0){
    while($row=mysql_fetch_array($sql1)){
        echo '<a href="pagename.php?field1='.$row['db_field1'].'&field2='.$row['db_field2].'"><li>'.$row['shop_name'].'</a></li>';
    }
}
else{
    echo '<li>'.'No Results Found'.'</li>';
} 

You can do like this.

Here 

pagename.php is page where you post info.
field1, field2 are names data to post.
$row['db_field1], $row['db_field2] are database fields.

谢谢!