Search code examples
phphtmlmysqlrecords

How to add link to mysql database record as a <html> href?


  if($rezultat = $polaczenie->query($sql))
$ilu_userow = $rezultat->num_rows;
  while($ilu_userow>0){
    $wiersz = $rezultat->fetch_assoc();
    $id = $wiersz['id'];
    $like = $wiersz['likes'];
    $price = $wiersz['price'];
    echo '<div class="pozycja">
            <span>
              <h1><font color="blue"/> '
               . $id . ' </h1></font><font color="red"/> '
                . $like . ' </font><h2><strong><font color="green"/> '
                 . $price . '</h2></strong></font></span></div>';

    $ilu_userow = $ilu_userow - 1;
  }

This is my code, and - as in the topic - i want to create html adress to every row i get from my database, and the question is - how?


Solution

  •   if($rezultat = $polaczenie->query($sql)) $ilu_userow = $rezultat->num_rows;   while($ilu_userow>0){
        $wiersz = $rezultat->fetch_assoc();
        $id = $wiersz['id'];
        $like = $wiersz['likes'];
        $price = $wiersz['price'];
        echo '<div class="pozycja">
                <span>
                  <h1><font color="blue"/> '
                   . $id . ' </h1></font><font color="red"/> '
                    . $like . ' </font><h2><strong><font color="green"/> '
                     . $price . '</h2></strong></font></span>';
    
        //added line start
    
        echo '<a href="file.php?id='.$id.'">'.$id.'</a>';
        echo '</div>';
    
        //added line end
    
        $ilu_userow = $ilu_userow - 1;   }