duan205571 2016-09-22 22:30
浏览 7

显示基于链接的SQL表信息[关闭]

I currently have a php file displaying a list of unique VARCHAR items in a table on a SQL server like this:

echo "<b><center>Strain List</center></b><br><br>";

$i=0;
$priorstrain='NULL';
while ($i < $num) {
    $strain=mysql_result($result,$i,"Strain");

    if ($strain!=$priorstrain) {

        echo "<a href=result.php><b>$strain</b></a>";
    }
    $priorstrain=$strain;
    $i++;
}

I would like all items that matches $strain to display on the next page. For example, say the list displays:

CAT DOG MOUSE

and when someone clicks on DOG I want the page to redirect to a page that shows:

STRAIN OWNER DOB      COLOR 
DOG    JOHN  9/9/2015 BROWN
DOG    JEFF  10/04/2013 BLACK

What is the best way to accomplish this?

Thanks in advance!

</div>
  • 写回答

1条回答 默认 最新

  • douchuxun4162 2016-09-23 00:27
    关注

    You can use GET variables as @bassxzero said, to do this you can do like this in your code :-

    if ($strain!=$priorstrain) {
    
            echo "<a href='result.php?strain='$strain><b>$strain</b></a>";
        } 
    

    result.php

    if(isset($_GET['strain'])) {
        //I am not doing but make sure you validate this variable first :)
        $stname = $_GET['strain'];
        //SOME CODE HERE LIKE 
        // SELECT QUERY TO SHOW ALL RESULT LIKE OWNER'S NAME, DETAILS, ETC.    
       }
    

    Hope this will help you :)

    评论

报告相同问题?

悬赏问题

  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效