Jump to content

[SOLVED] PHP DO in echo statement


kyleldi

Recommended Posts

I've got a little statement that uses the DO cmd to repeat a query on my db, but I have to put it in the middle of my echo.  I keep getting an error on this line, yet I can't figure out what's not correct.  Any ideas?

 

My code that it fails on:

 

echo "<div class='catdetail_header'><h1 class="style1">'.ucwords($row_rs_multi_dl['category']).'</h1>" ; 

 

My complete code:

 

<?php
  if(isset($_GET['category'])){
echo "<div class='catdetail_header'><h1 class="style1">'.ucwords($row_rs_multi_dl['category']).'</h1>" ; 
do {
echo '<div class="catdetail_header"><h1 class="style1">'.ucwords($row_rs_multi_dl['title']).'</h1></div>
<div class="catdetail_desc"><p>'.$row_rs_multi_dl['description'].'</p></div>
<div class="catdetail_footer"><a href="downloads/'.$row_rs_multi_dl['filetype'].'/'.$row_rs_multi_dl['filename'].'">Download Now</a></div>';
    } 
    while($row_rs_multi_dl = mysql_fetch_assoc($rs_multi_dl));
}
else{
echo "<div class="catdetail_header"><h1 class="style1">Please Choose A Category</h1></div>";
do {
echo '<div class="catdetail_header"><h1 class="style1"><a href="1">'.ucwords($row_rs_showcats['category']).'</a></h1>
while($row_rs_showcats = mysql_fetch_assoc($rs_showcats))';
}
?>

 

Thank You!

Link to comment
https://forums.phpfreaks.com/topic/149134-solved-php-do-in-echo-statement/
Share on other sites

You are using single quotes and double quotes incorrectly.  Use double quotes for the whole string, and when you want to break in and out, but for values of attributes use single quotes:

 

echo "".ucwords($row_rs_multi_dl['category']).""; 

Look at this line with a syntax highlighter:

echo "<div class='catdetail_header'><h1 class="style1">'.ucwords($row_rs_multi_dl['category']).'</h1>" ;

echo '<div class="catdetail_header"><h1 class="style1">'.ucwords($row_rs_multi_dl['category']).'</h1>' ;

 

See the difference?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.