How can I transform a PHP Function's MySQL Loop in to an HTML custom markup tag?
I have a MySQL While Loop in a PHP Function. Basically, block code so if need be, can be reused without any user errors.
This is for client implementation though. I want to make this process as easy as possible for the client to add PHP functions without having to learn PHP, but also be able to be inserted in to a textarea via my CMS backend.
I already have custom markup code using preg_replace, but that involves the function's content to be set as a variable. With the way I have my MySQL while loop currently set, it only displays the first row when/if I replace the echo with a variable. I don't know enough about preg_replace to know if I can use it without a variable.
MySQL While Loop/PHP Function (example):
function myPageList($var1,$var2)
{
global $dbc;
$query = "SELECT page_url, title, desc FROM pages ORDER BY nav_order ASC";
$query_result = @mysql_query($query, $dbc);
while ($row = mysql_fetch_array($query_result))
{
$page = $row['page_url'];
$title = $row['title'];
$desc = $row['desc'];
echo "content goes here";
}
}
Custom Markup (end result):
[myPageList]
Whether I add on to the code I currently have or use something totally different, in the end I need an HTML safe custom markup for a PHP function.
Please let me know if you need more details on this.