če imaš recimo index.php?nekajdrugega potem moraš malo spremenit ane..
if(isset($_GET['nekajdrugega'])) {
//...
} elseif(isset($_GET['nekajtretjega'])) {
//...
} else ....ni variante da ne deluje :ok:
Objavljeno 23 marec 2008 - 18:25
<html> <head> <!-- anketa.html --> <script src="anketa.js"></script> </head> <body> <div id="poll"> <h2>Vprašanje</h2> <form> Ja: <input type="radio" name="vote" value="0" onclick="getVote(this.value)"> <br />Ne: <input type="radio" name="vote" value="1" onclick="getVote(this.value)"> </form> </div> </body> </html>
// anketa.js
var xmlHttp
function getVote(int)
{
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request")
return
}
var url="poll_vote.php"
url=url+"?vote="+int
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=stateChanged
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}
function stateChanged()
{
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
document.getElementById("poll").
innerHTML=xmlHttp.responseText;
}
}
function GetXmlHttpObject()
{
var objXMLHttp=null
if (window.XMLHttpRequest)
{
objXMLHttp=new XMLHttpRequest()
}
else if (window.ActiveXObject)
{
objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
}
return objXMLHttp
}<?php
// poll_vote.php
$vote = $_REQUEST['vote'];
//get content of textfile
$filename = "poll_result.txt";
$content = file($filename);
//put content in array
$array = explode("||", $content[0]);
$yes = $array[0];
$no = $array[1];
if ($vote == 0)
{
$yes = $yes + 1;
}
if ($vote == 1)
{
$no = $no + 1;
}
//insert votes to txt file
$insertvote = $yes."||".$no;
$fp = fopen($filename,"w");
fputs($fp,$insertvote);
fclose($fp);
?>
<h2>Rezultati:</h2>
<table>
<tr>
<td>Ja:</td>
<td>
<img src="poll.gif"
width='<?php echo(100*round($yes/($no+$yes),2)); ?>'
height='20'>
<?php echo(100*round($yes/($no+$yes),2)); ?>%
</td>
</tr>
<tr>
<td>Ne:</td>
<td>
<img src="poll.gif"
width='<?php echo(100*round($no/($no+$yes),2)); ?>'
height='20'>
<?php echo(100*round($no/($no+$yes),2)); ?>%
</td>
</tr>
</table>0||0
Objavljeno 24 marec 2008 - 23:42
Objavljeno 18 april 2008 - 13:30
function getList(){
$fileList = array();
// Open the actual directory
if ($handle = opendir("test")) {
// Read all file from the actual directory
while ($file = readdir($handle)) {
if (!is_dir($file)) {
$fileList[] = $file;
}
}
}
rsort ($fileList);
return $fileList;
}<?php
$list = getList();
foreach ($list as $value) {
$newsData = file("news/".$value);
$newsTitle = $newsData[0];
$submitDate = $newsData[1];
unset ($newsData['0']);
unset ($newsData['1']);
$newsContent = "";
foreach ($newsData as $value) {
$newsContent .= $value;
echo "<tr><th align='left'>$newsTitle</th><th align='right'>$submitDate</th></tr>";
echo "<tr><td colspan='2'>".$newsContent."<br/><hr size='1'/></td></tr>";
}
?>Objavljeno 18 april 2008 - 14:29
<?php
$list = getList();
$x = 1;
foreach ($list as $value) {
if (x > 5) break;
$newsData = file("news/".$value);
$newsTitle = $newsData[0];
$submitDate = $newsData[1];
unset ($newsData['0']);
unset ($newsData['1']);
$newsContent = "";
foreach ($newsData as $value) {
$newsContent .= $value;
echo "<tr><th align='left'>$newsTitle</th><th align='right'>$submitDate</th></tr>";
echo "<tr><td colspan='2'>".$newsContent."<br/><hr size='1'/></td></tr>";
}
?>
Objavljeno 30 april 2008 - 14:27
0 članov, 1 gostov, 0 anonimnih uporabnikov