检查字段是否相同

I have this code: <?php echo $pinDetails->id;?>

this gives me a unique ID and displays it on my page.

I am trying to check whether this unique ID for one table is also in another table. Then if it is, show other data from that table.

<?php
$data = mysql_query("SELECT * FROM repin WHERE new_pin_id>$pinDetails->id") 
or die(mysql_error()); 
while($info = mysql_fetch_array( $data )) 
{
    Print "".$info['from_pin_id'].",".$info['new_pin_id']."";
} 
?>

To my understanding this should work fine but nothing appears. Do I have the syntax wrong?

Also, is there a cleaner way of doing this?

Change your query like

<?php
$data = mysql_query("SELECT * FROM repin WHERE new_pin_id LIKE ".$pinDetails->id) or die(mysql_error()); 
while($info = mysql_fetch_array( $data ))
{
    Print "".$info['from_pin_id'].",".$info['new_pin_id']."";
} 
?>

You cannot use string interpolation by calling an object attribute directly.

Try this:

$data = mysql_query("SELECT * FROM repin WHERE new_pin_id>{$pinDetails->id}") 

or even better with string concatenation:

$data = mysql_query("SELECT * FROM repin WHERE new_pin_id>" . $pinDetails->id)