DS928
asked on
Formatting PHP Table
I am trying to format a table. Everything is bunched up. I need some separation as well as the lines showing for the table. This is what I have so far.
$sql = "SELECT recordId, recordCust, recordSite, recordUser, recordPass, recordDateAdded FROM records";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo "Record" . $row["recordId"]. "Customer" . $row["recordCust"]. "Site " . $row["recordSite"]. "User" . $row["recordUser"]. "Password" . $row["recordPass"]. "Date" . $row["recordDateAdded"]."<br>";
}
} else {
echo "0 results";
}
ASKER
Ok, agreed. How do I apply a style sheet to this?
CSS works by using "selectors" to apply styling to HTML elements. You use HTML to provide semantic markup, attaching meaning to the data elements on the page. You use CSS to affect the appearance of the data elements. Learning CSS can take some time, but there are many good online and published resources. Make a Google search for "Learn CSS" and you will find many good examples. And from personal experience, I can recommend this book.
http://www.amazon.com/Book-CSS3-Developers-Future-Design/dp/1593275803/
Here's an example. See lines 8-18.
http://iconoun.com/demo/ds928.php
http://www.amazon.com/Book-CSS3-Developers-Future-Design/dp/1593275803/
Here's an example. See lines 8-18.
http://iconoun.com/demo/ds928.php
<!DOCTYPE html>
<html dir="ltr" lang="en-US">
<head>
<meta charset="utf-8" />
<meta name="robots" content="noindex, nofollow" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style type="text/css">
body {
background-color:yellow;
}
#vibrant {
color:red;
}
.stuff {
padding-left:4em;
}
</style>
<title>HTML5 Page With CSS</title>
</head>
<body>
<h2 id="vibrant">Here are some data fields styled with CSS <i>padding</i></h2>
<span class="stuff">Field 1</span>
<span class="stuff">Field 2</span>
<span class="stuff">Field 3</span>
</body>
</html>
ASKER
I have this but it did not work.
<style type=”text/css”>
table {
margin: 8px;
}
th {
font-family: Arial, Helvetica, sans-serif;
font-size: .7em;
background: #666;
color: #FFF;
padding: 2px 6px;
border-collapse: separate;
border: 1px solid #000;
}
td {
font-family: Arial, Helvetica, sans-serif;
font-size: .7em;
border: 1px solid #DDD;
}
</style>
$sql = "SELECT recordId, recordCust, recordSite, recordUser, recordPass, recordDateAdded FROM records";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo "<table>";
echo "Record" . $row["recordId"]. "Customer" . $row["recordCust"]. "Site" . $row["recordSite"]. "User" . $row["recordUser"]. "Password" . $row["recordPass"]. "Date" . $row["recordDateAdded"]."<br>";
}
} else {
echo "0 results";
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Cd&