hey folks,
i m developing a page. and in td’s i got php dynamic queries being called on execution. but if i set those td’s width according to the th, its not the same. this got me confused that if php valuing printing inside a td has some default values with are being printed in td. or something like that. can someone untangle my confusion?
the div is used for scrolling the result in table. and the table details is dynamically created on click event. however if i remove the colspan 7. which is my case is dumbest thing ever. i think should it fix the problem?
If you want to align the colums of the tables head and tables body, you really need to get rid of the embedded table…
consider this table:
<table>
<thead>
<tr>
<th class="part">Part No</th>
<th class="desc">Description</th>
<th class="mfc">Manufacturer</th>
<th class="unit">Unit Price</th>
<th class="qty">Qty.</th>
<th class="qty">Qty.<br /> Approved</th>
<th class="total">Total Price</th>
</tr>
</thead>
<tbody style="overflow:auto; height:200px;">
<tr>
<td>Part No</td>
<td>Description</td>
<td>Manufacturer</td>
<td>Unit Price</td>
<td>Qty.</td>
<td>Qty.<br /> Approved</td>
<td>Total Price</td>
</tr>
</tbody>
</table>
Ah ok, that is one of 2 parts. coz i want a scrolling tbody. so i will work around the second part. thanks though for the help btw still i didn’t get why wasn’t i getting the width’s as defined for th in td?
Could be that the embedded table have a width of 1020…
if the classes define the width in %, and the outer table have no widht the widths will be based on different overall widths.
You could try to remove the widht attribute in the embedded table…
Well, you missed some of the code… but lets try any way.
Start by fixing the <th></td> error on the last th column.
Next, the result from the database is placed in a new table within a single td (spanning 7 rows), thats why the columns doesnt match the headers.
remove these 4 lines after the first </tr>
<tr>
<td colspan="7">
<div style="overflow:auto; height:200px;">
<table id="details" width="1020" >
There are probably some closing tags associated, which also needs to be removed.
Could you post the raw html here?
It’s much easier to help, when some code is present.
There’s no difference between outputting text from the database, and writing it directly in the td/th.
i been given some raw html, and to fix width’s and the html is so crazy and not validation and the width’s are not being equalized as same of the th’s.could it be because inside td there is input type set to text and inside that are values being echoed. coz i set the same class as i set for th’s but they don’t seem to line up
here
<th class="part">Part No</th>
<th class="desc">Description</th>
<th class="mfc">Manufacturer</th>
<th class="unit">Unit Price</th>
<th class="qty">Qty.</th>
<th class="qty">Qty.<br /> Approved</th>
<th class="total">Total Price</td>
</tr>
<tr>
<td colspan="7">
<div style="overflow:auto; height:200px;">
<table id="details" width="1020" >
<?php
$query="select p.part_num,p.part_desc,m.manu_name,p.part_price,d.quantity,d.total_price,d.desc_id_pk,d.quantity_approved from cat_parts p,cat_manufacturer m,po_details d where p.manu_id_fk=m.manu_id(+)
and p.part_id_pk=d.part_id_fk and d.po_id_fk='$poid' ";
$cursor = OCIParse ( $connection, $query);
$result=ociexecute($cursor);
while(ocifetchinto($cursor,$values))
{
?>
<tr>
<td>
<!--<select name="ddlParts[]" id="ddlParts[]" onchange="populateParts(this,1);" class="txtfield" style="width:6.5em">
<option value="0">Select Part</option>
<?php //CreateAjaxParts($values[0]);?>
</select>-->
<?php echo $values[0];?>
<input type="hidden" value="<?php echo $values[6];?>" name="hidDescId[]"/>
<input type="hidden" value="<?php echo $editable;?>" name="hidEditable" />
</td>
<td><?php echo $values[1];?></td>
<td><?php echo $values[2];?></td>
<td><input type="text" name="txtUnit[]" value="<?php echo $values[3];?>" size="7" readonly="readonly"/></td>
<td><?php if($editable){echo $values[4];}else {?><input type="text" name="txtQuantity[]" id="txtQuantity" onkeyup="populate(1);" value="<?php echo $values[4];?>" /><?php }?></td>
<td><?php if(!$editable){echo $values[7];}else {?><input type="text" size="7" name="txtQuantityApproved[]" id="txtQuantityApproved" onkeyup="populate(2);" value="<?php echo $values[7];?>" /><?php }?></td>
<td><input type="text" name="txtTotal[]" id="txtTotal[]" size="10" readonly="readonly" value="<?php echo $values[5];?>" /></td>
</tr>
<?php
}
?>
</table>
whereas, the classes in th has width’s set respectively, but when i give same class to td in which dynamic data is displayed. they are of different width. its very troublesome to work on dumb people who don’t know anything about html and still do experiment with it and when fails they give u to fix it.
what i wanna say is that suppose we are having a we have
<table width="200">
<tr>
<td width="200">Hello world</td>
</td>
</tr>
</table
that is static text but suppose we are printing a statment out of database within that td. the values between the td’s are called from database. will its width be equal to a width defined in td or if text is more or less. the width will wrap around it?
I don’t understand your question very well, but you could assume this:
<th style="width: 100%">
<td style="width: 25%;">item</td>
<td style="width: 50%;">desc</td>
<td style="width: 25%;">item</td>
</th>
And even if you do this, it will assume the TD % of the TH % of the Page
<th style="width: 50%">
<td style="width: 25%;">item</td>
<td style="width: 50%;">desc</td>
<td style="width: 25%;">item</td>
</th>