Solved

Table Not Making Columns

Posted on 2015-01-24
3
63 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 30

Accepted Solution

by:
Marco Gasi earned 500 total points
Comment Utility
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
Comment Utility
Thank you!
0
 
LVL 30

Expert Comment

by:Marco Gasi
Comment Utility
Glad to help you!
Cheers
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Animate a Title 7 34
How do I edit this Drupal page? 9 27
Install bootstrap locally using Angular CLI 2 19
CSS measurement 10 11
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... …
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
In this tutorial viewers will learn how to style rounded corners for elements in CSS using the border-radius property Begin with a normal styled element such as a div: To style all four corners of the div to be the same degree of roundness, use the …

743 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