Page 1 of 1

tabular pagination

Posted: Tue Sep 30, 2008 9:01 pm
by cali_dotcom
hi,
im a php newbie and i need some help with tabluar pagination. i want to display the results of my query in a table. i actually came up with this code:

Code: Select all

 
while   ($row = mysql_fetch_assoc($result)){
    $job_id = $row['job_id'];
    $job_title = $row['job_title'];
    $post_date = $row['post_date'];
    
    echo "<table border='1'>";
    echo "<TR>";
    echo "<TH>  </TH><TH><STRONG>Job Title</STRONG></TH><TH><STRONG>Post date</STRONG></TH>";
    echo "</TR>";
    
    //the link of the job title is given, when the user clicks on it, we issue another querry
    echo "<TR>";
    echo "<TD>";
    echo "<form METHOD='POST' ACTION='deletejob.php>";///check box to delete job from database
    echo "<input type='CHECKBOX' name='job_id'>";
    echo "<input type='submit' value='delete'>";
    echo "</form></TD>";
    echo "<TD><a href=jobinfo.php?job_id=".$job_id.">$job_title</a></TD>";
    
    
    
    
    echo "<TD>$post_date</TD>";
    echo "</TR>";
    echo "</table>";
} 
 
this is a part of the greater code. it works, but not quite well. the problem is that the resulting table is not uniform. each cell in the table is just as wide as it needs to be to fit the contents of $job_title for example.
what can i do to create a uniform table where the contents of each cell would have to wrap to fit the table cell?
can anyone also help me with pagination?
examples, suggestions and resources would be kindly appreciated.
thankx

Re: tabular pagination

Posted: Tue Sep 30, 2008 10:20 pm
by josh
with html:
<td width="150">

with css:
.myTable td { width:150px; }
( in your markup: <table><tr><td class="myTableClass"> )

Re: tabular pagination

Posted: Wed Oct 01, 2008 3:20 am
by papa
Also look in the HTML and CSS section here: http://www.w3schools.com/

<STRONG> is not very good to use for example.

Also you can make a general make up for your table with css as mentioned above and then just add classes for other kinds of table.

For example a general make up for your th headers.

Code: Select all

/*
TABLE
*/
 
table { 
    width: 95%;
    margin-bottom: 2em;
}
td {
    color: #000000; 
    font-family: verdana, geneva; 
    font-size: 10px; 
    padding: 2px;
    text-align: left;
}
 
th {
    color: #000000; 
    font-family: verdana, geneva; 
    font-size: 10px; 
    font-weight:bold; 
    letter-spacing: 1px; 
    background-color: #dcdcdc;
    padding: 2px;
}
Just as an example. So you only have to add the class attribute to those tables that doesn't look like your template.

Re: tabular pagination

Posted: Wed Oct 01, 2008 6:22 am
by josh
papa wrote:<STRONG> is not very good to use for example.
Incorrect, there is nothing wrong about using any HTML tag semantically, he's using it perfectly fine. It is redundant in terms of styling in the sense that it could be handled by CSS, but maybe he wants to add semantic importance to those fields. Search engines, screen readers, text / mobile browsers and other browser clients may treat different tags differently and ignore stylesheets for the most part. Hes creating his document how it semantically makes sense to him.

Re: tabular pagination

Posted: Wed Oct 01, 2008 6:46 am
by papa
Ok my bad.

Re: tabular pagination

Posted: Wed Oct 01, 2008 7:02 am
by josh
Adding the class is a lot easier, you were only trying to point out a better way, kudos for that.. I just didn't want him worrying about his <strong> tag as thats the least of his worries right now hah

Re: tabular pagination

Posted: Wed Oct 01, 2008 7:19 am
by papa
Appreciate the correction. I'm a little snowed in on CSS atm. :)

Re: tabular pagination

Posted: Thu Oct 02, 2008 5:24 pm
by cali_dotcom
thankx alot guys, i tried the html solution and it worked and i guess the css solution would work too.
thankx again.