menu klapt niet uit
pim1991 - 29/01/2006 17:25
PHP interesse
hallo,
ik heb een webshop. maar mijn menu klapt niet uit als ze erop klikken.
dit menu werkt voor een groot deel met de mysql database. eerst deed hij het wel maar nu hij naar een andere server is verhuist niet meet.
weet iemand wat ik fout doe?
dit is de code
<?php
include "index2.php";
include "config.inc";
$db = @mysql_connect("$databasehost", "$databaseuser", "$databasepasswd"); ?>
<html><head>
<title><? echo $ashopname ?>
</title>
<script language="JavaScript">
function buyItem(itemno)
{
window.open("buy.php?"+itemno,"_blank","toolbar=no, location=no, scrollbars=no, width=450, height=150")
}
</script>
<script language="JavaScript">
function info(nr)
{
window.open("info.php?"+nr,"_blank","toolbar=no, location=no, scrollbars=no, width=500, height=200")
}
</script>
</head>
<body bgcolor="FFFFFF" text="#000000" link="#000000" alink="#000000" vlink="#000000">
<table width="100%" valign="top" border="0" cellspacing="0" cellpadding="0" height="95%">
<tr><td width="15%"><p>
<?
// List categories...
if ($cat) {
$sql="SELECT parentcategoryid from category WHERE categoryid = $cat";
$result = @mysql_query($sql,$db);
$parent = @mysql_result($result, 0, "parentcategoryid");
}
$sql="SELECT categoryid, name FROM category WHERE parentcategoryid = categoryid";
$result = @mysql_query($sql,$db);
for ($i = 0; $i < @mysql_num_rows($result); $i++) {
$categoryname = @mysql_result($result, $i, "name");
$categoryid = @mysql_result($result, $i, "categoryid");
echo "<font face=\"Arial, Helvetica, sans-serif\" size=\"2\"><a href=\"main.php?cat=$categoryid\">$categoryname</a></font><br>";
if (($categoryid == $cat) || ($categoryid == $parent)) {
$subsql="SELECT categoryid, name FROM category WHERE parentcategoryid = $categoryid AND categoryid != parentcategoryid";
$subresult = @mysql_query($subsql,$db);
for ($j = 0; $j < @mysql_numrows($subresult); $j++) {
$subcategoryname = @mysql_result($subresult, $j, "name");
$subcategoryid = @mysql_result($subresult, $j, "categoryid");
echo "<li><font face=\"Arial, Helvetica, sans-serif\" size=\"2\"><a href=\"main.php?cat=$subcategoryid\">$subcategoryname</a></font><br>";
}
}
}
?>
</p>
<p>
</td>
<td valign="top">
</p>
</td><td><font color="white">
<TABLE BORDER="1" valign="top" width="100%" BORDERCOLOR="black" CELLPADDING="2" CELLSPACING="0">
<TR>
<TD BGCOLOR="blue" width="30%">Produktnaam</TD>
<TD BGCOLOR="blue" width="4%"> </TD>
<TD BGCOLOR="blue" width="45%">eenheid</TD>
<td bgcolor="blue" width="20%" height="10"> </TD>
</TR>
</TABLE>
</font>
<?
// List products belonging to this category...
$sql="SELECT product.* from productcategory, product WHERE productcategory.categoryid = $cat AND product.productid = productcategory.productid";
$result = @mysql_query($sql,$db);
for ($i = 0; $i < @mysql_num_rows($result); $i++) {
$productid = @mysql_result($result, $i, "productid");
$productname = @mysql_result($result, $i, "name");
$description = @mysql_result($result, $i, "description");
$inhoud = @mysql_result($result, $i, "inhoud");
$price = @mysql_result($result, $i, "price");
echo "
<TABLE BORDER=\"0\" width=\"100%\" valign=\"top\" BORDERCOLOR=\"#000000\" CELLPADDING=\"2\" CELLSPACING=\"0\">
<TR>
<TD BGCOLOR=\"#3399CC\" width=\"30%\">$productname</TD>
<TD BGCOLOR=\"#3399CC\" width=\"4%\"><a onClick=\"info($productid)\"><table bgcolor=\"blue\"><td><img height=\"20\" width=\"20\" src=\"images\info.gif\" border=\"0\"></td></table></a></TD>
<TD BGCOLOR=\"#3399CC\" width=\"45%\">$inhoud</TD>
<td bgcolor=\"#3399CC\" width=\"20%\" height=\"10\"><center><table bgcolor=\"blue\"><td><a onClick=\"buyItem($productid)\"><img src=\"images\cart.gif\" border=\"0\"></a></td></table></center></TD>
</TR>
</TABLE>
";
}
@mysql_close($db);
?>
</tr></td>
</td>
</tr>
</table>
</body></html>
<?php
include "index2.php" ;
include "config.inc" ;
$db = @ mysql_connect ( "$databasehost " , "$databaseuser " , "$databasepasswd " ) ; ?> <html><head>
<title>
<? echo $ashopname ?> </title>
<script language="JavaScript">
function buyItem(itemno)
{
window.open("buy.php?"+itemno,"_blank","toolbar=no, location=no, scrollbars=no, width=450, height=150")
}
</script>
<script language="JavaScript">
function info(nr)
{
window.open("info.php?"+nr,"_blank","toolbar=no, location=no, scrollbars=no, width=500, height=200")
}
</script>
</head>
<body bgcolor="FFFFFF" text="#000000" link="#000000" alink="#000000" vlink="#000000">
<table width="100%" valign="top" border="0" cellspacing="0" cellpadding="0" height="95%">
<tr><td width="15%"><p>
<?
// List categories...
if ( $cat ) {
$sql = "SELECT parentcategoryid from category WHERE categoryid = $cat " ;
}
$sql = "SELECT categoryid, name FROM category WHERE parentcategoryid = categoryid" ;
echo "<font face=\" Arial, Helvetica, sans-serif\" size=\" 2\" ><a href=\" main.php?cat=$categoryid \" >$categoryname </a></font><br>" ; if ( ( $categoryid == $cat ) || ( $categoryid == $parent ) ) {
$subsql = "SELECT categoryid, name FROM category WHERE parentcategoryid = $categoryid AND categoryid != parentcategoryid" ;
$subcategoryid = @ mysql_result ( $subresult , $j , "categoryid" ) ; echo "<li><font face=\" Arial, Helvetica, sans-serif\" size=\" 2\" ><a href=\" main.php?cat=$subcategoryid \" >$subcategoryname </a></font><br>" ; }
}
}
?>
</p>
<p>
</td>
<td valign="top">
</p>
</td><td><font color="white">
<TABLE BORDER="1" valign="top" width="100%" BORDERCOLOR="black" CELLPADDING="2" CELLSPACING="0">
<TR>
<TD BGCOLOR="blue" width="30%">Produktnaam</TD>
<TD BGCOLOR="blue" width="4%"> </TD>
<TD BGCOLOR="blue" width="45%">eenheid</TD>
<td bgcolor="blue" width="20%" height="10"> </TD>
</TR>
</TABLE>
</font>
<?
// List products belonging to this category...
$sql = "SELECT product.* from productcategory, product WHERE productcategory.categoryid = $cat AND product.productid = productcategory.productid" ;
<TABLE BORDER=\" 0\" width=\" 100%\" valign=\" top\" BORDERCOLOR=\" #000000\" CELLPADDING=\" 2\" CELLSPACING=\" 0\" >
<TR>
<TD BGCOLOR=\" #3399CC\" width=\" 30%\" >$productname </TD>
<TD BGCOLOR=\" #3399CC\" width=\" 4%\" ><a onClick=\" info($productid )\" ><table bgcolor=\" blue\" ><td><img height=\" 20\" width=\" 20\" src=\" images\info.gif\" border=\" 0\" ></td></table></a></TD>
<TD BGCOLOR=\" #3399CC\" width=\" 45%\" >$inhoud </TD>
<td bgcolor=\" #3399CC\" width=\" 20%\" height=\" 10\" ><center><table bgcolor=\" blue\" ><td><a onClick=\" buyItem($productid )\" ><img src=\" images\cart.gif\" border=\" 0\" ></a></td></table></center></TD>
</TR>
</TABLE>
" ;
}
?>
</tr></td>
</td>
</tr>
</table>
</body></html>
alvast bedankt.
7 antwoorden
Gesponsorde links
MindPrison - 29/01/2006 17:52 (laatste wijziging 29/01/2006 17:55)
PHP gevorderde
Heb je een voorbeeldje ergens? Er zit wel een foutje in je html:
<a onClick=\"info($productid)\"><table bgcolor=\"blue\"><td><img height=\"20\" width=\"20\" src=\"images\info.gif\" border=\"0\"></td></table></a>
< a onClick= \"info($productid )\" ><table bgcolor=\" blue\" ><td><img height=\" 20\" width=\" 20\" src=\" images\info.gif\" border=\" 0\" ></td></table></a>
Vervangen door (<tr> vergeten):
<a onClick=\"info($productid)\"><table bgcolor=\"blue\"><tr><td><img height=\"20\" width=\"20\" src=\"images\info.gif\" border=\"0\"></td></tr></table></a>
< a onClick= \"info($productid )\" ><table bgcolor=\" blue\" ><tr><td><img height=\" 20\" width=\" 20\" src=\" images\info.gif\" border=\" 0\" ></td></tr></table></a>
En waarom dit?
<script language="JavaScript">
function buyItem(itemno)
{
window.open("buy.php?"+itemno,"_blank","toolbar=no, location=no, scrollbars=no, width=450, height=150")
}
</script>
<script language="JavaScript">
function info(nr)
{
window.open("info.php?"+nr,"_blank","toolbar=no, location=no, scrollbars=no, width=500, height=200")
}
</script>
<script language = "JavaScript" >
function buyItem( itemno)
{
window. open( "buy.php?" + itemno, "_blank" , "toolbar=no, location=no, scrollbars=no, width=450, height=150" )
}
</script>
<script language = "JavaScript" >
function info( nr)
{
window. open( "info.php?" + nr, "_blank" , "toolbar=no, location=no, scrollbars=no, width=500, height=200" )
}
</script>
Kan beter dit zijn (geen echte fout, maar beter ):
<script type="text/javascript">
<!--
function buyItem(itemno)
{
window.open("buy.php?"+itemno,"_blank","toolbar=no, location=no, scrollbars=no, width=450, height=150")
}
function info(nr)
{
window.open("info.php?"+nr,"_blank","toolbar=no, location=no, scrollbars=no, width=500, height=200")
}
-->
</script>
< script type= "text/javascript" >
<!--
function buyItem( itemno)
{
window. open( "buy.php?" + itemno, "_blank" , "toolbar=no, location=no, scrollbars=no, width=450, height=150" )
}
function info( nr)
{
window. open( "info.php?" + nr, "_blank" , "toolbar=no, location=no, scrollbars=no, width=500, height=200" )
}
-->
</script>
MindPrison - 29/01/2006 21:26
PHP gevorderde
Ik zou (lijn 26)
Vervangen door (test ook of de categorie numeriek is)
if(is_numeric($_GET["cat"])) {
Waarschijnlijk moet je op je nieuwe server verplicht superglobals gebruiken, maar ik ben niet zeker dat dit de fout is...
riekele - 29/01/2006 21:44
PHP beginner
en probeer zoveel mogelijk html buiten je php te houden, dit scheelt weer parse tijd
pim1991 - 31/01/2006 09:20 (laatste wijziging 04/02/2006 17:51)
PHP interesse
doet het nog niet. nog andere oplossingen
rambo - 04/02/2006 19:24
HTML beginner
Regel 40:
for ($j = 0; $j < @mysql_numrows($subresult); $j++) {
moet zijn:
for ($j = 0; $j < @mysql_num_rows($subresult); $j++) {
Zoiezo zou ik overal de @ weghalen; zo spoor je de fout wat makkelijker op.
pim1991 - 04/02/2006 19:28
PHP interesse
sorry,
maar hij doet het nog niet.
hij doet net zoveel als de vorige keer.
dus daar ligt het niet aan.
Gesponsorde links
Dit onderwerp is gesloten .