Jump to content

Script not working when part of an include


hoponhiggo

Recommended Posts

Hi

 

I have previously posted this in the Jquery section but im not so sure its a Jquery issue now, so apoligies for the double post.

 

I am having an issue with a rating system that works if i access the gamecards.php file through its absolute path (www..../...../gamecards.php) but will not work if i access it through a file that it is an include of (www..../reviews.php)

 

Basicaly, when i click on the link through the include, the data is not sent to the DB and the data does not refresh.

 

gamecards.php all works fine when its not as an include.

 

Any ideas why? Gamecards.php is posted below

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<script type="text/javascript" src="jquery.js"></script>

<script type="text/javascript">
$(function() {

$(".vote").click(function() 
{

var id = $(this).attr("id");
var name = $(this).attr("name");
var dataString = 'id='+ id ;
var parent = $(this);


if(name=='up')
{

$(this).fadeIn(200).html('<img src="dot.gif" align="absmiddle">');
$.ajax({
   type: "POST",
   url: "up_vote.php",
   data: dataString,
   cache: false,

   success: function(html)
   {
    parent.html(html);
  
  }  });
  
}
else
{

$(this).fadeIn(200).html('<img src="dot.gif" align="absmiddle">');
$.ajax({
   type: "POST",
   url: "down_vote.php",
   data: dataString,
   cache: false,

   success: function(html)
   {
       parent.html(html);
  }
   
});


}
  
  
   


return false;
});

});
</script>
</head>
<body>
<?php

include('config.php');

//get results from db

if (isset($_GET['gameid']) && is_numeric($_GET['gameid'])) {
$gameid = mysql_real_escape_string($_GET['gameid']);
$sql = "SELECT * FROM Games WHERE gameid = $gameid";
$res = mysql_query($sql);
$data = mysql_fetch_assoc($res);

// However you'd like to format the html to output
$title=$data['gametitle'];
$cover=$data['cover'];
$gameid=$data['gameid'];
$info=$data['info'];
$genre=$data['genre'];
$rdate=$data['releasedate'];
$format=$data['format'];
$dir1="coverart";
$reviews="Enter Reviews Here";
date("d/m/y",$rdate);

echo "<div id='cardcontainer_full'>
<div id='coverart'><img src='$dir1/{$cover}' width='100' height='140'><br></div>

<div id='gametitle'>$title</div>

<div id='features'>Genre: $genre<br><br>
Release Date: $rdate<br><br>
Available for: $format<br><br>
</div>

<div id='gameinfo'><div style='font-weight:bold'>Summary</div><br>$info
<p><div style='font-weight:bold'>Reviews</div><p>$reviews
</div>

</div>";

} else {

$data = '';

if(isset($_GET['filter']) && $_GET['filter'] != ''){
$filter = $_GET['filter']."%";
}else{
// set A as default
$filter = "a%";
}

$sql = "SELECT * FROM Games WHERE gametitle LIKE '$filter' ORDER BY gametitle";
$res = mysql_query($sql) or die(mysql_error());
if(mysql_num_rows($res) == 0) die("No records found");

// loop through the results returned by your query
while($row = mysql_fetch_assoc($res))
{
    $title=$row['gametitle'];
$cover=$row['cover'];
$gameid=$row['gameid'];
$up=$row['up'];
$down=$row['down'];

// directory for images
$dir="coverart";
?>



<div id="cardcontainer">

<div id="coverart">
<?php echo "<img src='$dir/{$cover}' width='100' height='140'><br>"; ?>
</div>
<div id="gametitle">
<a href="Reviews.php?gameid=<?php echo $gameid ?>"><?php echo $title ?></a>
</div>
<div id="friendrating">Rate It<br /><a href="" class="vote" id="<?php echo $gameid; ?>" name="up"><?php echo $up; ?></a></div>
<div id="globalrating">Hate It<br /><a href="" class="vote" id="<?php echo $gameid; ?>" name="down"><?php echo $down; ?></a></div>

</div>
<br />
<?php
}
}
?>
</body>
</html>

Link to comment
Share on other sites

So you're saying that on the form action that sends you to reviews.php?gameid=$gameid with post data, it does not work?

 

If this file you're showing us works fine then why are you showing it?

 

We need the file that's not working which is reviews.php, so if you can post it here that would be great.

 

Also, I'm assuming you're talking about the form because I do not see you including the file reviews.php anywhere.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.