Reputation: 13
When i click the link , it cant work.
These are my codes:
if (mysql_num_rows($sql1)) {
echo"<table>";
while ($row1 = mysql_fetch_array($sql1)) {
if($row1['topic_id'] == $row['topic_id']){
echo "<tr><th><font color='blue'>".$row1['topic_name']."</th></tr> </font>";
echo"<a href='postreply.php?cat_id='$cat_id'&topic_id='$topic_id'&topic_creator='$topic_creator''>hi</a>";
}
}
echo "<tr><td>".$row['post_content']."</td></tr>";
echo"</table><hr>";
}
Upvotes: 0
Views: 122
Reputation: 9804
Try with,
echo"<a href='postreply.php?cat_id=$cat_id&topic_id=$topic_id&topic_creator=$topic_creator'>hi</a>";
Your code is breaking due to the wrong usage of ' in the href attribute
Edit :
You are still not able to click the element since the parent element #notificationContainer click event listener has a return false which prevents the default action of children as well.
You can make the link working by either changing listener code that code or by stopping the event propagation from child a to parent #notificationContainer. This will stop calling the parent click event listener and will allow the default action of the a element.
So either remove
$("#notificationContainer").click(function()
{
return false;
});
or add the below code for stopping propagation in the script.
$("#notificationContainer a").click(function(e)
{
e.stopPropagation();
});
Upvotes: 0
Reputation: 479
Do not use HTML
tags inside php echo "<h1>Don't Use This</h1>";
because when you use these in bigger project these may create problem of indentation, omitting quot semicolon Etc. Try to keep your code in good Form.
On the other side i recommend you to use php classes and object, mysqli object oriented with prepared statement .These will help in better way of coding.
<?php
if (mysql_num_rows($sql1)){
?>
<table>
<?php
while ($row1 = mysql_fetch_array($sql1)) {
if($row1['topic_id'] == $row['topic_id']){
?>
<tr>
<th><font color='blue'><?php echo $row1['topic_name'];?></font></th>
</tr>
<a href="postreply.php?cat_id=<?php echo "cat_id=".$cat_id."&topic_id=".$topic_id."&topic_creator=".$topic_creator;?>">hi</a>
<?php
}
}
?>
<tr>
<td><?php echo $row['post_content'];?></td>
</tr>
</table>
<hr>
<?php
}
?>
Upvotes: 0
Reputation: 982
Your quotations are breaking the code,
You will need to escape the double quotes, so they will not be read as PHP code. You can do this by typing a \
character before them.
In your above code, modify as follows:
echo"<a href='postreply.php?cat_id='$cat_id'&topic_id=\"$topic_id'&topic_creator=\"$topic_creator''>hi</a>";
Upvotes: 1
Reputation: 94682
The multiple '
are not needed and the space between ?
and cat
as well may cause issues
echo"<a href='postreply.php?cat_id=$cat_id&topic_id=$topic_id&topic_creator=$topic_creator'>hi</a>";
Upvotes: 0