0

I have the following code from mysql.

if ($result = $mysqli->query("SELECT * FROM movies")) {
    if (mysqli_num_rows($result) > 0) {
    // output data of each row
    while($row = mysqli_fetch_assoc($result)) {
        echo '<span class="image">';
        echo'<img id="'. $row["movie_ID"] .'" src=" ' .$row["bild"]. ' "/>';
        echo '</span>';
        echo '<a href=" ' . $row["link"] . ' ">';
        echo '<h2>' . $row["name"] . '</h2>';
        echo '<div class="content">';
        echo '<p>' . $row["short"] . '</p>';
        echo '</div>';
        echo '</a>';
    }
} else {
    echo "0!";
}
mysqli_close($conn);
}

My code works, but now I want to change it so that when I click on it, it opens my defined php site and my image href is input there.

7
  • When you click on what?
    – Russ J
    Commented Feb 19, 2019 at 17:26
  • Maybe pass your image and link at GET or POST parameters?
    – Russ J
    Commented Feb 19, 2019 at 17:29
  • these are videos and pictures from mysql. i have player.php, when i click on picture i want to send parameter to player.php
    – Yoe
    Commented Feb 19, 2019 at 17:36
  • Is there any reason why you couldn't just pass them as GET or POST?
    – Russ J
    Commented Feb 19, 2019 at 17:43
  • I'm not such a professional, I'm just learning, and I'm making home video library. can you please show me somehow how I could do it?
    – Yoe
    Commented Feb 19, 2019 at 17:47

2 Answers 2

0

Thanks Russ J,i read more, what you told me, then I changed code.

$video = $row["link"];
echo '<a href="/videoteka.ado/player.php?video= ' . $video. ' ">';

player.php

<? Php
 $ movie_link = $ _GET ["video"];
?>

Thank you very much

-1

If I understood your task correctly, then you need something like that:

if ($result = $mysqli->query("SELECT * FROM movies")) {

    if (mysqli_num_rows($result) > 0) {
    // output data of each row
        while ($row = mysqli_fetch_assoc($result)) {
            echo '<a href=" ' . $row["link"] . ' ">';
            echo '<span class="image">';
            echo '<img id="' . $row["movie_ID"] . '" src=" ' . $row["bild"] . ' "/>';
            echo '</span>';
            echo '<h2>' . $row["name"] . '</h2>';
            echo '<div class="content">';
            echo '<p>' . $row["short"] . '</p>';
            echo '</div>';
            echo '</a>';

        }
    } else {
        echo "0!";
    }

    mysqli_close($conn);

}
3
  • these are automatically generated images from db, images have href link of movies, I've made a another php site, player.php. I want if I click on the picture the href from picture in player.php page transfer. Do you understand now?
    – Yoe
    Commented Feb 19, 2019 at 19:39
  • No. I wrap image into link. You did not specify in the question about the player.php and I suggested that this link in $row["link"]. Learn to ask questions before putting a minus.
    – N1Creator
    Commented Feb 21, 2019 at 7:55
  • I did not give you a minus, I do not know who that was, I just wrote komentar
    – Yoe
    Commented Feb 21, 2019 at 14:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.