Jump to content

displaying HTML in my string variable


webguync

Recommended Posts

apparently I am doing this wrong. I want my string results from a form that searches DB content to appear within HTML table, tr, td tags. I get the results fine, but the HTML part isn't appearing. How should I be doing this?

 

<?php

$string = '';

$result = mysql_query($sql);  /// This is the execution
if (mysql_num_rows($result) > 0){
  while($row = mysql_fetch_object($result)){
  echo "<table>";
  echo "<tr>";
    $string .= "<td>".$row->last_name."</td> ";
     $string .= "<td>".$row->first_name."</td>";
  $string .= "<td>".$row->employee_id."</td>";
   $string .= "<td>".$row->title."</b>";
      $string .= "<td>".$row->territory."</td>";
	   $string .= "<td>".$row->district."</td>";
	    $string .= "<td>".$row->Phase1A_Score."</td>";
	  		   $string .= "<td>".$row->Phase1B_Score."</td>";
			    $string .= "<td>".$row->Phase1_Average."</td>";
	   $string .= "<td>".$row->Phase1A_HS_Exam."</td>";
	   $string .= "<td>".$row->Phase1A_HS_Exam_RT."</td>";
	    $string .= "<td>".$row->Phase1B_HS_Exam."</td>";
	   $string .= "<td>".$row->Phase1B_HS_Exam_RT."</td>";
	    $string .= "<td>".$row->Class_Date."</td>";
		 $string .= "<td>".$row->Awards."</td>";
    $string .= "<br/>\n";
echo "</tr>";
echo "</table>";
  
  }

}else{

  $string = "No matches found!";

} 

echo $string;


?>

Link to comment
Share on other sites

I don't know for sure that I understand exactly what you're asking, but maybe this will help:

 

<?php

$string = "<table>";
$result = mysql_query($sql);

if (mysql_num_rows($result) > 0) {
    while($row = mysql_fetch_object($result)) {
	$string .= "<tr>";
    	        $string .= "<td>".$row->last_name."</td>";
    	        $string .= "<td>".$row->first_name."</td>";
	$string .= "<td>".$row->employee_id."</td>";
	$string .= "<td>".$row->title."</td>";
	$string .= "<td>".$row->territory."</td>";
	$string .= "<td>".$row->district."</td>";
	$string .= "<td>".$row->Phase1A_Score."</td>";
	$string .= "<td>".$row->Phase1B_Score."</td>";
	$string .= "<td>".$row->Phase1_Average."</td>";
	$string .= "<td>".$row->Phase1A_HS_Exam."</td>";
	$string .= "<td>".$row->Phase1A_HS_Exam_RT."</td>";
	$string .= "<td>".$row->Phase1B_HS_Exam."</td>";
	$string .= "<td>".$row->Phase1B_HS_Exam_RT."</td>";
	$string .= "<td>".$row->Class_Date."</td>";
	$string .= "<td>".$row->Awards."</td>";
    	        $string .= "</tr>";
}
$string .= "</table>";
} else {
$string = "No matches found!";
} 

echo $string;

?>

Link to comment
Share on other sites

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.