Create a clickable link in php from sql results

后端 未结 3 1329
醉梦人生
醉梦人生 2021-01-17 01:29

I am trying to make the results from mysql results clickable links in php. I am new to php and please help.



        
相关标签:
3条回答
  • 2021-01-17 01:45

    echo '<a href="php page which you want to display on click">$info['descr']</a>'

    0 讨论(0)
  • 2021-01-17 01:48
    while ($info = mysql_fetch_array($data)) {
        echo '<a href="somefile.php?id='.$info['ID'].'">'.$info['title'].'</a>';
        echo " <br>";
        echo $info['descr'];
        echo "<br>";
        echo "<br>";
    }
    

    Then in somefile.php, use $_GET to capture the id and show the results

    $id = $_GET['id'];
    // pull info from db based on $id
    $sql = mysql_query('SELECT * FROM items WHERE ID = "'.$id.'"');
    .
    .
    .
    .
    
    0 讨论(0)
  • 2021-01-17 01:53

    just use anchor tag like this

    while ($info = mysql_fetch_array($data)) {
        echo "<a href =\"$info[title]\">".$info['title'];. "</a>";
    }
    
    0 讨论(0)
提交回复
热议问题