tabular pagination

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
cali_dotcom
Forum Commoner
Posts: 49
Joined: Fri Aug 22, 2008 7:28 pm
Location: Rancho Cucamonga, CA

tabular pagination

Post 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
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: tabular pagination

Post by josh »

with html:
<td width="150">

with css:
.myTable td { width:150px; }
( in your markup: <table><tr><td class="myTableClass"> )
User avatar
papa
Forum Regular
Posts: 958
Joined: Wed Aug 27, 2008 3:36 am
Location: Sweden/Sthlm

Re: tabular pagination

Post 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.
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: tabular pagination

Post 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.
User avatar
papa
Forum Regular
Posts: 958
Joined: Wed Aug 27, 2008 3:36 am
Location: Sweden/Sthlm

Re: tabular pagination

Post by papa »

Ok my bad.
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: tabular pagination

Post 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
User avatar
papa
Forum Regular
Posts: 958
Joined: Wed Aug 27, 2008 3:36 am
Location: Sweden/Sthlm

Re: tabular pagination

Post by papa »

Appreciate the correction. I'm a little snowed in on CSS atm. :)
cali_dotcom
Forum Commoner
Posts: 49
Joined: Fri Aug 22, 2008 7:28 pm
Location: Rancho Cucamonga, CA

Re: tabular pagination

Post 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.
Post Reply