PHP links

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ambal13
Forum Newbie
Posts: 5
Joined: Tue Feb 24, 2009 7:25 pm

PHP links

Post by ambal13 »

Hi I'm trying to create an event calendar for a website and Im having a problem with the PHP

The stuff that works can bee seen here: http://www.gotbookz.com/calendar4.php (you can add an event if you want, just refresh the page to see it)

the above link is ofcourse a trial version

i have made the all the events as links (not on that page) by doing this:

Code: Select all

<a href="event.php"><?php echo $getinfoarray['event_title']; ?> </a> <?php echo "<br/>";
it get the name of the event from my database and makes it a link

there are two problms with this:
1. when a person clicks on an event i want a pop up window to pop up with the details of it. I know that if I put

Code: Select all

target="_blank"
in the link then it will open in a new window but thats not the case in the latest firefox where it opens in a new tab (it works in internet explorer). Anyway to make it a new window/popup?
2. there will be hundreds of events over time and i dont think that creating a new page for every event is a good idea so i created a field in the table in the database called 'id' which gives every event a unique id and i want to be able to have one page called event.php that sets the content based on the id of event. Something like this: you click on the event, a window with details pops up with the address being :http://www.gotbookz.com/event.php?eventid=123. I know how to write to files from another file but i don't know how to make the previous link work.

Can anyone point to a tutorial or something like that in this field? And if there is not enough info or questions ask me.

Thanks
ambal13
Forum Newbie
Posts: 5
Joined: Tue Feb 24, 2009 7:25 pm

Re: PHP links

Post by ambal13 »

i forgot to mention that i do use the (2) concept of links being ?month=&year= but this code was borrowed and i dont fully understand it
yorkcoparamedic
Forum Newbie
Posts: 4
Joined: Tue Feb 24, 2009 1:51 pm

Re: PHP links

Post by yorkcoparamedic »

This might work for your calender. You can resize the popup box very easy and also change the appearance of the box with CSS. Save all the code to a blank page and test it out. I have also attached a 38 x 30 close.gif button for you to use if needed. Let me know if this helps cuz i have a couple of other ideas as well using JavaScript and PHP.

Code: Select all

<?php
$nextid = 1;
function start_link( $text )
{
  global $nextid;
  $idtext = "a"+$nextid;
?><a href="javascript&#058; void drop( '<?php echo($idtext); ?>' );"><span id="a_<?php echo($idtext); ?>"><?php echo($text); ?></span></a><div id="<?php echo($idtext); ?>" class="drop" style="visibility:hidden;">
<table cellspacing="0" cellpadding="0" width="170"><tr>
<td valign="top" width="20">
<a href="javascript&#058; void close(<?php echo($idtext); ?>)"><img src="close.gif" border="0"></a>
</td>
<td valign="top" width="150">
<?php
}
 
function end_link()
{
?>
</td>
</tr></table>
</div><?php
}
 
function link_header()
{
?>
<style type="text/css">
body { font-family: arial, verdana; }
.drop { 
  padding: 5px;
  font-size: small;
  background: #eee;
  border: 1px solid black;
  position: absolute;
}
</style>
<script language="Javascript">
function drop( sid )
{
  aobj = document.getElementById( "a_"+sid );
  divobj = document.getElementById( sid );
  divobj.style.top = aobj.offsetBottom+10;
  divobj.style.left = aobj.offsetLeft+10;
  divobj.style.visibility = "visible";
}
function close( sid )
{
  divobj = document.getElementById( sid );
  divobj.style.visibility = "hidden";
}
</script>
<?php
}
?>
<html>
<head>
<?php link_header(); ?>
</head>
<body>
Hey <?php start_link( "this might work" ); ?>
That really<br/>
Is interesting <?php end_link(); ?>. How about this?
<br/>
The popup will go over text<br/>
And it will stay up until it's dismissed with the close
button.
</body>
</html>
 
Attachments
Close Button
Close Button
close.gif (106 Bytes) Viewed 453 times
ambal13
Forum Newbie
Posts: 5
Joined: Tue Feb 24, 2009 7:25 pm

Re: PHP links

Post by ambal13 »

yorkcoparamedic wrote:This might work for your calender. You can resize the popup box very easy and also change the appearance of the box with CSS. Save all the code to a blank page and test it out. I have also attached a 38 x 30 close.gif button for you to use if needed. Let me know if this helps cuz i have a couple of other ideas as well using JavaScript and PHP.

Code: Select all

<?php
$nextid = 1;
function start_link( $text )
{
  global $nextid;
  $idtext = "a"+$nextid;
?><a href="javascript&#058; void drop( '<?php echo($idtext); ?>' );"><span id="a_<?php echo($idtext); ?>"><?php echo($text); ?></span></a><div id="<?php echo($idtext); ?>" class="drop" style="visibility:hidden;">
<table cellspacing="0" cellpadding="0" width="170"><tr>
<td valign="top" width="20">
<a href="javascript&#058; void close(<?php echo($idtext); ?>)"><img src="close.gif" border="0"></a>
</td>
<td valign="top" width="150">
<?php
}
 
function end_link()
{
?>
</td>
</tr></table>
</div><?php
}
 
function link_header()
{
?>
<style type="text/css">
body { font-family: arial, verdana; }
.drop { 
  padding: 5px;
  font-size: small;
  background: #eee;
  border: 1px solid black;
  position: absolute;
}
</style>
<script language="Javascript">
function drop( sid )
{
  aobj = document.getElementById( "a_"+sid );
  divobj = document.getElementById( sid );
  divobj.style.top = aobj.offsetBottom+10;
  divobj.style.left = aobj.offsetLeft+10;
  divobj.style.visibility = "visible";
}
function close( sid )
{
  divobj = document.getElementById( sid );
  divobj.style.visibility = "hidden";
}
</script>
<?php
}
?>
<html>
<head>
<?php link_header(); ?>
</head>
<body>
Hey <?php start_link( "this might work" ); ?>
That really<br/>
Is interesting <?php end_link(); ?>. How about this?
<br/>
The popup will go over text<br/>
And it will stay up until it's dismissed with the close
button.
</body>
</html>
 
thanks for your help man. it didn't work for some reason when i pasted it into a new page but i figured out how to make my calendar work.

i sent the id of an event as an argument in the url and at the same time used javascript function that made a pop up window and in that popup i $_GET['id'] and then use it to get information out of the database.
Post Reply