Jump to content

Problem with PHP, i'm new to php so this is prolly easy for pros.


murhapuro

Recommended Posts

Hello

 

I have this problem that i have this ajax rating script that shows the users how good something is rated, they can also vote by mouseovering it.

 

I call the rating bar with :

 

<?php echo rating_bar('page-id-is-in-here','5'); ?>

 

Now i would like to get that page id from other table in the same database. This would help me alot cause i have many pages to make. I tried to call it like this:

 

<?php

$result = mysql_query("SELECT stars_ss FROM info WHERE (id ='$id');", $connection);

 

while ($row = mysql_fetch_array($result)) {

echo rating_bar('stars_ss','5');

}

?>

 

This however did not work, and i would like to solve this before i go any further.

I have 2 tables:

 

info (in here is the stars_ss)

ratings (here is all the ratings)

 

Could anyone please suggest how i would make this work? Im very new to php, but would like to learn more! Thanks in advance!

 

Murhapuro

you're while loop looks wrong to me.

 

while ($row = mysql_fetch_array($result)) {
    echo rating_bar('$row['column_name']','5');
}

 

Insert the appropriate column name into this part: $row['column_name'].

 

Also, are you getting any errors? I would set it up like this:

<?php
$query = "SELECT stars_ss FROM info WHERE (id ='$id');";
$result = mysql_query($query, $connection) or die("Error: " . mysql_error());

while ($row = mysql_fetch_array($result)) {
   echo rating_bar($row['column_name'],'5');
}
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.