Re: Formatting - Solved

Jim Giner <[email protected]>
Newsgroups gmane.comp.php.database
Message-ID <[email protected]>
On 11/26/2012 1:04 PM, Ethan Rosenberg, PhD wrote:
> Dear list
>
> Here is the answer....
>
>      ORIGINAL
>
> <center><b>Search Results</b></center><br />
> <center>
> <!--  This is the block that prints about one screen full down bellow
> the Search Results header -->
>
> <table border="4" cellpadding="5" cellspacing="55"  rules="all"
> frame="box" style="table-layout: fixed;">
> <tr class="heading">
> <th>Site</th>
> <th>Medical Record</th>
> <th>First Name</th>
> <th>Last Name</th>
> <th>Phone</th>
> <th>Height</th>
> <th>Sex</th>
> <th>History</th>
> <th>Birthday</th>
> <th>Age</th>
> </tr>
> </div>
>
> <?php             $i = 0;
>                  do
>                  {
>                      {
>                          $vara2 = array(array($Site, $MedRec, $Fname,
> $Lname, $Phone, $Height, $Sex, $Hx, $Bday, $Age));
>
>                          $vara2[$i][0]    = $Site;
>                          $vara2[$i][1]    = $MedRec;
>                          $vara2[$i][2]    = $Fname;
>                          $vara2[$i][3]    = $Lname;
>                          $vara2[$i][4]    = $Phone;
>                          $vara2[$i][5]    = $Height;
>                          $vara2[$i][6]    = $Sex;
>                          $vara2[$i][7]    = $Hx;
>                          $vara2[$i][8]    = $Bday;
>                          $vara2[$i][9]    = $Age;
>
>                          echo "<tr>\n";
>                          $_SESSION['exe'] = 2;
> ?>
> <td> <?php echo $vara2[$i][0]?> </td><br />
> <td> <?php echo $vara2[$i][1]?> </td><br />
> <td> <?php echo $vara2[$i][2]?> </td><br />
> <td> <?php echo $vara2[$i][3]?> </td><br />
> <td> <?php echo $vara2[$i][4]?> </td><br />
> <td> <?php echo $vara2[$i][5]?> </td><br />
> <td> <?php echo $vara2[$i][6]?> </td><br />
> <td class="first-col"><?php echo $vara2[$i][7] ?></td><br />
> <td> <?php echo $vara2[$i][8]?> </td><br />
> <td> <?php echo $vara2[$i][9]?> </td><br />
> <?php                     echo "</tr>\n";
>                          $i = $i +1;
>
>                      }
>                  } while (mysqli_stmt_fetch($stmt)); //end do-while
>                      $imax = $i;
>                      echo "</table>";
>                      echo "</center>";
>                      echo "</form>";
>
>              }    //    end count($errors_array)
>
>
> THIS IS THE CORRECTED VERSION:
>
>              if(count($errors_array) == 0)
>              {
> ?>
>
> <center><b>Search Results</b></center><br />
> <center>
> <table border="4" cellpadding="5" cellspacing="55"  rules="all"
> frame="box" style="table-layout: fixed;">
> <tr class="heading">
> <th>Site</th>
> <th>Medical Record</th>
> <th>First Name</th>
> <th>Last Name</th>
> <th>Phone</th>
> <th>Height</th>
> <th>Sex</th>
> <th>History</th>
> <th>Birthday</th>
> <th>Age</th>
>
>
>
> <?php             $i = 0;
>                  do
>                  {
>                      {
>
>                          $vara2 = array(array($Site, $MedRec, $Fname,
> $Lname, $Phone, $Height, $Sex, $Hx, $Bday, $Age));
>                          $vara2[$i][0]    = $Site;
>                          $vara2[$i][1]    = $MedRec;
>                          $vara2[$i][2]    = $Fname;
>                          $vara2[$i][3]    = $Lname;
>                          $vara2[$i][4]    = $Phone;
>                          $vara2[$i][5]    = $Height;
>                          $vara2[$i][6]    = $Sex;
>                          $vara2[$i][7]    = $Hx;
>                          $vara2[$i][8]    = $Bday;
>                          $vara2[$i][9]    = $Age;
> //                        echo "<tr>\n";
>                          $_SESSION['exe'] = 2;
> ?>
>
>
> <tr>
> <td> <?php echo $vara2[$i][0]?> </td>
> <td> <?php echo $vara2[$i][1]?> </td>
> <td> <?php echo $vara2[$i][2]?> </td>
> <td> <?php echo $vara2[$i][3]?> </td>
> <td> <?php echo $vara2[$i][4]?> </td>
> <td> <?php echo $vara2[$i][5]?> </td>
> <td> <?php echo $vara2[$i][6]?> </td>
> <td class="first-col"><?php echo $vara2[$i][7] ?></td>
> <td> <?php echo $vara2[$i][8]?> </td>
> <td> <?php echo $vara2[$i][9]?> </td>
> <?php                     echo "</tr>\n";
>                          $i = $i +1;
>                      }
>                  } while (mysqli_stmt_fetch($stmt)); //end do-while
>                      $imax = $i;
>                      echo "</table>";
>                      echo "</center>";
>                      echo "</form>";
> ?>
>
> <?php
>              }    //    end count($errors_array)
>
>
> NOTE THE ABSENCE OF the <br /> AFTER EACH <td> LINE
>
> That was the problem!!!
>
> Ethan
>
Did not notice; was not looking for them.  Of course if you knew about 
html tables you would know not to put them in there.  A little knowledge 
seems to be the root of all your bugs once again.

You really should read up on HEREDOCS in the php manual.  It will save 
you mucho amounts of typing and confusion when mixing php and html code.

Ex.

$code =<<<heredocs
<tr>
<td>$vara2[$i][0]</td>
<td>$vara2[$i][1]</td>
<td>$vara2[$i][2]</td>
<td>$vara2[$i][3]</td>
<td>$vara2[$i][4]</td>
<td>$vara2[$i][5]</td>
<td>$vara2[$i][6]</td>
<td class="first-col">$vara2[$i][7]</td>
<td>$vara2[$i][8]</td>
<td>$vara2[$i][9]</td>
</tr>
heredocs;
echo $code;

This does all that you code does with much less chafe in the code.


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.