Page 1 of 2
PHP POPUPS? hehe
Posted: Fri Jan 30, 2004 12:45 pm
by John Cartwright
I know this is the stupidest thing to ask but how can I create popups with php... don't ask why.... it just will make my life a whole lot easier. I know you propably can't :S but I thought I'd ask.
Posted: Fri Jan 30, 2004 12:47 pm
by markl999
Yeah, you can't

PHP is server side, so you'de need to use JavaScript, course, PHP can create the JavaScript same as it can 'create' HTML

Posted: Fri Jan 30, 2004 12:54 pm
by John Cartwright
K let's take a different course of action then.
Code: Select all
<script language="JavaScript" type="text/javascript">
flyer = "";
function pop_news(psjs_url){
if(flyer){
if(flyer.closed){
flyer = window.open("news.php", "flyer", "top=" + ((screen.availHeight/2) - (500 / 2)) + ",left=" + ((screen.availWidth/2) - (700 / 2)) + ",width=500,height=500,resizable=0,toolbar=0,scrollbars=1,location=0,status=0,menubar=0")
} else {
flyer.focus();
}
} else {
flyer = window.open("news.php", "flyer", "top=" + ((screen.availHeight/2) - (500 / 2)) + ",left=" + ((screen.availWidth/2) - (700 / 2)) + ",width=500,height=500,resizable=0,toolbar=0,scrollbars=01,location=0,status=0,menubar=0")
}
}
</script>
and then my link was
Code: Select all
ї<a href="javascript:pop_news();">read
more</a>]
K so thats the javascript way.... but I have a loop which is for different news headlines there is a read more function which brings up all the news articles in the news database (news.php) and it brought to the specific article..... I'm mentally stuck on this :S
Posted: Fri Jan 30, 2004 12:56 pm
by phpcoder
Just as u creat HTML code with php as response u can also create java script using php for pop ups u can use java script window.open(.....) function
Posted: Fri Jan 30, 2004 1:01 pm
by John Cartwright
Just out of curiosity... Do i have to declare the function before using it ..
cuz you set it then it reads the rest of the code and makes sense of it and runs to function... or u gotto declare it first :S
Posted: Fri Jan 30, 2004 1:05 pm
by John Cartwright
nvm I just remembered all about windows.open function... all I needed to know TY
Posted: Fri Jan 30, 2004 1:11 pm
by John Cartwright
grr I'm trying it out but its not working very well.. getting a lot of errors
How do I format this properly
Code: Select all
<?php
."<td width="73" class="readmore">[<a href="javascript:window.open(news.php, width=500, length=500, location=0);">read more</a>]</td>\n"
?>
I know #$id will give an invalid char error... but I'm getting other errors such as 'news' undefined.
I'm not sure what to do, I tried putting all the variables in window.open in quotes... and then just their numbers... but still nothng
Posted: Fri Jan 30, 2004 1:18 pm
by markl999
Might be better to just do
<td width="73" class="readmore">[<a href="javascript:window.open(news.php?id=<?php echo $id ?>, width=500, length=500, location=0);">read more</a>]</td>
Posted: Fri Jan 30, 2004 1:21 pm
by John Cartwright
cant do that.... this is inside a loop :S
Posted: Fri Jan 30, 2004 1:23 pm
by markl999
Can still break out of PHP mode for it if you wanted..
foreach($foo as $bar){
?>
<td>..etc..etc..</td>
<?php
}
?>
Posted: Fri Jan 30, 2004 1:40 pm
by John Cartwright
This is still not working
Heres a bigger snipplet.
Code: Select all
<?php
$result = @mysql_query("SELECT * FROM news ORDER BY `id` DESC LIMIT 10");
if (!$result) {
echo("<p>Error performing query: " . mysql_error() . "</p>");
exit();
}
while ( $row = mysql_fetch_array($result) ) {
$title = $row["title"];
$newsid = $row["id"];
echo "<tr>\n"
."<td height="19">$title</td>\n"; ?>
<td width="73" class="readmore">[<a href="javascript:window.open(news.php?id=<?php echo $id ?>, width=500, length=500, location=0);">read more</a>]</td>
<?
echo "</tr>\n";
}
?>
Posted: Fri Jan 30, 2004 2:02 pm
by John Cartwright
help me

Posted: Fri Jan 30, 2004 2:05 pm
by DuFF
Whats wrong with it? Seems fine to me...
Posted: Fri Jan 30, 2004 2:08 pm
by John Cartwright
There is a syntax error...
Line 1 Char 25 Code=0
That's all it sais... The error is that javascript line...
Posted: Fri Jan 30, 2004 2:10 pm
by DuFF
Phenom, if you want help you have to tell us the problem. Just mentioning it vaugly doesn't help! Show us the exact error you got! Show us the line it is pointing to! We can't help unless you tell us what's wrong.
