How to pass a database value in a hyperlink using PHP + HTML

前端 未结 4 2004
無奈伤痛
無奈伤痛 2021-01-29 06:14

I have a table in a database called Artists. It contains two bands. What I would like to do is to be able to click on the bands name using a hyper link, send that bands name to

相关标签:
4条回答
  • 2021-01-29 06:31

    you can't put PHP code into echo and hope that it will run again.

    Try this,

    echo     
    "<a target='Main_Frame' href='Side_Menu_ContentPrint.php?Aname=" . $row['ArtistName'] ."'>". $row['ArtistName'] . "</a>";     
    
    0 讨论(0)
  • 2021-01-29 06:37

    You need to fetch id of band, and place it into while loop to create dynamic functional links. You could use band name instead of id, but it can lead to errors. Better to do with the primary key.

    $id = $row['id'];
    <a target='Main_Frame' href=Side_Menu_ContentPrint.php?id=$id>" . $row['ArtistName'] . "</a>
    
    0 讨论(0)
  • 2021-01-29 06:44

    Use this

    echo "<a target='Main_Frame' href='Side_Menu_ContentPrint.php?Aname=".$_POST['ArtistName'].$row['ArtistName'] . "'</a>";      
    
    0 讨论(0)
  • 2021-01-29 06:55

    you can use http_build_query please see http://www.php.net/http_build_query

    you can c onvert a PHP Array to a Query String… and Back Again , Please see below

     $myArray = array(  
            "car"=>array("ford", "vauxhall", "dodge"),  
            "animal"=>"elephant",  
            "language"=>"php"  
        );  
    
    echo http_build_query($myArray);  
    
    // Outputs: car[0]=ford&car[1]=vauxhall&car[2]=dodge&animal=elephant&language=php  
    
    
    $queryString = "car=ford&animal=elephant&language=php";  
    
    parse_str($queryString, $output);  
    
    print_r($output); 
    
    Array  
    (  
        [car] => ford  
        [animal] => elephant  
        [language] => php  
    )  
    
    0 讨论(0)
提交回复
热议问题