Programimi ne server side
Gjuha PHP
<html>
<head>
<title>Sample</title>
</head>
<body>
<table>
<thead>
<tr>
<th>Nr</th>
<th>Artikulli</th>
</tr>
</thead>
<tbody>
<?php
for($i=1;$i<7;$i++)
{
?>
<tr>
<td><?php echo $i; ?></td>
<td><h<?php echo $i; ?>>Artikulli <?php echo $i ?><?php echo '</h'.$i ?>></td>
</tr>
<?php
}
?>
</tbody>
</table>
</body>
</html>
Te nderojme nje faqe ne php qe gjeneron nje tabele shahu ne dimensione 8*8.
<html>
<head>
<title>Tabele Shahu</title>
</head>
<body>
<table border="1" width="400">
<?php
for($i=1;$i<=8;$i++)
{
?>
<tr>
<?php
for($j=1;$j<=8;$j++)
{
?>
<td height="50"
<?php
if((($i+$j)%2)==0)
{
echo 'bgColor="brown" ';
}
else
{
echo 'bgColor="white" ';
}
?>
>
</td>
<?php
}
?>
</tr>
<?php
}
?>
</table>
</body>
</html>
Te shtohet nje lokalizues ne tabelen e shahut
<html>
<head>
<title>Tabele Shahu</title>
<script language="JavaScript">
function tell(x,y)
{
alert('Ju keni klikuar ne kutine '+x+','+y);
}
</script>
</head>
<body>
<table border="1" width="400">
<?php
for($i=1;$i<=8;$i++)
{
?>
<tr>
<?php
for($j=1;$j<=8;$j++)
{
?>
<td height="50" onClick="tell(<?php echo $i; ?>,<?php echo $j; ?>);"
<?php
if((($i+$j)%2)==0)
{
echo 'bgColor="brown" ';
}
else
{
echo 'bgColor="white" ';
}
?>
>
</td>
<?php
}
?>
</tr>
<?php
}
?>
</table>
</body>
</html>
Detyre
Ndertoni nje tabele me 8 rreshta me nje kollone.
Nese perdoruesi klikon mbi njerin nga rreshtat atehere ne
nje zone te faqes poshte tabeles shfaqet teksti:
"Ky eshte rreshti x".