| | |
help with javascript (moved from javascript forum)
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jun 2005
Posts: 9
Reputation:
Solved Threads: 0
http://ww.bestblanks.co.uk/media.php
hi
im not sure what im doing wrong with this:
have a look at the above url:
each product name is suppose to open a small window which will go on to display a description of the product: however when you click on title there is an error and nothing loads
can anybody suggest what im doing wrong
thanks
simon
this is the code for media.php:
<?php include "vsadmin/db_conn_open.php"; ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>bestblanks.co.uk</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="bluetipdvd/bluetipdvd.css" rel="stylesheet" type="text/css">
<script language="javascript">
function longdescription(ID) {
url = 'proddetail.php?ID='+ID;
window.open(url,'welcome','width=400,height=200');
}
</script>
<SCRIPT SRC="bluetipdvd/language-en.js"></SCRIPT>
<SCRIPT SRC="bluetipdvd/nopcart.js"></SCRIPT>
</script>
</head>
<body background="bluetipdvd/images/background.jpg" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="509" height="100%" border="0" align="center" cellpadding="1" cellspacing="1">
<tr class="rightborder">
<td width="505" valign="top"> <table width="100%" height="100" border="0" align="center" bgcolor="#FFFFFF" valign="top">
<?php
$cat = $_GET['cat'];
if(empty($cat)) {
$query = "SELECT * FROM products ORDER BY 'price'";
} else {
$query = "SELECT * FROM products WHERE cat = '$cat' ORDER BY 'price' ";
}
$result = mysql_query($query) or die('Query failed: ' . mysql_error());
$num=mysql_num_rows($result);
mysql_close();
$i=0;
while ($i < $num) {
$ID=mysql_result($result,$i,"ID");
$name=mysql_result($result,$i,"name");
$price=mysql_result($result,$i,"price");
$photo=mysql_result($result,$i,"photo");
$longdescription=mysql_result($result,$i,"longdescription");
$qty=mysql_result($result,$i,"qty");
?>
<tr>
<td width="31%" rowspan="2" valign="top" class="name"><div align="left"></div>
[<? echo "$ID" ?>] <br> <img src="<? echo "$photo" ?>" alt="<? echo "$name" ?>"></td>
<td width="69%" valign="top" class="name"><p><span class="name"><a href="javascript:longdescription(<?= $ID ?>)">
<?=$name?>
</a> </p>
<p><span class="name"> Our price £<? echo "$price" ?></span></p>
<p> </p></td>
</tr>
<tr>
<td valign="top"> <p>
<form name=order>
<input type=hidden name="qty" onChange='this.value=CKquantity(this.value)' value="1">
<input type=hidden name="PRICE" value="<?php echo "$price" ?>">
<input type=hidden name="NAME" value="<?php echo "$name" ?>">
<input type=hidden name="ID_NUM" value="<?php echo "$ID" ?>">
<input type=hidden name="SHIPPING" value="0.00">
<input type=image src="../images/addcart.gif" border="0" onClick='AddToCart(this.form)'>
</FORM></form>
</td>
</tr>
<?
$i++;
}
?>
</table></td>
</table>
</body>
</html>
and this is the code for the window that opens:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<?php include "vsadmin/db_conn_open.php";
$ID = $_GET['ID'];
$query = "SELECT * FROM products";
}
$result = mysql_query($query) or die('Query failed: ' . mysql_error());
$num=mysql_num_rows($result);
mysql_close();
$name=mysql_result($result,$i,"name");
$price=mysql_result($result,$i,"price");
$longdescription=mysql_result($result,$i,"longdescription");
?>
<title><? echo "$name" ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<table width="100%" height="91" border="1" cellpadding="1" cellspacing="1">
<tr>
<td><strong><font color="#0000FF" size="2" face="Arial, Helvetica, sans-serif">[</font><font color="#0000FF" size="2" face="Arial, Helvetica, sans-serif"><? echo "$ID"?>
] </font></strong></tr>
<tr><td><? echo "$name"?></td></tr><tr><td><? echo "$longdescription"?></td></tr>
<td height="18"></tr>
</table>
</body>
</html>
hi
im not sure what im doing wrong with this:
have a look at the above url:
each product name is suppose to open a small window which will go on to display a description of the product: however when you click on title there is an error and nothing loads
can anybody suggest what im doing wrong
thanks
simon
this is the code for media.php:
<?php include "vsadmin/db_conn_open.php"; ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>bestblanks.co.uk</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="bluetipdvd/bluetipdvd.css" rel="stylesheet" type="text/css">
<script language="javascript">
function longdescription(ID) {
url = 'proddetail.php?ID='+ID;
window.open(url,'welcome','width=400,height=200');
}
</script>
<SCRIPT SRC="bluetipdvd/language-en.js"></SCRIPT>
<SCRIPT SRC="bluetipdvd/nopcart.js"></SCRIPT>
</script>
</head>
<body background="bluetipdvd/images/background.jpg" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="509" height="100%" border="0" align="center" cellpadding="1" cellspacing="1">
<tr class="rightborder">
<td width="505" valign="top"> <table width="100%" height="100" border="0" align="center" bgcolor="#FFFFFF" valign="top">
<?php
$cat = $_GET['cat'];
if(empty($cat)) {
$query = "SELECT * FROM products ORDER BY 'price'";
} else {
$query = "SELECT * FROM products WHERE cat = '$cat' ORDER BY 'price' ";
}
$result = mysql_query($query) or die('Query failed: ' . mysql_error());
$num=mysql_num_rows($result);
mysql_close();
$i=0;
while ($i < $num) {
$ID=mysql_result($result,$i,"ID");
$name=mysql_result($result,$i,"name");
$price=mysql_result($result,$i,"price");
$photo=mysql_result($result,$i,"photo");
$longdescription=mysql_result($result,$i,"longdescription");
$qty=mysql_result($result,$i,"qty");
?>
<tr>
<td width="31%" rowspan="2" valign="top" class="name"><div align="left"></div>
[<? echo "$ID" ?>] <br> <img src="<? echo "$photo" ?>" alt="<? echo "$name" ?>"></td>
<td width="69%" valign="top" class="name"><p><span class="name"><a href="javascript:longdescription(<?= $ID ?>)">
<?=$name?>
</a> </p>
<p><span class="name"> Our price £<? echo "$price" ?></span></p>
<p> </p></td>
</tr>
<tr>
<td valign="top"> <p>
<form name=order>
<input type=hidden name="qty" onChange='this.value=CKquantity(this.value)' value="1">
<input type=hidden name="PRICE" value="<?php echo "$price" ?>">
<input type=hidden name="NAME" value="<?php echo "$name" ?>">
<input type=hidden name="ID_NUM" value="<?php echo "$ID" ?>">
<input type=hidden name="SHIPPING" value="0.00">
<input type=image src="../images/addcart.gif" border="0" onClick='AddToCart(this.form)'>
</FORM></form>
</td>
</tr>
<?
$i++;
}
?>
</table></td>
</table>
</body>
</html>
and this is the code for the window that opens:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<?php include "vsadmin/db_conn_open.php";
$ID = $_GET['ID'];
$query = "SELECT * FROM products";
}
$result = mysql_query($query) or die('Query failed: ' . mysql_error());
$num=mysql_num_rows($result);
mysql_close();
$name=mysql_result($result,$i,"name");
$price=mysql_result($result,$i,"price");
$longdescription=mysql_result($result,$i,"longdescription");
?>
<title><? echo "$name" ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<table width="100%" height="91" border="1" cellpadding="1" cellspacing="1">
<tr>
<td><strong><font color="#0000FF" size="2" face="Arial, Helvetica, sans-serif">[</font><font color="#0000FF" size="2" face="Arial, Helvetica, sans-serif"><? echo "$ID"?>
] </font></strong></tr>
<tr><td><? echo "$name"?></td></tr><tr><td><? echo "$longdescription"?></td></tr>
<td height="18"></tr>
</table>
</body>
</html>
•
•
Join Date: Dec 2004
Posts: 1,655
Reputation:
Solved Threads: 35
Because I saw no JavaScript in his code. I saw PHP code that produces JavaScript. So the first step in troubleshooting the problem is to make sure all of the PHP is valid. If it is, then we can move on to working through the JavaScript.
If a user truly wants help with JavaScript, they should post the relevant JavaScript. With server-side-generated code, the best way to see what is actually produced is to "view source" and copy the relevant code snippets to the forum. Which the original poster can still do! He hasn't been "banned" from the JavaScript forum by any means. I just made a judgment call that he would get better help here.
While we're talking about clarity, in a technical forum I would recommend proper spelling and punctuation.
If a user truly wants help with JavaScript, they should post the relevant JavaScript. With server-side-generated code, the best way to see what is actually produced is to "view source" and copy the relevant code snippets to the forum. Which the original poster can still do! He hasn't been "banned" from the JavaScript forum by any means. I just made a judgment call that he would get better help here.
While we're talking about clarity, in a technical forum I would recommend proper spelling and punctuation.
![]() |
Similar Threads
- quick javascript help (JavaScript / DHTML / AJAX)
- Any good Javascript forum ? (PHP)
- JavaScript Issue in Mozilla (Java)
- help with javascript and forms (PHP)
- XHTML and javascript 'setInterval' (JavaScript / DHTML / AJAX)
Other Threads in the PHP Forum
- Previous Thread: Error with tables overlapping
- Next Thread: Mysql num rows(): Invalid argument
| Thread Tools | Search this Thread |
ajax apache api array beginner binary body broken cakephp checkbox class cms code cookies cron curl database date date/time display dynamic ebooks echo email error file files folder form forms function functions google href htaccess html image include insert interactive ip javascript job joomla js limit link login mail mediawiki menu mlm mobile msqli_multi_query multiple mycodeisbad mysql navigation oop outofmemmory paging parse paypal pdf php problem procedure query radio ram random recursion regex remote script search server sessions sms source space sql stored subdomain syntax system table tutorial unicode update upload url validator variable video web webapplications websitecontactform xml youtube






