Click to See Complete Forum and Search --> : table problem


barantamer
07-20-2007, 10:41 AM
Hello i am having a weird problem can you help me please , my code belov is php , but my problem in it is css , if u have a look i would appreciate it...

function lastfivegames($country_id,$team_id)
{

$result=mysql_query("SELECT home_id AS h, away_id AS a, home_score AS hscr,away_score AS ascr, week_no, country_id
FROM results where
country_id = $country_id and (home_id=$team_id or away_id=$team_id)

");
echo "<table width='300' border='1' >";
$counter=0;
while($row = mysql_fetch_array($result)){
if($counter>4)
{
break;
}
$counter++;
if($row["hscr"]>$row["ascr"])
{
$baran2='relegate';
$baran1='chlig';
}
if($row["hscr"]<$row["ascr"])
{
$baran1='relegate';
$baran2='chlig';
}
if($row["hscr"]==$row["ascr"])
{
$baran1='default';
$baran2='default';

}

echo '<tr>';
echo "<td wıdth='138' align='right' class='$baran1'>";
$home=$row["h"];
$away=$row["a"];

$result2=mysql_query("select name from teams where team_id=$home");
$row2 = mysql_fetch_array($result2);

echo $row2["name"];

echo "</td>";
$result3=mysql_query("select name from teams where team_id=$away");
$row3 = mysql_fetch_array($result3);

echo "<td width='8'>";
echo $row["hscr"];
echo "</td>";

echo "<td width='8'>";
echo "-";
echo "</td>";

echo "<td width='8'>";
echo $row["ascr"];
echo "</td>";

echo "<td wıdth='138' align='left' class='$baran2'>";
echo $row3["name"];
echo "</td>";






echo "</tr>";

}
echo"</table>";
}


i will try to demonstrate my result with borders :
Stars do not exist

----------------------------------------
|**** Manisa |1|-|0|Besiktas********|
----------------------------------------
|****Trabzon|1|-|1|Manisa*********|
----------------------------------------
|**** Manisa|2|-|2|Galatasaray******|
----------------------------------------

and if i run the same function for an other team the result is

----------------------------------------
|**********Kasimpasa|0|-|0|Rize****|
----------------------------------------
|**************Rize|1|-|1|Sivas***|
----------------------------------------
|*********Fenerbahce|2|-|1|Rize ***|
----------------------------------------


Obviously i want my results centered like this

----------------------------------------
| ***** Manisa |1|-|0|Besiktas*******|
----------------------------------------
|******Trabzon|1|-|1|Manisa********|
----------------------------------------
|****** Manisa|2|-|2|Galatasaray****|
----------------------------------------

----------------------------------------
|****Kasimpasa|0|-|0|Rize**********|
----------------------------------------
|******** Rize|1|-|1|Sivas*********|
----------------------------------------
|***Fenerbahce|2|-|1|Rize**********|
----------------------------------------

Thank you for your help

ryanbutler
07-20-2007, 12:23 PM
Try assigning an ID to your table and then assigning auto margins to center the table.

HTML or PHP in your case:

<table id="mytable">
....
</table>


CSS:

table#mytable{
width:300px;
margin:0 auto;
}