Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Table Not Making Columns

Posted on 2015-01-24
3
Medium Priority
?
83 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 31

Accepted Solution

by:
Marco Gasi earned 2000 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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
Suggested Courses

618 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