0% found this document useful (0 votes)
237 views

Hyrje Ne Programim Ne PHP-Leksion

The document discusses an introduction to PHP programming. It covers the structure of a PHP page, an exercise on building a chessboard table, adding click handlers to the chessboard, and provides an example. It includes code examples for building basic PHP pages and tables, styling the tables with CSS, and adding JavaScript click handlers.

Uploaded by

Bujar Dalipi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
237 views

Hyrje Ne Programim Ne PHP-Leksion

The document discusses an introduction to PHP programming. It covers the structure of a PHP page, an exercise on building a chessboard table, adding click handlers to the chessboard, and provides an example. It includes code examples for building basic PHP pages and tables, styling the tables with CSS, and adding JavaScript click handlers.

Uploaded by

Bujar Dalipi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Email: [email protected].

al

Leksion Nr. 4

Hyrje ne programim ne PHP


Ne kete leksion do te shohim:

o Struktura e nje faqe PHP


o Ushtrim - Ndertimi i nje tabele shahu
o Ushtrim - Te shtohet nje lokalizues ne fushen e shahut
o Shembull
Email: [email protected]

Struktura e nje faqe PHP


Per te ekzekutuar ushtrimet duhet te keni te instaluar Xmmp:

Struktura e nje faqe PHP


Shembull

hello.php

<html>
<head>
<title>Sample</title>
</head>
<body>
<table>
Email: [email protected]

<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>

Ushtrim - Ndertimi i nje tabele shahu

shahu1.php
Email: [email protected]

<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>

Ushtrim - Te shtohet nje lokalizues ne fushen e shahut


Email: [email protected]

<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>
Email: [email protected]

Shembull

test.php

<link rel="stylesheet" type="text/css" href="style.css">

<script language="JavaScript" src="logic.js"></script>

<table>

<?php

$n=100;

for($i=1;$i<=$n;$i++)

echo "

<tr onClick='tell($i);' >

<td>

$i

</td>

<td>

Artikulli $i

</td>

</tr>

";

?>

</table>
Email: [email protected]

<table>

<tr>

<td>

test table

</td>

</tr>

</table>

logic.js

// JavaScript Document

function tell(rr)

alert('Ju klikuat ne rreshtin'+rr);

style.css

/* CSS Document */

table
Email: [email protected]

width:400px;

margin:25px;

box-shadow:-5px -5px 3px #cccccc;

border-style:solid;

border-width:1px;

border-color:#cccccc;

tr:nth-child(odd)

background-color:#cccccc;

tr:nth-child(6n)

background-color:#6699cc;

You might also like