jeudi 23 avril 2015

PHP if statement - Resource id issue

I have some code below which retrieves data from a table named "tally_point"

What I am trying to is retrieve a value from a column named 'tpt_id'

On another table, there is a table named "tally_point_type", which has has the primary key 'tpt_id' as well.

What I am trying to do is get the 'tpt_name' value to print from the tally_point_type row. At the moment I can get the "Order Details" link to work but the $tpt_name value prints out a Resource id# value.

I knwo Im close but can't quite figure out how to get this to work.

    <?php

    $pointstype = $row['tpt_id'];

    $type = '<td align="center">';

    if($pointstype > '0') {

    $query = "SELECT tpt_name 
    FROM tally_point_type 
    WHERE'" . $row['tpt_id'] . "'=$pointstype";

    $tpt_name = mysql_query($query);
     $type .='<strong>' . $tpt_name . '</strong></td></tr>';
    }
    else {
     $type .='<strong><a href="view-ind-order.php?id=' . $pointsitem . '">Order Details</a></strong></td></tr>'; 
    }   
    echo $type; 
    ?>

Aucun commentaire:

Enregistrer un commentaire