Solved

Table Not Making Columns

Posted on 2015-01-24
3
65 Views
Last Modified: 2015-01-25
This table is making one column only.  Should be six columns.  What am I doing wrong?
<style type=”text/css”>
.viewpost {
    border: 1.5px solid #367588;
    background-color: #333;
    margin-bottom:25px;
}

.viewpost1 {
    border: 1.5px solid #367588;
    background-color: #333;
    line-height:100px;
    vertical-align:top;
    margin-left:10px;
    }
</style>

Open in new window


if ($result->num_rows > 0) {
    		// output data of each row
  			echo '<table>';
    		while($row = $result->fetch_assoc()) {
        
  			if(!empty($row['recordId'])) {
      			echo '<tr class="viewpost"><td>Record ID' . $row['recordId'] . '</td></tr>';
    			}
  			if(!empty($row['recordCust'])) {
      			echo '<tr class="viewpost"><td>Customer' . $row['recordCust'] . '</td></tr>';
    			}
  			if(!empty($row['recordSite'])) {
      			echo '<tr class="viewpost1"><td>Site' . $row['recordSite'] . '</td></tr>';
   	 			}
    		if(!empty($row['recordUser'])) {
      			echo '<tr class="viewpost1"><td>User Name' . $row['recordUser'] . '</td></tr>';
   	 			}
			if(!empty($row['recordPass'])) {
      			echo '<tr class="viewpost1"><td>Password' . $row['recordPass'] . '</td></tr>';
   	 			}
			if(!empty($row['recordDateAdded'])) {
      			echo '<tr class="viewpost1"><td>Date Added' . $row['recordDateAdded'] . '</td></tr>';
   	 			}			
				}
  			echo '</table>';

Open in new window

0
Comment
Question by:DS928
  • 2
3 Comments
 
LVL 31

Accepted Solution

by:
Marco Gasi earned 500 total points
ID: 40568932
First You're closing each row after wach column so you'll always have only one column per row. econd, I think it would be better if a value is empty printing omething like 'NA'.

Your style:
		if ($result->num_rows > 0) {
    		// output data of each row
  			echo '<table>';
    		while($row = $result->fetch_assoc()) {
				echo "<tr class='viewpost'>";
  			if(!empty($row['recordId'])) {
      			echo '<td>Record ID ' . $row['recordId'] . '</td>';
    			}
  			if(!empty($row['recordCust'])) {
      			echo '<td>Customer ' . $row['recordCust'] . '</td>';
    			}
  			if(!empty($row['recordSite'])) {
      			echo '<td>Site ' . $row['recordSite'] . '</td>';
   	 			}
    		if(!empty($row['recordUser'])) {
      			echo '<td>User Name ' . $row['recordUser'] . '</td>';
   	 			}
			if(!empty($row['recordPass'])) {
      			echo '<td>Password ' . $row['recordPass'] . '</td>';
   	 			}
			if(!empty($row['recordDateAdded'])) {
      			echo '<td>Date Added ' . $row['recordDateAdded'] . '</td>';
   	 			}			
					echo "</tr>"; //closing row
				}
  			echo '</table>';

Open in new window


my suggesiton:
		if ($result->num_rows > 0) {
    		// output data of each row
  			echo '<table>';
    		while($row = $result->fetch_assoc()) {
				echo "<tr class='viewpost'>";
  			if(!empty($row['recordId'])) {
      			echo '<td>Record ID: ' . $row['recordId'] . '</td>';
    			}
					else
					{
      			echo '<td>Record ID: NA</td>';
					}
  			if(!empty($row['recordCust'])) {
      			echo '<td>Customer' . $row['recordCust'] . '</td>';
    			}
					else
					{
      			echo '<td>Customer: NA</td>';
					}
  			if(!empty($row['recordSite'])) {
      			echo '<td>Site' . $row['recordSite'] . '</td>';
   	 			}
					else
					{
      			echo '<td>Site: NA</td>';
					}
    		if(!empty($row['recordUser'])) {
      			echo '<td>User Name' . $row['recordUser'] . '</td>';
   	 			}
					else
					{
      			echo '<td>User Name: NA</td>';
					}
			if(!empty($row['recordPass'])) {
      			echo '<td>Password' . $row['recordPass'] . '</td>';
   	 			}
					else
					{
      			echo '<td>Password: NA</td>';
					}
			if(!empty($row['recordDateAdded'])) {
      			echo '<td>Date Added' . $row['recordDateAdded'] . '</td>';
   	 			}			
					else
					{
      			echo '<td>Date Added: NA</td>';
					}
					echo "</tr>"; //closing row
				}
  			echo '</table>';

Open in new window

0
 

Author Closing Comment

by:DS928
ID: 40569329
Thank you!
0
 
LVL 31

Expert Comment

by:Marco Gasi
ID: 40569330
Glad to help you!
Cheers
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

When writing CSS, there are a few simple rules that will make your life easier.    1. Using ‘* {box-sizing:border-box;}’. Using this will wrap all your elements in a nice little compact box-model that will give you the width you want, like so... …
CSS is a visual language used to classify objects and define rules about how they should be displayed. CSS skills aren’t restricted to developers anymore, there is a big benefit to having a basic understanding of the language, regardless of your occ…
In this tutorial viewers will learn how to style a decorative dropcap for the first letter in a paragraph using CSS. In CSS, create a new paragraph class by typing "p.fancy": Then, to style only the first letter of the first sentence, include the ps…
In this tutorial viewers will learn how to embed custom externally-hosted Google Fonts using the Google Font API in CSS Go to the Google Fonts website at google.com/fonts: Browse or search based on font properties or name to find a suitable font for…

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now