Wednesday, 15 June 2011

php - Fixed table height with 4 cells inside (no scroll bars) & assigning text to each cell -



php - Fixed table height with 4 cells inside (no scroll bars) & assigning text to each cell -

i need generate table (html/css) 4 cells within (think 4 boxes 1 on top of another). have 2 questions-

how can prepare width , height of each box (they may have different heights) without no scroll bars if text overflows. if text overflow, cell height (& width) must remain same size , hide overflowing text.

using php (no frameworks) populate these 4 cells 4 different strings in database. how can assign text each 1 of 4 cells? e.g. $string[1] cell#1, $string[2] goes cell#2 etc. thankyou.

here html/php generates table (in calandar)

<table width="700" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#000000"> ' <tr>' <td><table width="100%" border="0" cellpadding="0" cellspacing="1">' ($i = 1; $i <= $days_in_month; $i++) {' echo "<td width=\"100\" height=\"100\" class=\"$class\">\n"; echo "<div align=\"right\"><span class=\"daynumber\">$i</span></div>\n";' // maintain count of cells across row, , if=7 end row , start 1 time again ' }'

etc. (my calendar code works well, unlike futile attempts format code here)

i store "events" in mysql db, , when i=date in db, output text. complex bit trying set 4 different event "data" corresponding boxes (see q2 above).

to prepare width , height , stop overflowing can utilize css class.

.something{ width: 200px; height : 100px; overflow : hidden; }

and can limit text length using php substr() function

$limitedtext = substr($yourstring, 0, 100);

to have utilize foreach or while loop

foreach($queryresult $rs){ echo "$rs['stringone']"; echo "$rs['stringtwo']"; echo "$rs['stringthree']"; echo "$rs['stringfour']"; }

php html mysql css

No comments:

Post a Comment