Jump to content

MySQL, PHP & Lightbox?


mcfmullen

Recommended Posts

I am in desperate need of a lightbox script that will open dynamic php pages.

 

What I have is a php file that holds a MySql table. Each row has animal names. Clicking an animal name opens animalspec.php which displays the specs on that animal. All of this functions.

 

What I want is to have each animal name open the animalspec.php file in a lightbox window. I've tried many clones of lightbox including greybox, lightbox2, and the one found here:

http://www.richandstephsipe.com/wordpress/2006/12/20/lightbox-with-iframes-reloaded/

 

With the above script, I use a code that looks like this inside my php file:

echo "<a href='http://www.domain.com/animalspec.php?animal={$rownameUser}' rel='lightbox|800|800'>{$rownameAnimal}</a>";

 

The url looks like this in my window:

http://www.domain.com/animalspec.php?animal=selectedanimal

 

All I get is a white page inside a lightbox window. I do not get what the url should display. If I click view source in the window, i see what the window should be showing rather than the php code.

 

Does anyone know of a good, working script for this type of url? Alternatively, is there a way I can get the contents of animalspec.php to display inside an html file so that may be loaded in lightbox instead?

 

This is what animalspec.php look like:

<?php
  if (isset($_GET['animal'])) {
DATABASE CONNECTION STUFF


    $sql = "SELECT Animals.photoAnimal, Animals.nameAnimal, Animals.nameCategory, Animals.introDateAnimal, Animals.endDateAnimal, Animals.sizeAnimal, Animals.XPplacedAnimal, Animals.timeAnimal, Animals.harvestAnimal, Animals.costAnimal, Animals.sellAnimal, Animals.idLevel, Animals.descriptionAnimal, Animals.commentAnimal, animalMethods.nameMethod, animalThemes.nameTheme FROM (Animals LEFT JOIN animalThemes ON Animals.nameAnimal = animalThemes.nameAnimal) LEFT JOIN animalMethods ON Animals.nameAnimal = animalMethods.nameAnimal WHERE Animals.nameAnimal = '{$_GET['animal']}'";
    $result = mysql_query($sql);
    if ($result) {
      if (mysql_num_rows($result) > 0) {
        $row = mysql_fetch_assoc($result);
?>
You've selected <?php echo "{$row['nameAnimal']}.";} ?>
<?php
      } else {
        echo "No animal found by that name";
    }
  } else {
    echo "No animal selected";
  }
?>

Link to comment
https://forums.phpfreaks.com/topic/192732-mysql-php-lightbox/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.