简体   繁体   中英

A href in PHP Foreach $result

I have a question about PHP/MYSQL. Here you see my php page in the browser:

在此处输入图片说明

And here you see my phpmyadmin database:

在此处输入图片说明

What I want is when I click on:"Laders" I only want to see on the next page everything in the "groep":"Laders". The problem is I don't know how to do that in a loop. Here is the code:

    <?php 
$link = mysqli_connect('localhost', 'root', 'root', 'producten'); 
$query =    "SELECT *
                    FROM producten
                    WHERE Merk = '" . 'Apple' . "' 
                    ORDER BY Artikelnummer, Artikelnaam";
                    /*echo $query;*/
    $result = mysqli_query($link, $query);
?>
<table>
<?php
    echo '<table style="width:100%">
            <tr style="color:yellow; background-color:black;">
                <th>Apple</th>
            </tr>';
    foreach ($result AS $rij)
{

         echo '<tr style="background:blue"><td>' . $rij['Groep'] . ' </td></tr>';



}
?> </table>
foreach ($result AS $rij)

{

     echo '<tr style="background:blue"><td><a href="view.php?variable='.$rij['Groep'].'">'.$rij['Groep'].'</a></td></tr>';

}

After this, create a php file "view.php" and fetch data using $_GET['variable']

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM