PDA

View Full Version : automatic expanding <td>


ali_b
07-12-2007, 11:07 AM
hey,

i have made a menu using php and mysql and just now it looks like this:



Starters
Starter 1 3.90
Starter 2 4.80

but i want it to look like this:

Starter 1................................................. .......................3.90
Starter 2................................................. .......................4.80


just now i have just put full stops in the blank <td> but because i do that if the starters name is too long it goes onto two lines so i would like the <td> with the dots to automatically fill up the space so that the table is the width of the container..
but i dont no how to do this :(

cheers

ali

davidj
07-12-2007, 01:39 PM
you could do this dynamically but its going to add work

you would first have to measure the length of every string then using nested loops you would have to concat ..(dots) to the end of the variable

the easier option is to use a table and design a background with dots to the middle cell. Make the image larger than the cell

the middle cell will retract and expand accordingly exposing more of the dot graphic.

if you want to do this dynamicaly your going to have to write a dot function. Let me know if this is what you want and we will tackle it together

ali_b
07-12-2007, 02:10 PM
i think im going to have to do the background technique because im nearly the deadline for this project.

just now i have:

<?php do { ?>
<tr>
<td width="13%"><?php echo $starter['food_menu'];?></td>
<td width="81%"></td>
<td width="6%"><?php echo $starter['price'];?></td>
</tr>
<?php } while ($starter = @mysql_fetch_array($result1)); ?>

should i take out the widths completley so it does it automatically?

davidj
07-12-2007, 02:15 PM
it will always expand to the longest width <td>

personaly i would have the same amount of dots in the middle cell and i would fix the dimensions. I wouldnt bother with being too clever with this.

keep it simple

ali_b
07-12-2007, 04:54 PM
cheers, i got it working, to stop the food name going onto another like i just put in a nowrap thing

cheers,

ali