Page 1 of 1

Parsing a string

Posted: Fri Dec 16, 2005 3:00 pm
by cheerio
Hey, i need help parsing a string that i am receiving from mysql. Here is the code

Code: Select all

$result = mysql_query("SELECT * FROM `content` WHERE name='current' LIMIT 1");
		while($row = mysql_fetch_array($result)) {
		 echo $row['categories'];
		}
This is what it should echo, parsed.

Code: Select all

<div id='head'> Tutorials </div> 
<div id='content'>
  &raquo; <a href='$weburl'>Home</a><br>
  &raquo; <a href='{$weburl}categories/Adobe_Photoshop'>Adobe Photoshop</a><Br>
  &raquo; <a href='{$weburl}categories/PHP_and_MySQL'>PHP and MySQL</a><Br>
  &raquo; <a href='{$weburl}categories/Macromedia_Flash'>Macromedia Flash</a><Br>
  &raquo; <a href='{$weburl}categories/Adobe_Photoshop'>Adobe Photoshop</a><Br>
  </div>  <div id='bottom'> </div>
I want it to fill in the varialbe $weburl, but PHP doesn't parse it and i don't know how.

Re: Parsing a string

Posted: Fri Dec 16, 2005 9:12 pm
by BDKR
cheerio wrote:Hey, i need help parsing a string that i am receiving from mysql. Here is the code

Code: Select all

$result = mysql_query("SELECT * FROM `content` WHERE name='current' LIMIT 1");
		while($row = mysql_fetch_array($result)) {
		 echo $row['categories'];
		}
This is what it should echo, parsed.

Code: Select all

<div id='head'> Tutorials </div> 
<div id='content'>
  &raquo; <a href='$weburl'>Home</a><br>
  &raquo; <a href='{$weburl}categories/Adobe_Photoshop'>Adobe Photoshop</a><Br>
  &raquo; <a href='{$weburl}categories/PHP_and_MySQL'>PHP and MySQL</a><Br>
  &raquo; <a href='{$weburl}categories/Macromedia_Flash'>Macromedia Flash</a><Br>
  &raquo; <a href='{$weburl}categories/Adobe_Photoshop'>Adobe Photoshop</a><Br>
  </div>  <div id='bottom'> </div>
I want it to fill in the varialbe $weburl, but PHP doesn't parse it and i don't know how.

Code: Select all

&raquo; <a href='{<?php echo $weburl; ?>}categories/Adobe_Photoshop'>Adobe Photoshop</a><Br>