drifterz28
06-12-2010, 12:39 AM
so i have this nice little "write a review" that i am working on, i am trying to pass info from a MySQL database to a php page then to an html page using ajax but my issue is that it would be cross domain, so i need to use JSON to do this. i am looking for a simple lite way to use Jquery/JSON on the HTML page (that cant be changed) and use a GET function to pass the item ID to the php page that will sort the query and give me the info from the database.
here is the php code that i am using
<?
$con = mysql_connect("mysql","******","******");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("stores", $con);
$value = $_GET["itemid"];
$query = "SELECT * FROM ratings WHERE itemid= '$value' ORDER BY time DESC";
$result = mysql_query($query)
or die("query failed: " . mysql_error());
while($row = mysql_fetch_array($result))
{
echo "<div class=reviews>", strip_tags($row['name']), "<img src=", $row['rating'], ".png><br/>";
echo "\"", strip_tags($row['comments']), "\"</div>";
}
mysql_close($con);
?>
sorry if i did not make sense but this is also on a Yahoo! store so php on the display page is a no-no and i can do this with an iframe but that is not the way i like to roll.
Thank you
here is the php code that i am using
<?
$con = mysql_connect("mysql","******","******");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("stores", $con);
$value = $_GET["itemid"];
$query = "SELECT * FROM ratings WHERE itemid= '$value' ORDER BY time DESC";
$result = mysql_query($query)
or die("query failed: " . mysql_error());
while($row = mysql_fetch_array($result))
{
echo "<div class=reviews>", strip_tags($row['name']), "<img src=", $row['rating'], ".png><br/>";
echo "\"", strip_tags($row['comments']), "\"</div>";
}
mysql_close($con);
?>
sorry if i did not make sense but this is also on a Yahoo! store so php on the display page is a no-no and i can do this with an iframe but that is not the way i like to roll.
Thank you