?
Solved

Table Not Making Columns

Posted on 2015-01-24
3
Medium Priority
?
86 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 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The first step to building an amazing About page is to figure out what you want the page to say about your company. You then must grab the attention of the reader, boast a bit, tell a story and let others brag about you. With a little bit of thought…
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses
Course of the Month16 days, 12 hours left to enroll

862 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