I'm trying to replace a simple command from a basic CMS with a database call.
The user enters
[gallery id=x]
into the CMS, and I want this to go away, find the images included in that gallery, and display them (ready for the jQuery Cycle plugin)
I can get:
$pattern = '/\[gallery id=(\w+)\]/i';
$rpl = 'Display Gallery ID ${1}';
$bubble = preg_replace($pattern, $rpl, $bubble);
...which returns "Display Gallery 12" (for example). However I need it to do this:
$sql = "SELECT * FROM galleries INNER JOIN photos ON photos.PhotoGallery=galleries.GalleryID WHERE GalleryID='x'";
$set = mysql_query($sql);
echo '<div id="gallery">';
while($row = mysql_fetch_array($set))
{
echo '<img src="'.$row['PhotoPath'].'" />';
}
echo '</div>';
mysql_*functions will be deprecated in PHP 5.5. It is not recommended for writing new code as it will be removed in the future. Instead, either the MySQLi or PDO and be a better PHP Developer.