Forum Moderators: coopster

Message Too Old, No Replies

Concatinate PHP code in a String Variable

Concatenate String Variables

         

kyler

7:53 pm on Jan 19, 2005 (gmt 0)

10+ Year Member



I am having a problem with this code it is erroing at the point of entering the string after the php code within.

Any help or code is better I Learn visually!

echo $NonList;
$NonList = "
<div class=\"rightnavheaderblue\"><h3>PRESCRIPTION DRUG RE-IMPORTATION NON-SUPPORTERS</h3></div>
<div class=\"maincontent\">Click on the names below to see what they have said about importation of prescription medication.</div><br><br>
<table>
<tr><td><b><p>Senators</b></td></tr>
" . "
$SQLstatment = "SELECT SupportId, Category, SupporterName FROM supporters WHERE Supporter = 'n' AND Category = 'Senator' ORDER BY SupporterName;";
Get_db_RS ($SQLstatment);
$Result1 = $_SESSION['result'];
//keeps getting the next row until there are no more to get
while($row = mysql_fetch_array( $Result1 )) {
// Print out the contents of each row into a table
print $row['SupporterName']; testing will use
//}
" . "
<tr><td><p><b>Governors</b></td></tr>
ADD A SELECT AND WRITE THE RESULTS
<tr><td><b><p>Political Candidates</b></td></tr>

ADD A SELECT AND WRITE THE RESULTS

<tr><td><b><p>Representatives</b></td></tr>

***** ADD A SELECT AND WRITE THE RESULTS

<tr><td><b><p>Others</b></td></tr>

***** ADD A SELECT AND WRITE THE RESULTS
***********STRUCTURE******
<tr><td>
<a href=\"addedpages/againstlist.php#10\" target=\"window\" onClick=\"winNews(\'addedpages/againstlist.php#10\',\'window\');\" class=\"maincontent\" border=\"0\">White House:</a><br>
</td></tr>
</table>
";

echo $NonList;

Salsa

8:18 pm on Jan 19, 2005 (gmt 0)

10+ Year Member



Kyler, Welcome to WebmasterWorld!

I think that at least part of the problem is that you are trying to concatenate where you shouldn't. The first place I see is after setting $NonList:

<tr><td><b><p>Senators</b></td></tr> 
" . "

$SQLstatment = "SELECT SupportId, Category, SupporterName FROM supporters...
This should be simply:

<tr><td><b><p>Senators</b></td></tr>  
";
$SQLstatment = "SELECT SupportId, Category, SupporterName FROM supporters...

...as it is, you're trying to make "$SQLstatment..." part of the $NonList variable, and you're going to get a parse error at the quote before SELECT.

Then in your while loop, if you want to concatenate the output from your query to $NonList, instead of using print, do it something like this:

$NonList .= "<tr><td>".$row['SupporterName']."</td></tr>\n";

Finally, after the while loop, get rid of the " . " concatenation line, and concatenate the rest of your html like this:

$NonList .= "<tr><td><p><b>Governors</b></td></tr> 
...
</table>";

I hope this helps.

kyler

9:01 pm on Jan 19, 2005 (gmt 0)

10+ Year Member



Thanks sir I will try