Php MysQl Search script returns blank page - php

I have written a simple page script to loop through a dynamic table that gets data from the database. But when I click on search the page returns blank with no error. I'm trying to understand what's going on without success.
display_table.php
<?php
include('session.php');
if ($_SESSION['login_user']){
include 'includes/header.php';
$searchQ = "SELECT * FROM companytable";
if(isset($_POST['search'])){
$search_term = mysqli_real_escape_string($db, $_POST['search_box']);
$searchQ .="WHERE title ='{$search_term}' ";
$searchQ .="OR country ='{$search_term}' ";
$searchQ .="OR description ='{$search_term}' ";
$searchQ .="OR timezone ='{$search_term}' ";
}
$query = mysqli_query($db, $searchQ) or die(mysqli_error());
}
form
<form class="form" name="search_form" method="POST" action="display_table.php">
<input id="search_box" style="padding: 2px;" class="" type="text" name="search_box">
<input class="btn btn-default" type="submit" name="search" value="🔍">
</form>
table
<table>
<tr>
<th>ID</th>
<th>Name</th>
<th>Description</th>
<th>Type</th>
<th>Address</th>
<th>Country</th>
<th>Time Zone</th>
</tr>
<?php while($company=mysqli_fetch_array($result)){ ?>
<tr>
<td data-th="ID"><?=$company['id'];?></a></td>
<td data-th="Name"><?=$company['title'];?></td>
<td data-th="Description"><?=$company['description'];?></td>
<td data-th="Type"><?=$company['type'];?></td>
<td data-th="Address"><?=$company['address'];?></td>
<td data-th="Country"><?=$company['country'];?></td>
<td data-th="Time Zone"><?=$company['timezone'];?></td>
</tr>
<?php };?>
</table>

You need to change
<?php while($company=mysqli_fetch_array($result)){ ?>
to reference the mysqli result you created, $query:
<?php while($company=mysqli_fetch_array($query)){ ?>

You can use object-oriented
<?php
include('session.php');
if ($_SESSION['login_user']){
include 'includes/header.php';
$query = "SELECT * FROM companytable ";
if(isset($_POST['search_box'])){
$search_term = $db->real_escape_string($_POST['search_box']);
$query.=" WHERE title ='{$search_term}'
OR country ='{$search_term}'
OR description ='{$search_term}'
OR timezone ='{$search_term}';";
}
if(!$s = $db->query($query)){
die($db->error);
}
}
Table
<table>
<tr>
<th>ID</th>
<th>Name</th>
<th>Description</th>
<th>Type</th>
<th>Address</th>
<th>Country</th>
<th>Time Zone</th>
</tr>
<?php while($m = $s->fetch_object()){ ?>
<tr>
<td data-th="ID"><?=$m->id;?></a></td>
<td data-th="Name"><?=$m->title;?></td>
<td data-th="Description"><?=$m->description;?></td>
<td data-th="Type"><?=$m->type;?></td>
<td data-th="Address"><?=$m->address;?></td>
<td data-th="Country"><?=$m->country;?></td>
<td data-th="Time Zone"><?=$m->timezone;?></td>
</tr>
<?php
};
$s->free();
?>
</table>

So turn out I decided to go with sortable.js It not only takes care of search but also takes care of sorting the rows by clicking on headers. So if you are looking for a clean fix, that would be it.
form
<form class="form" name="search_form"> <input id="search" style="" class="form-control" type="text" name="search" placeholder="🔍 Search...">
table
<table id="table" class="sortable" >
<thead style="cursor:pointer;">
<th>ID</th>
<th>Name</th>
<th>Description</th>
<th>Type</th>
<th>Address</th>
<th>Country</th>
<th>Time Zone</th>
</thead>
<tbody>
<?php while($company=mysqli_fetch_array($result)){ ?>
<tr>
<td data-th="ID" sorttable_customkey="2"><?=$company['id'];?></a></td>
<td data-th="Name"><?=$company['title'];?></td>
<td data-th="Description"><?=$company['description'];?></td>
<td data-th="Type"><?=$company['type'];?></td>
<td data-th="Address"><?=$company['address'];?></td>
<td data-th="Country"><?=$company['country'];?></td>
<td data-th="Time Zone"><?=$company['timezone'];?></td>
</tr>
<?php };?>
</tbody>
<tfoot></tfoot>
</table>
Search script
<script src="js/sorttable.js"></script> //load sortable.js
<script type="text/javascript">
var $search_rows = $('#table tr');
$('#search').keyup(function() {
var val = $.trim($(this).val()).replace(/ +/g, ' ').toLowerCase();
$search_rows.show().filter(function() {
var text = $(this).text().replace(/\s+/g, ' ').toLowerCase();
return !~text.indexOf(val);
}).hide();
});
</script>

Related

How to display mysql data in different HTML elements by using AJAX

I'm new to web development and I'm following a couple of tutorials. I'm learning that how to display mySQL data into HTML by using HTML, PHP, jQuery and AJAX. Below example is my practice work where I'm successfully loading data into HTML table.
<table id="main" border="1px" cellspacing="0">
<tr>
<td id="header">
<h1>PHP with AJAX</h1>
</td>
</tr>
<tr>
<td id="table-form">
<form id="addform">
Student First Name: <input type="text" id="st-first-name">
Student Last Name: <input type="text" id="st-last-name">
<input type="submit" value="Save Data" id="save-data"><br>
</form>
</td>
</tr>
<tr>
<td id="table-data">
<table border="1px" width="100" cellspacing="0px" cellpadding="10px">
<tr>
<th>ID</th>
<th>Name</th>
</tr>
<tr>
<td align="center">1</td>
<td>Abid Durrani </td>
</tr>
</table>
</td>
</tr>
</table>
Here is my AJAX Code.
$("document").ready(function(){
function loadData(){
$.ajax({
url: "ajaxload.php",
type: "post",
success: function(data){
$("#table-data").html(data);
}
});
} });
And this is my ajaxload.php code:
$myConn = mysqli_connect("localhost", "root", "", "test") or die("Your Connection Failed");
$sqlQuery = "select * from students";
$result = mysqli_query($myConn, $sqlQuery) or die ("Your Query Execution Failed");
$output = "";
if(mysqli_num_rows($result) > 0) {
$output = "
<table border='2' cellpadding='5px' cellspacing='5px'>
<tr>
<th width='100px'>ID</th>
<th>Name</th>
<th width='100px'>Delete</th>
</tr>";
while($row = mysqli_fetch_assoc($result)){
$output .= "
<tr>
<td>{$row['st_id']}</td>
<td>{$row['st_first_name']}</td>
<td><button class='btn-delete' data-myid={$row['st_id']}>Delete</button></td>
</tr>";
}
$output .= "</table>";
mysqli_close($myConn);
echo $output;
} else
{
echo "sorry, no record found";
}
Question: Here my data is directly loading into HTML table through its css ID. What I want is to set my database data into a textBox and a dropDownMenu along with this table. For table, I've created the table in ajaxload.php but what do I need to do for dropDownMenu and textBox?
Thanks.

particular Data not getting inserted in a column

I am facing a unknown problem while I go insert data.Some data getting inserted in same table n same column but except one.
The following is my code.
<html>
<body>
<?php
include("index.php");
?>
<form action="addcenter.php" method="post">
<table align="center" border="9" width="600">
<tr>
<td align="center" colspan="5" bgcolor="yellow">
<h1>Add Your Center Details</h1></td>
</tr>
<tr>
<th>District Name</th>
<td><input type="text" name="district"></td>
</tr>
<tr>
<th>Phone No.</th>
<td><input type="text" name="phone"></td>
</tr>
<tr>
<th>Person's Name</th>
<td><input type="text" name="person"></td>
</tr>
<tr>
<th>Designation</th>
<td><input type="text" name="designation"></td>
</tr>
<tr>
<td align="center" colspan="5"><input type="submit" name="submit"
value="submit"></td>
</tr>
</table>
</form>
<?php
include("includes/connect.php");
if(isset($_POST['submit']))
{
$district=$_POST['district'];
$phone=$_POST['phone'];
$person=$_POST['person'];
$designation=$_POST['designation'];
if($district=='' or $phone=='' or $person=='' or $designation='')
{
echo"<script> alert('Please fill the fiels')</script> ";
exit();
}
$query="insert into centers (District,Phone,ContactPerson,Designation)
values('$district','$phone','$person','$designation') ";
if(mysql_query($query))
{
echo"<center><h1>Details Successfully added to your database</h1>
</center> ";
}
}
?>
<table width=" 900" align="center" border="3">
<tr>
<td align="center" colspan="9" bgcolor="orange"><h1>View all
Centers</h1></td>
</tr>
<tr align="center">
<th>SL No.</th>
<th>District</th>
<th>Phone No</th>
<th>Contact Person</th>
<th>Designation</th>
<th>Edit</th>
<th>Delete</th>
</tr>
<?php
$query="select * from centers";
$run=mysql_query($query);
$i=1;
while($row=(mysql_fetch_array($run)))
{
$center_id=$row['center_id'];
$district=$row['District'];
$phone=$row['Phone'];
$contact_person=$row['ContactPerson'];
$designation=$row['Designation'];
?>
<tr align="center">
<td><?php echo $i++ ;?></td>
<td><?php echo $district;?></td>
<td><?php echo $phone ;?></td>
<td><?php echo $contact_person ;?></td>
<td><?php echo $designation ;?></td>
<td>Edit
</td>
<td><input type="button" onclick="deleteme1(<?php echo $center_id ?>)"
name="delete" value="Delete"></td>
</tr>
<script language="javascript">
function deleteme1(delid1)
{
if(confirm("are u sure"))
{
window.location.href='deletecenter.php?del_id1='+delid1+'';
return true;
}
}
</script>
<?php } ?>
</table>
</body>
</html>
The problem is that when I going to insert the Contactperson,district,designation and phone no.Then only the data of Contactperson,district and phone no get inserted but not the designation..I dont know why this is happening even the coding is also right..Please help me. Thankyou
Your "if" statement is assigning '' to $designation. Use '==' for comparison.
if($district=='' or $phone=='' or $person=='' or $designation**=**'')
The if statement says, "if $district is '' or $phone is '' or $person is '' or 'I can assign nothing to $designation (which always succeeds)' - at which point you have successfully assigned '' to $designation. The if statement finishes and you insert '' into designation.

php add html element inside while loop

Hello here is my code :
<table class="table table-hover table-bordered">
<tr>
<th class="well" style="text-align:center">ID</th>
<th class="well" style="text-align:center">Email</th>
<th class="well" style="text-align:center">User level</th>
</tr>';
<?
$code_sql = "SELECT user_id, user_email,user_level FROM users ORDER BY user_id ASC ";
$code_query = mysql_query($code_sql) or die(error_sql(mysql_error(),__LINE__,__FILE__));
$sql_rows = mysql_num_rows($code_query);
if($sql_rows > 0){
while($rows = mysql_fetch_object($code_query)){
$user_id = intval($rows->user_id);
$user_level= intval($rows->user_level);
$user_email = htmlspecialchars($rows->user_email);
echo ' <tr>
<td>'.$user_id.'</td>
<td>'.$user_email.'</td>
<td>'.$user_level.'</td>
</tr>';
}
mysql_free_result($code_query);
}else{
echo '<tr>
<td>
<font color="red">no data found</font>
</td>
</tr>';
}
echo '</table>';
?>
the output of the code will be like .
<table class="table table-hover table-bordered">
<tr>
<th class="well" style="text-align:center">ID</th>
<th class="well" style="text-align:center">Email</th>
<th class="well" style="text-align:center">User level</th>
</tr>
<tr>
<td>1</td>
<td>test1#gmail.com</td>
<td>1</td>
</tr>
<tr>
<td>2</td>
<td>test2#gmail.com</td>
<td>2</td>
</tr>
<tr>
<td>3</td>
<td>test3#gmail.com</td>
<td>2</td>
</tr>
<tr>
<td>4</td>
<td>test4#gmail.com</td>
<td>1</td>
</tr>
</table>
(1 = normal user , and 2 = admin for user level) but what I want is something .like that
<table class="table table-hover table-bordered">
<tr>
<th class="well" style="text-align:center">ID</th>
<th class="well" style="text-align:center">Email</th>
<th class="well" style="text-align:center">User level</th>
</tr>
<div id="users">
<tr>
<td>1</td>
<td>test1#gmail.com</td>
<td>1</td>
</tr>
<tr>
<td>4</td>
<td>test4#gmail.com</td>
<td>1</td>
</tr>
</div>
<div id="admins">
<tr>
<td>2</td>
<td>test2#gmail.com</td>
<td>2</td>
</tr>
<tr>
<td>3</td>
<td>test3#gmail.com</td>
<td>2</td>
</tr>
</div>
</table>
I want to add a div id="users" that will contain all users from database that have user_level = 1 and another div id="admins" for user_level = 2.
try the following code, you need to create div's based on conditions like if the iteration number 1 then insert div(open) before content and after content(close)...and the if iteration number is 3 then again insert the div(open) before content an after content(close)
<table class="table table-hover table-bordered">
<tr>
<th class="well" style="text-align:center">ID</th>
<th class="well" style="text-align:center">Email</th>
<th class="well" style="text-align:center">User level</th>
</tr>
<?php
$code_sql = "SELECT user_id, user_email,user_level FROM users ORDER BY user_id ASC ";
$code_query = mysql_query($code_sql) or die(error_sql(mysql_error(),__LINE__,__FILE__));
$sql_rows = mysql_num_rows($code_query);
if($sql_rows > 0){
$i=0;
while($rows = mysql_fetch_object($code_query)){
$user_id = intval($rows->user_id);
$user_level= intval($rows->user_level);
$user_email = htmlspecialchars($rows->user_email);
if($i==0){?><div id='users'><?php }elseif($i==2){?><div id='admins'><?php }
echo ' <tr>
<td>'.$user_id.'</td>
<td>'.$user_email.'</td>
<td>'.$user_level.'</td>
</tr>';
if($i==0){?></div><?php }elseif($i==2){?></div><?php }
$i++;
}
mysql_free_result($code_query);
}else{
echo '<tr>
<td>
<font color="red">no data found</font>
</td>
</tr>';
}
echo '</table>';
?>
Try the below code with tbody to group table rows,
<?php
$code_sql = "SELECT user_id, user_email,user_level FROM users ORDER BY user_level ASC, user_id ASC ";
$code_query = mysql_query($code_sql) or die(error_sql(mysql_error(),__LINE__,__FILE__));
$sql_rows = mysql_num_rows($code_query);
if($sql_rows > 0){
$newgroup = false;
$groupid = array(1=>'users', 2=>'admins');
while($rows = mysql_fetch_object($code_query)){
$user_id = intval($rows->user_id);
$user_level= intval($rows->user_level);
$user_email = htmlspecialchars($rows->user_email);
if($newgroup != $user_level) {
if($newgroup != false) echo '</tbody>';
echo '<tbody id="'.$groupid[$user_level].'">';
$newgroup = $user_level;
}
echo ' <tr>
<td>'.$user_id.'</td>
<td>'.$user_email.'</td>
<td>'.$user_level.'</td>
</tr>';
}
echo '</tbody>';
mysql_free_result($code_query);
}else{
echo '<tr>
<td>
<font color="red">no data found</font>
</td>
</tr>';
}
echo '</table>';
?>
Note:
It would work if you just want to group table rows. But if you want to add additional features like animation then you might need to add more css/jQuery.
Additional suggestions:
1. You should start using mysqli or PDO
2. You should start using css to replace font tags.

sort data from mysql table using php

Can you help me how to sort my data from MySQL table ?
I want to sort is by using the table head :
<?php
if(isset($_POST['search'])) {
$valueTosearch = $_POST['searchvalue'];
$query = "SELECT * FROM `admin` WHERE CONCAT(`id`, `name`, `gender`, `user_group`, `date_registered`) LIKE '%".$valueTosearch."%'";
$search_result = filterTable($query);
} else {
$query = "SELECT * FROM `admin`";
$search_result = filterTable($query);
}
function filterTable($query)
{
include('config/dbconnect.php');
$filter_result = mysqli_query($con, $query);
return $filter_result;
}
?>
<form method='post' action=''>
<div><input type = 'text' name = 'searchvalue' placeholder="search by name">
<span>
<div style='margin-bottom:3px; margin-top:3px'>
<input id='gradient' class='search-btn' type = 'hidden' name = 'search' value = 'search'>
</div>
</span>
<div style="height: auto">
<table id='responsive_table'>
<thead>
<tr>
<th scope="col">name</th>
<th scope="col">sex</th>
<th scope="col">user group</th>
<th scope="col">date register</th>
</tr>
</thead>
<?php while($row = mysqli_fetch_array($search_result)): ?>
<tbody>
<tr>
<td scope="row" data-label='name'><?php echo $row['name']; ?></td>
<td data-label='sex'><?php echo $row['gender']; ?></td>
<td data-label='user group'><?php echo $row['user_group']; ?></td>
<td data-label='date register'><?php echo $row['date_registered']; ?></td>
</tr>
</tbody>
<?php endwhile; ?>
</table>
</div>
</form>
Why don't you use order by clause:
SELECT * FROM table ORDER BY column;
Order By Reference
You can modified your query as below for sorting:
sql > select * from <table name> order by <column name>;
default sorting is ascending order else for descending you can do like
sql > select * from <table name> order by <column name> desc;
If you could use JQuery, it's very simple, you have just to add the following javascript code:
$( document ).ready(function() {
$("#responsive_table").DataTable({
ordering: true,
searching: true
});
});
for a complete example see the following code:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<script src="https://code.jquery.com/jquery-3.1.0.js"></script>
<script src="https://cdn.datatables.net/1.10.12/js/jquery.dataTables.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.12/css/jquery.dataTables.min.css">
<script>
$( document ).ready(function() {
$("#responsive_table").DataTable({
ordering: true,
searching: true
});
});
</script>
</head>
<body>
<form method='post' action=''>
<div style="height: auto">
<table id='responsive_table'>
<thead>
<tr>
<th scope="col">name</th>
<th scope="col">sex</th>
<th scope="col">user group</th>
<th scope="col">date register</th>
</tr>
</thead>
<tbody>
<tr>
<td scope="row" data-label='name'>HERE</td>
<td data-label='sex'>Your</td>
<td data-label='user group'>data</td>
<td data-label='date register'>loaded</td>
</tr>
<tr>
<td scope="row" data-label='name'>via</td>
<td data-label='sex'>PHP</td>
<td data-label='user group'>loop</td>
<td data-label='date register'>bye</td>
</tr>
</tbody>
</table>
</div>
</form>
</body>
</html>

i want 3 records on one page when pressing ctrl +p to print that page of a php application

<?php session_start();
require_once('SessionSet.php');
require_once('connection.php');
include('top.php');
if(isset($_GET['ClassID']) && isset($_GET['SectionId']) )
{
$ClassID = $_GET['ClassID'];
$SectionId = $_GET['SectionId'];
$ClassName = $_GET['ClassName'];
$SectionName = $_GET['SectionName'];
$GetCurrentMonth = date('M');
/* select latest Academic Year*/
$GetAcademicQ = "select * from study_year order by StudyYearId desc limit 1";
$GetAcademicQR = mysqli_query($con,$GetAcademicQ);
$GetAcademicRow = mysqli_fetch_assoc($GetAcademicQR);
$AcademciyearId = $GetAcademicRow['StudyYearId'];
$YearName = $GetAcademicRow['YearName'];
/* Get Students and Students Class + Fee Records */
$GetStudentClassQ = "select * from studentclass where
AcademicYearId='$AcademciyearId' and StudentClassId='$ClassID'
and StudentSectionId='$SectionId';";
$GetStudentClassQR = mysqli_query($con,$GetStudentClassQ);
$GetStudentClassNum = mysqli_num_rows($GetStudentClassQR);
if($GetStudentClassNum>0)
{
while($GetStudentClassRow = mysqli_fetch_assoc($GetStudentClassQR))
{
$StudentID = $GetStudentClassRow['StudentID'];
$RollNumber = $GetStudentClassRow['RollNumber'];
$RollNumber = $GetStudentClassRow['RollNumber'];
$StuentClassFee = $GetStudentClassRow['StuentClassFee'];
/* Get Stduent Name and bio data */
$GetStudentQ = "select * from students where Student_ID='$StudentID';";
$GetStudentQR = mysqli_query($con,$GetStudentQ);
$GetStudentRow = mysqli_fetch_assoc($GetStudentQR);
$Name = $GetStudentRow['Name'];
$FatherName = $GetStudentRow['FatherName'];
$StudentPhoto = $GetStudentRow['StudentPhoto'];
$Student_ID = $GetStudentRow['Student_ID'];
/* Get Stduent Name and bio data */
$GetfeeQ = "select * from fee where FeeStudentID='$StudentID';";
$GetfeeQR = mysqli_query($con,$GetfeeQ);
$GetfeeRow = mysqli_fetch_assoc($GetfeeQR);
$FeeAmount = $GetfeeRow['FeeAmount'];
$FeePaid = $GetfeeRow['FeePaid'];
?>
<div id="page-wrapper">
<div class="container-fluid">
<div class="row">
<table class="table table-hover table-bordered print-table" style="width:100% !important" align="center">
<!--Office Copy-->
<tr class="warning">
<th>Student ID</th>
<td>
<?php echo $Student_ID;?>
</td>
<th>Class</th>
<td>
<?php echo $ClassName;?>
</td>
<th>Section Name</th>
<td>
<?php echo $SectionName;?>
</td>
<th>Roll Number</th>
<td>
<?php echo $RollNumber;?>
</td>
<th>Academic Year </th>
<td>
<?php echo $YearName;?>
</td>
<!--td rowspan="5" style="text-align:center"><img src="StudentImages/<?php/* echo $StudentPhoto;*/?>"/ alt="Stdudent Image not found" style="width:150px; height:200px"></td-->
</tr>
<tr class="warning">
<th>Student Name</th>
<td colspan="4">
<?php echo $Name;?>
</td>
<th>Father Name</th>
<td colspan="4">
<?php echo $FatherName;?>
</td>
</tr>
<tr class="warning">
<th>Fee Month </th>
<td>
<?php echo $GetCurrentMonth;?>
</td>
<th>Fee Amount</th>
<td style="font-size:20px;">
<?php echo $StuentClassFee;?>
</td>
<th>Previous Dues</th>
<td style="font-size:20px;">
<?php echo $FeeAmount-$FeePaid;?>
</td>
<th>Due Date</th>
<td>12 -
<?php echo $GetCurrentMonth;?>
</td>
<th>After Due Date</th>
<td>
<?php echo $StuentClassFee+50;?>
</td>
</tr>
<hr>
<!--Student Copy-->
</table>
<table class="table table-hover table-bordered print-table" style="width:100% !important" align="center" >
<tr class="warning">
<th>Student ID</th>
<td>
<?php echo $Student_ID;?>
</td>
<th>Class</th>
<td>
<?php echo $ClassName;?>
</td>
<th>Section Name</th>
<td>
<?php echo $SectionName;?>
</td>
<th>Roll Number</th>
<td>
<?php echo $RollNumber;?>
</td>
<th>Academic Year </th>
<td>
<?php echo $YearName;?>
</td>
<!--td rowspan="5" style="text-align:center"><img src="StudentImages/<?php/* echo $StudentPhoto;*/?>"/ alt="Stdudent Image not found" style="width:150px; height:200px"></td-->
</tr>
<tr class="warning">
<th>Student Name</th>
<td>
<?php echo $Name;?>
</td>
<th>Father Name</th>
<td>
<?php echo $FatherName;?>
</td>
<th>Fee Month </th>
<td>
<?php echo $GetCurrentMonth;?>
</td>
<th>Fee Amount</th>
<td style="font-size:20px;">
<?php echo $StuentClassFee;?>
</td>
<th>Previous Dues</th>
<td style="font-size:20px;">
<?php echo $FeeAmount-$FeePaid;?>
</td>
</tr>
</table>
</div>
<!-- row end here -->
</div>
</div>
<!-- page-wrapper end here -->
<?php
}
}
else
{
}
?>
<?php
}
?>
i am building a php school management application. when I try to print report after pressing ctrl+p one recored is being shown on each page. but i want to show atleast 3 records on a single page after giving printing command. I have attached snapshots of records before and after print command.
enter image description here
here is picture after giving print command
enter image description here
Your question has nothing to do with PHP, this is a question about CSS, specifically print styles.
In the absence of an example of plain HTML and CSS, take a look at the CSS properties page-break-before, page-break-after and page-break-inside. In this case you may want to look at something like:
#media print {
.row, table {
page-break-before: avoid;
page-break-after: avoid;
}
}
Learn a little bit more about the page-break-* properties at this CSS Tricks article. If you are generally new to CSS print styles, I wrote a primer for .NET magazine.
Bear in mind that whatever styles you use, these are only suggestions to the browser. Paper size, page orientation, font size, zoom level, user margins, etc. will all work together to mess with your plans. Content that you force to be too wide for the page may also be an issue.
Finally, don't use any inline styles. Use your CSS file for that (so get rid of that width:100% inline style I saw.
If you want more help, post the raw HTML output and your CSS.

Categories