Wordpress MySql query - foreach gallery echo the description

416 Views Asked by At

i'm trying to echo each gallery description, but i don't know how to write so it would check which gallery we are in right now.

Can't use the default method of writing echo nl2br($gallery->description); because i'm trying to echo it into prettyphoto plugin, which is in header.

So i wrote the query, but it just jams all descriptions. This is the code, i tried to make it query only rows where our database gid is equal to gid of the gallery we are in, but it doesn't seem to work:

<?php $result = mysql_query("SELECT * from wp_ngg_gallery WHERE 'gid'='". gid ."';");while($row = mysql_fetch_array($result))
        {
            $gallery_desc[] = $row['galdesc'];
        }
    foreach ($gallery_desc as &$galdesc)
        {
            echo '<div class="GalleryDescription">' . $galdesc . '</div>';
        }
    ?>

Thanks

1

There are 1 best solutions below

3
On

Try replacing 'gid' with a variable:

$result = mysql_query("SELECT * from wp_ngg_gallery WHERE 'gid'='". $gid ."';")