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.

Recommended Answers

All 3 Replies

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 
}
?>

also:

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

It works. Thank you @joshuajames.delacruz. Thank you @pzuurveen.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.