16-05-2007, 21:50
|
|
|
חבר מתאריך: 17.05.05
הודעות: 7,321
|
|
אם אתה רוצה, לפני הרבה זמן כתבתי קוד ליצירת טבלה עם כל מיני אפשרויות...כתבתי שם הרבה חירטוטים אבל אני בטוח שתצליח לסדר ולהתאים את זה למה שאתה צריך בדיוק.
בעיקרון זה עובד טוב מבחינת ה-tr,td.
הקוד:
קוד PHP:
// tables_maker()
// This nice function creates & returns HTML ready tables
// By DCD
function tables_maker($cells, $info=array())
{
$html_it = ""; $times = 0; $sum = 0; $overall = count($cells);
if ($info['cells_per_row'] > 0)
{ $info['cells_per_row'] = $info['cells_per_row']; }
else
{ $info['cells_per_row'] = 4; }
foreach ($cells as $value)
{
$times = $times + 1;
if ( ($times / $info['cells_per_row']) != ($sum) AND ($times / $overall) != 1 AND $times != 1)
{
$html_it .= "<td {$info['css']} style='{$info['style']}' {$info['nowrap']}>".$value."</td>";
}
else
{
if ($times == 1)
{
$html_it .= "<tr><td {$info['css']} style='{$info['style']}' {$info['nowrap']}>".$value."</td>";
}
else if (($times / $overall) == 1 OR ($times/($sum))==$info['cells_per_row'] OR $times==$info['cells_per_row'])
{
$html_it .= "<td {$info['css']} style='{$info['style']}' {$info['nowrap']}>".$value."</td></tr>";
}
else
{
$html_it .= "</tr><tr><td {$info['css']} style='{$info['style']}' {$info['nowrap']}>".$value."</td>";
}
$sum = $sum + 1;
}
}
return $html_it;
}
אין צורך לשמור זכויות
|