-2

I was wondering if anyone can tell me how I can style the results which are outputted onto my php page from the database.

<!doctype html>
<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <link href="css/style.css" rel="stylesheet" type="text/css" />
    <link href="css/reset.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="container2">

<div id="adminpanel">Admin Page 

<div id="showorders"><u>Orders</u></div>

<?php
session_start();
include('connection.php');

$result = mysql_query("SELECT * FROM orderform");
while($row = mysql_fetch_array($result))
  {
  echo $row['product'] . " " . $row['productcomments'] . " " . $row['name'] . " " . $row['address'] . " " . $row['age'] . " " . $row['delivery'] ;
  echo "<br>";
  }
?>


<div id="showreviews"><u>Reviews</u></div>

<?php


$result = mysql_query("SELECT * FROM reviewform");
while($row = mysql_fetch_array($result))
  {
  echo $row['name'] . " " . $row['product'] . " " . $row['comment']  ;
  echo "<br>";
  }
?>




</div>

Update coded at 12.37. Need to get rid of an error in orders div

JBuss
  • 43
  • 6
  • Wrap them in a div with a specific id / class and style them using CSS? – Amal Murali Mar 17 '14 at 12:29
  • 1
    You probably need to add some HTML Markups, first. – Hector Ordonez Mar 17 '14 at 12:29
  • I have wrapped them in divs and added my HTML markup and get this error before my results. Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /web/users/l1071039/bobbin/admin.php:16) in /web/users/l1071039/bobbin/admin.php on line 17 – JBuss Mar 17 '14 at 12:36
  • Updated php code can be seen above. Thank you – JBuss Mar 17 '14 at 12:38
  • For the `headers already sent` error - please have a read of this - http://stackoverflow.com/questions/8028957/how-to-fix-headers-already-sent-error-in-php – Nick R Mar 17 '14 at 12:44
  • The error you posted is nothing to do with wrapping them in divs. It's because you've outputted text before you are starting the session. `session_start();` should be right at the top of the page – andy Mar 17 '14 at 12:45

1 Answers1

0

Try something like this:

<?php
session_start();
include('connection.php');

$resultOrder = mysql_query("SELECT * FROM orderform");
while($row = mysql_fetch_array($result))
{
echo "<span style='color: #333; width: 200px; height: 200px; padding: 5px; border: 1px solid #ff9900;'>" . $row['product'] . " " . $row['productcomments'] . " " . $row['name'] . " " .       $row['address'] . " " . $row['age'] . " " . $row['delivery'] . "</span>" ;
echo "<br>";
}


$resultReview = mysql_query("SELECT * FROM reviewform");
while($row = mysql_fetch_array($result))
{
echo "<span style='color: #333; width: 200px; height: 200px; padding: 5px; margin-bottom: 20px; border: 1px solid #ff9900;'>" $row['name'] . " " . $row['product'] . " " . $row['comment'] . "</span>" ;
echo "<br>";
}
?>

Really you should be styling your boxes in your primary style sheet and just giving these a DIV ID or CLASS.

DanDotNet
  • 157
  • 5