0

Hello.
This is a part of my script:

<table id="table-5">
    <thead>
        <th>ID</th>
        <th>URL</th>
        <th>Editor</th>
        <td>More....</td>
    </thead>
    <tbody>

<?php

include('connection.php');
try {
$sql = "SELECT * FROM Data ORDER BY ID DESC";
$result = $conn->query($sql);

foreach($result as $key => $row) {
        echo "<tr>";
        echo "<td>" . $row['ID'] . "</td>";
        echo "<td>" . $row['URL'] . "</td>";
    echo "<td>" . $row['Editor'] . "</td>";
    echo "<td><a id='more' href='http://www.niloofar3D.ir' onClick='return popup(this, 'mypopup')'><button>&raquo;</button></a></td>";
    echo "</tr>";
}

} catch(PDOException $e) {
    echo "Query error:".$sql . "<br>" . $e->getMessage();
}

$conn = null;
?>

    </tbody>



</table>

Line 22 is a button that is popup. But as I have put it here in the php part of the code, it doesn't work now. It acts as clicking a link right now.

But will act as a popup in this way:

<td><a id="more" href="http://www.niloofar3D.ir" onClick="return popup(this, 'mypopup')"><button>&raquo;</button></a></td>

How can i fix it. Because of " and ' this problem has happend.

Edited by Niloofar24

3
Contributors
3
Replies
24
Views
2 Years
Discussion Span
Last Post by Niloofar24
1

you can do it this way its much more easier to make them like this

foreach($result as $key => $row) {
?>
    <tr>
    <td> <?= $row['ID'] ?>   </td>
    <td> <?=$row['URL'] ?>   </td>
    <td> <?=$row['Editor'] ?></td>
    <td><a id='more' href='http://www.niloofar3D.ir' onClick='return popup(this, 'mypopup')'><button>&raquo;</button></a></td>";
    </tr>
    <?php 
}
?>
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.