PHP sammen med Javascript?
Hey,Jeg har et problem med at koble javascript og PHP sammen! Min ser således ud:
<?
$foresp = mysql_query("SELECT id, pic1, pic1spg, pic1url, pic2, pic2spg, pic2url, pic3, pic3spg, pic3url, pic4, pic4spg, pic4url, pic5, pic5spg, pic5url FROM banner WHERE id = '1' ORDER BY id DESC LIMIT 0, 1");
while($data = mysql_fetch_array($foresp)){
?>
<script language="JavaScript">
<!--
function SymError()
{
return true;
}
window.onerror = SymError;
//-->
</script>
<script type="text/javascript">
<!-- Dette script og mange flere -->
<!-- findes hos http://www.html.dk -->
<!-- Start
bannerpics=new Array;
bannerurls=new Array;
<? if($data[pic1spg] == "1") { ?>
bannerpics[1]="images/banner/<?=$data[pic1]; ?>";
bannerurls[1]="banner/hits.php?ban=1";
<? } else { } ?>
<? if($data[pic2spg] == "1") { ?>
bannerpics[2]="images/banner/<?=$data[pic2]; ?>";
bannerurls[2]="banner/hits.php?ban=2";
<? } else { } ?>
<? if($data[pic3spg] == "1") { ?>
bannerpics[3]="images/banner/<?=$data[pic3]; ?>";
bannerurls[3]="banner/hits.php?ban=3";
<? } else { } ?>
<? if($data[pic4spg] == "1") { ?>
bannerpics[4]="images/banner/<?=$data[pic4]; ?>";
bannerurls[4]="banner/hits.php?ban=4";
<? } else { } ?>
<? if($data[pic5spg] == "1") { ?>
bannerpics[5]="images/banner/<?=$data[pic5]; ?>";
bannerurls[5]="banner/hits.php?ban=5";
<? } else { } ?>
num = Math.random();
num = 1 + ( num * ((bannerpics.length - 1)-1));
num = Math.round(num);
function ShowBanner() {
document.write("<a href='" + bannerurls[num] + "' target='_blank' >");
document.write("<img src='" + bannerpics[num] + "' border='0' >");
document.write("</a>");
}
bantal=new Array;
function ShowNum() {
document.write(num);
}
// Slut -->
</script>
<?
}
$bantop = "<script type=text/javascript>ShowNum()</script>";
if($bantop == 1){ mysql_query("UPDATE statistik SET topban1=topban1+1 WHERE id='1' ") or print mysql_error(); } else { }
if($bantop == 2){ mysql_query("UPDATE statistik SET topban2=topban2+1 WHERE id='1' ") or print mysql_error(); } else { }
if($bantop == 3){ mysql_query("UPDATE statistik SET topban3=topban3+1 WHERE id='1' ") or print mysql_error(); } else { }
if($bantop == 4){ mysql_query("UPDATE statistik SET topban4=topban4+1 WHERE id='1' ") or print mysql_error(); } else { }
if($bantop == 5){ mysql_query("UPDATE statistik SET topban5=topban5+1 WHERE id='1' ") or print mysql_error(); } else { }
?>
