Parsing a string

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
cheerio
Forum Newbie
Posts: 18
Joined: Sat Aug 13, 2005 4:52 pm

Parsing a string

Post 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.
User avatar
BDKR
DevNet Resident
Posts: 1207
Joined: Sat Jun 08, 2002 1:24 pm
Location: Florida
Contact:

Re: Parsing a string

Post 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>
Post Reply