Reputation: 649
I want to arrange my list as following:
Subject Chapter MCQ Duration(min)
Physics 1 10 40 40
Chemistry 1 9 30 30
Math 1 10 40 40
Biology 1 12 40 20
So, I tried following:
<div style="font-family: "Lucida Sans Unicode"">
<?php
include_once('funcs.php');
$f = new funcs();
$res = $f->get_ques();
printf("%-'.20s", 'Subject');
printf("%-'.20s", 'Chapter');
printf("%-'.20s", 'Marks');
printf("%-'.20s", 'Duration');
?>
<br/>
<select>
<?php
while( $q = mysql_fetch_array( $res ) ) {
echo '<option>', printf("%-'-20s", $f->get_sub($q['q_id'])), printf("%-'.20s", $q['chapter']), printf("%-'.20s", $q['mcq']), printf("%-'.20s", $q['time']), '</option>';
}
?>
</select>
</div>
And my output is:
Lines are zigzag. I want these lines to be strict. I tried to use fixed length font but failed. And I should remove these dots . as well. Anyone please help me.
Upvotes: 4
Views: 105
Reputation: 7918
As such thing with different types and fonts would not possible as each character width is different from each other. There is only One way to do things required by you. In Options use Monospaced Font Courier or any other Monospaced font. I know the Courier has the same width of all characters. Just Change the font name to courier and view the required think needed by you.
Use style sheet prove the id is select and option and describe css rules as:
<select id=abc>
<option id=abc> def </option>
</select>
and in css
#abc {font-family:.......}.
The will be resolved
Upvotes: 0
Reputation: 30488
change this
echo '<option>', printf("%-'-20s", $f->get_sub($q['q_id'])), printf("%-'.20s", $q['chapter']), printf("%-'.20s", $q['mcq']), printf("%-'.20s", $q['time']), '</option>';
to
echo '<option>', printf("% / 20s", $f->get_sub($q['q_id'])), printf("% / 20s", $q['chapter']), printf("% / 20s", $q['mcq']), printf("% / 20s", $q['time']), '</option>';
use  
for space.
Upvotes: 3