want to replace [img] filename [/img] tags
Posted: Wed Aug 23, 2006 10:27 am
feyd | Please use
Thanks in advance,
Greg
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
I am developing my first PHP site [url]http://www.forthosewhowait.com/restaurant[/url] and now I want to add a feature to the Customer Management System.
I want to allow a user to add images to the text on the CATERING page. I envision the user typing [img-r]filename.jpg[/img] any where on the page, and then have the server display that specified image at that point on the page. I already have an image upload feature that resizes and stores the images in a folder and records image size and path in a table.
The revelant code is below.
I can hardcode the filename in the $imagename = statement and the picture shows, but I can't seem to get the filename.jpg out of the CATERING page into the PHP code.
The image table contains path,width,height data so that is why it is included, but right now I am streamlining the effort to just getting the filename.jpg off the page and into $imagename variable code.
I think my use of REGUALR EXPRESSIONS is good "\[img-r\](.+)\[/img\]", of course that is just my opinion and I may be wrong.Code: Select all
<?php
$sqlselect_content = @mysql_query("SELECT cater_content FROM cater");
while ($contentlist = mysql_fetch_array($sqlselect_content)) {
$contentlist = $contentlist["cater_content"];
// Photos alignment
$contentlist = eregi_replace("\[img-r\](.+)\[/img\]","$imagename", $contentlist);
$sqlselect_image = @mysql_query("SELECT image_name FROM image
WHERE image_name='$imagename'");
while ($imagelist = mysql_fetch_array($sqlselect_image)) {
$imagename = htmlspecialchars($imagelist["image_name"]);
}
$imagename = "<img src='../images/cater/thumbs/$imagename' align='right' hspace='10' vspace='10' />";
echo ("<br><span class='body01'>$contentlist</span><br>");
}
?>Thanks in advance,
Greg
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]