HTML Code
<?php $id=1;?>
<a href="" onClick="popitup('popup1.php?id=<?php echo $id;?>')">Open</a>
Javascript Code
<script type="text/javascript">
function popitup(url) {
newwindow=window.open(url,'name','height=200,width=150');
if (window.focus) {newwindow.focus()}
return false;
}
</script>
Answer from Blue Rose on Stack OverflowVideos
For a popup javascript is required. Put this in your header:
Copy<script>
function myFunction()
{
alert("I am an alert box!"); // this is the message in ""
}
</script>
And this in your body:
Copy<input type="button" onclick="myFunction()" value="Show alert box">
When the button is pressed a box pops up with the message set in the header.
This can be put in any html or php file without the php tags.
-----EDIT-----
To display it using php try this:
Copy<?php echo '<script>myfunction()</script>'; ?>
It may not be 100% correct but the principle is the same.
To display different messages you can either create lots of functions or you can pass a variable in to the function when you call it.
You'll have to use JS to open the popup, though you can put it on the page conditionally with PHP, you're right that you'll have to use a JavaScript function.
You can do it by JavaScript see the solution given below:
Add this script on top of the page in head section
<script>
function pop_up(url){
window.open(url,'win2','status=no,toolbar=no,scrollbars=yes,titlebar=no,menubar=no,resizable=yes,width=1076,height=768,directories=no,location=no')
}
</script>
Replace these line on your code
<td>
<a href="update_users.php?person_id=<?php echo $row['person_id']; ?>" onclick="pop_up(this);">EDIT</a>
</td>
<td>
<a href="delete_users.php?person_id=<?php echo $row['person_id']; ?>" onclick="pop_up(this);">DELETE</a>
</td>
Hope it will help.
Use java scripts function.
function popupCenter(pageURL, title, w, h) {
var left = (screen.width / 2) - (w / 2);
var top = (screen.height / 2) - (h / 2);
var targetWin = window.open(pageURL, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width='+w+', height='+h+', top='+top+', left='+left);
}
<a href="#" onclick="popupCenter('delete_users.php?person_id=<?php echo $row['person_id']; ?>')">DELETE</a>
Your problem is the quotes, however you don't need to echo it at all. If you need to echo variables inside the url, try this:
<a href="http://www.quackit.com/common/link_builder.cfm?<?php echo $variable;?>" onclick="basicPopup(this.href);return false">Open a popup window</a>
alternatively, you can escape the quotes inside the string using a backslash:
echo "<a href=\"http://www.quackit.com/common/link_builder.cfm\" onclick=\"basicPopup(this.href);return false\">Open a popup window</a>";
Escape the quote or use single quote solved the problem.
Try
Escape the double quote within the quote
<?php
echo "<a href=\"http://www.quackit.com/common/link_builder.cfm\" onclick=\"basicPopup(this.href);return false\">Open a popup window</a>";
?>
or
Use single quote
<?php
echo "<a href='http://www.quackit.com/common/link_builder.cfm\' onclick='basicPopup(this.href);return false'>Open a popup window</a>";
?>
Don't echo HTML. Just let PHP output it directly.
<a href="delete_donor.php?id=<?php echo $row->id; ?>" class="delete_icon2" title="Delete Donor"
onclick="return confirm('Are you sure you want to delete this entry?')"></a></td>
Anything not inside <?php ?> tags is echoed directly to stdout.
It isn't a PHP issue.
onclick='return confirm('Are you sure you want to delete this entry?')'
is not going to work since you use ' for two different things.
Change it to
onclick='return confirm(\"Are you sure you want to delete this entry?\")'
and it should work.
php is a server side scripting language. You can do it with jquery. here a demo jsfiddle shows modal popup. Please go through it.
<!-- Button trigger modal -->
<button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">
Launch demo modal
</button>
<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
<h4 class="modal-title" id="myModalLabel">Modal title</h4>
</div>
<div class="modal-body">
...
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>
PhP cannot open popups... for that you need to use html or javascript
if you are using a css framework its easier (like bootstrap)
http://getbootstrap.com/javascript/#modals