tags:

views:

79

answers:

4

Help, Im really sick of using this lots of nbsps in my results page. Im just a beginner. Can you recommend me some techniques so that I will not be copy pasting this lots of nbsp just to get the space and line breaks I need.

 while($row = mysql_fetch_array($result))
      {
      echo "Patient #:". " ".  " ". " ". " ". $row['PNUM']; 

     echo "<B>"."Hospital #:"."</B>". "&nbsp;".  "&nbsp;". "&nbsp;". "&nbsp;". $row['HOSPNUM']."&nbsp;"."&nbsp;"."&nbsp;";
      echo "<B>"."Room:". "&nbsp;".  "&nbsp;". "&nbsp;". "&nbsp;". $row['ROOMNUM'];
       echo "<B>"."Lastname:". "&nbsp;".  "&nbsp;". "&nbsp;". "&nbsp;". $row['LASTNAME'];
        echo "<B>"."Firstname:". "&nbsp;".  "&nbsp;". "&nbsp;". "&nbsp;". $row['FIRSTNAME'];
         echo "<B>"."Middlename:". "&nbsp;".  "&nbsp;". "&nbsp;". "&nbsp;". $row['MIDNAME'];
          echo "<B>"."Admission Date:". "&nbsp;".  "&nbsp;". "&nbsp;". "&nbsp;". $row['ADATE'];
           echo "<B>"."Admission Time:". "&nbsp;".  "&nbsp;". "&nbsp;". "&nbsp;". $row['ADTIME'];
                echo "<B>"."Patient #:". "&nbsp;".  "&nbsp;". "&nbsp;". "&nbsp;". $row['PNUM']; 

      }
+9  A: 

Use a HTML table tag.

Kugel
+4  A: 

Consider tables or definition lists

Mike B
+4  A: 

Does it have to be plain text or can you display this in a table?

<table>
<tr>
    <th>Patient #</th>
    <th>Hospital #</th>
    <th>Room</th>
    <!-- etc. -->
</tr>
while($row = mysql_fetch_array($result))
{
    echo "<tr>";
    echo "<td>$row['PNUM']</td>";
    echo "<td>$row['HOSPNUM']</td>";
    echo "<td>$row['ROOMNUM']</td>";
    // etc.
    echo "</tr>";
}
</table>
iKnowKungFoo
HTML injection (XSS). Needs `htmlspecialchars`.
bobince
+1  A: 

if your output is mainly for debugging, you can output your results in pre tag, pre tag, *pre*serve space and line breaks

if not, you should learn some html (and css), a few possibilities are lists, tables, or custom markup with css style

mathroc