xenoula
asked on
Display results into 2 columns of 6 rows
Hello,
I have created a website which takes information from the database and displays the results in the web page.The table that takes that information is called jobs. The problem I have is with the layout of the results.I would like to dipslay the results into two columns of 6 rows.The tricky thing is that I want for every job to print in one row the title and in the second the other information for the specific job.An example of the layout is the following.
Customer Care Customer Care
£16K REF.:IMU0121 More Info £16K REF.:IMU0121 More Info
Sales Executive Sales Executive
£35k REF.:KTJ0140 More Info £35k REF.:KTJ0140 More Info
Customer Care Customer Care
£16K REF.:IMU0121 More Info £16K REF.:IMU0121 More Info
Sales Executive Sales Executive
£35k REF.:KTJ0140 More Info £35k REF.:KTJ0140 More Info
Sales Executive Sales Executive
£35k REF.:KTJ0140 More Info £35k REF.:KTJ0140 More Info
Sales Executive Sales Executive
£35k REF.:KTJ0140 More Info £35k REF.:KTJ0140 More Info
I would really appreciate if somebody could help me do the alrgorithm and how the code will be to diaply the correct layout
Thank you in advance,
Xenia
I have created a website which takes information from the database and displays the results in the web page.The table that takes that information is called jobs. The problem I have is with the layout of the results.I would like to dipslay the results into two columns of 6 rows.The tricky thing is that I want for every job to print in one row the title and in the second the other information for the specific job.An example of the layout is the following.
Customer Care Customer Care
£16K REF.:IMU0121 More Info £16K REF.:IMU0121 More Info
Sales Executive Sales Executive
£35k REF.:KTJ0140 More Info £35k REF.:KTJ0140 More Info
Customer Care Customer Care
£16K REF.:IMU0121 More Info £16K REF.:IMU0121 More Info
Sales Executive Sales Executive
£35k REF.:KTJ0140 More Info £35k REF.:KTJ0140 More Info
Sales Executive Sales Executive
£35k REF.:KTJ0140 More Info £35k REF.:KTJ0140 More Info
Sales Executive Sales Executive
£35k REF.:KTJ0140 More Info £35k REF.:KTJ0140 More Info
I would really appreciate if somebody could help me do the alrgorithm and how the code will be to diaply the correct layout
Thank you in advance,
Xenia
ASKER
Roonaan it is exacly what I wanted to do thank you very much.
However, i would like to ask you some questions regarding the code in order to understand how it is working.
What is the container, it is an element of CSS?
Where exacly in the code I assign that when the rows are 6 then go to the next column?
Moreover, how I can change the format of the tabel,for example after the title not to have so many cab.
Thank you very much,
Xenia
However, i would like to ask you some questions regarding the code in order to understand how it is working.
What is the container, it is an element of CSS?
Where exacly in the code I assign that when the rows are 6 then go to the next column?
Moreover, how I can change the format of the tabel,for example after the title not to have so many cab.
Thank you very much,
Xenia
The container is the <div style="width:610px;">
But actually , I think the code isn't what you where after, afterall. This code can only do the columns easily, not the next-col-after-6-rows.
But do you expect to have more than 12 elements actually?
-r-
But actually , I think the code isn't what you where after, afterall. This code can only do the columns easily, not the next-col-after-6-rows.
But do you expect to have more than 12 elements actually?
-r-
ASKER
I want to display 6 jobs in one column and 6 jobs in the second column.
Totally will be 12 jobs.I test it and is working.It displays the latest 12 jobs as I wanted.
Every time it will display 12 jobs only no more
Totally will be 12 jobs.I test it and is working.It displays the latest 12 jobs as I wanted.
Every time it will display 12 jobs only no more
In current setup it shows indeed 6x2 table, but the ordering is
1 2
3 4
5 6
Whereas in your question the ordering should be as below, shouldn't it?
1 4
2 5
3 6
-r-
1 2
3 4
5 6
Whereas in your question the ordering should be as below, shouldn't it?
1 4
2 5
3 6
-r-
ASKER
Yes you are right and I just realise now that it printd 7 and 8 rows it doen't display only 6 rows in every column.
ASKER
So please if you could help me to add a code in order to display 6 jobs in one column and 6 jobs to the second column,
I would be very gretfull.
Thank you,
Xenia
I would be very gretfull.
Thank you,
Xenia
Your query should be like:
$query = 'SELECT .... FROM table WHERE .... LIMIT 12';
Then have:
<div style="width:300px;float:l eft">
<?php
$i = 0;
while($i++ < 6 && $row=mysql_fetch_assoc()) {
//output table
}
?>
</div>
<div style="float:left;">
<?php
while($row=mysql_fetch_ass oc()) {
//output table
}
?>
</div>
<div style="clear:both;">
-r-
$query = 'SELECT .... FROM table WHERE .... LIMIT 12';
Then have:
<div style="width:300px;float:l
<?php
$i = 0;
while($i++ < 6 && $row=mysql_fetch_assoc()) {
//output table
}
?>
</div>
<div style="float:left;">
<?php
while($row=mysql_fetch_ass
//output table
}
?>
</div>
<div style="clear:both;">
-r-
ASKER
Actually I add a code in the exiting code and is working now ,it diplays in 6 rows:
<div id="container" style="width:610px;">
<?php
$result = mysql_query('Select * from Jobs ORDER BY job_reference DESC');
while($row = mysql_fetch_assoc($result) ) {
if ($_i > 0 && $_i % 2 == 0 && $_i<=12) {
echo "</TR>\n<TR>";
}if ($_i<12){
$titleCell = htmlspecialchars($row['job _title']);
$leftCell = '£'.htmlspecialchars ($row['sal ary']);
$midCell = 'REF.:'.htmlspecialchars($ row['ref'] );
$rightCell = '<a href="more_info.php?job_re ference='. $row['job_ reference' ].'" target="name" onclick="window.open("more _info.php" ,"name","h eight=255,
width=250,toolbar=no,direc tories=no, status=no,
menubar=no,scrollbars=no,r esizable=n o"); return false;" class="moreinfotext" target="_blank">More info</a>';
?>
<table border="0" width="258" height="18" cellpadding="0" cellspacing="0" style="width:300px;height: 30px;float :left;">
<tr>
<td height="19" colspan="3" align="left" class="navitextjobsbld"><? =$titleCel l;?></td>
</tr>
<tr>
<td width="54" class="navitextjobs" ><?=$leftCell;?> </td >
<td width="54" class="navitextjobs" ><?=$midCell;?> </td>
<td width="150" class="navitextjobs" ><?=$rightCell;?></td>
</tr>
<tr><td><img src="images/spacer.jpg" height="9px"></td></tr>
</table>
<?php
} $_i++;}
?>
<div style="clear:both;"></div>
</div>
what I wanted to ask you if I want to descrase the gap between the first colum of the jobs with the second.
How I can do that?
<div id="container" style="width:610px;">
<?php
$result = mysql_query('Select * from Jobs ORDER BY job_reference DESC');
while($row = mysql_fetch_assoc($result)
if ($_i > 0 && $_i % 2 == 0 && $_i<=12) {
echo "</TR>\n<TR>";
}if ($_i<12){
$titleCell = htmlspecialchars($row['job
$leftCell = '£'.htmlspecialchars
$midCell = 'REF.:'.htmlspecialchars($
$rightCell = '<a href="more_info.php?job_re
width=250,toolbar=no,direc
menubar=no,scrollbars=no,r
?>
<table border="0" width="258" height="18" cellpadding="0" cellspacing="0" style="width:300px;height:
<tr>
<td height="19" colspan="3" align="left" class="navitextjobsbld"><?
</tr>
<tr>
<td width="54" class="navitextjobs" ><?=$leftCell;?> </td
<td width="54" class="navitextjobs" ><?=$midCell;?> </td>
<td width="150" class="navitextjobs" ><?=$rightCell;?></td>
</tr>
<tr><td><img src="images/spacer.jpg" height="9px"></td></tr>
</table>
<?php
} $_i++;}
?>
<div style="clear:both;"></div>
</div>
what I wanted to ask you if I want to descrase the gap between the first colum of the jobs with the second.
How I can do that?
ASKER
The gap that I want to decrease is between the column of the jobs like the following example:
Customer Care Customer Care
£16K REF.:IMU0121 More Info £16K REF.:IMU0121 More Info
Instead of the bigger gap as the following:
Sales Executive Sales Executive
£35k REF.:KTJ0140 More Info £35k REF.:KTJ0140 More Info
Customer Care Customer Care
£16K REF.:IMU0121 More Info £16K REF.:IMU0121 More Info
Instead of the bigger gap as the following:
Sales Executive Sales Executive
£35k REF.:KTJ0140 More Info £35k REF.:KTJ0140 More Info
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Yes you were right
Have a container with a certain width. Then have each table float left inside that container. By adjusting the width of the container and the inner tables you can create as many columns as you like.
By setting the container to width:auto; you can even have a variable amount of columns based on screen width.
<div id="container" style="width:610px;">
<?php
$result = mysql_query('SELLECT ID, Name, Price, Ref FROM table');
while($row = mysql_fetch_assoc($result)
$titleCell = htmlspecialchars($row['Nam
$leftCell = '£'.htmlspecialchars
$midCell = htmlspecialchars($row['Ref
$rightCell = '<a href="moreinfo.php?id='.$r
?>
<table style="width:300px;height:
<tr><th colspan="3"><?=$titleCell;
<tr><td><?=$leftCell;?></t
</table>
<?php
}
?>
<div style="clear:both;"></div>
</div>
-r-