la faccenda è diversa da come l'avevo capita, comunque si può fare.
Io ho pensato a questo metodo, richiami con due query distinte i due valori di prezzo, e poi li compari. T faccio un esempio di codice nel quale metto i due id che mi hai dato in $ida e $idb. Il file db.php che viene incluso è un file che serve a semplificarti la vita con il db, ti riporto il codice.
codice:
<?php
$ida = "2";
$idb = "10";
include_once("db.php");
$db = new db;
$db->dati['sql_user'] = "";
$db->dati['sql_pass'] = "";
$db->dati['sql_host'] = "";
$db->dati['sql_database'] = "";
$db->connect();
$db->query("SELECT * FROM `tabella` WHERE id = ".$ida);
while($row = $db->fetch_row){
$prezzo['a'] = $row['prezzo'];
}
$db->query("SELECT * FROM `tabella` WHERE id = ".$idb);
while($row = $db->fetch_row){
$prezzo['b'] = $row['prezzo'];
}
if ( $prezzo['a'] = $prezzo['b']){
print "OK";
}
$db->close_db();
?>
db.php:
codice:
<?php
class db{
var $dati = array ( "sql_database" => "" ,
"sql_user" => "root" ,
"sql_pass" => "" ,
"sql_host" => "localhost",
);
var $query_id = "";
var $connection_id = "";
var $query_d = "";
function connect(){
$this->connection_id = mysql_connect( $this->dati['sql_host'] ,
$this->dati['sql_user'] ,
$this->dati['sql_pass']
);
if ( !mysql_select_db($this->dati['sql_database'], $this->connection_id) )
{
echo ("ERRORE: Impossibile trovare il database ");
}
}
function query($the_query = ""){
if ($the_query == "")
{
$the_query = $this->query_d;
}
$this->query_id = mysql_query($the_query, $this->connection_id);
return $this->query_id;
}
function insert($tbl,$nam,$val){
$sql_ins = "INSERT INTO $tbl ( $nam ) VALUES ( $val )";
$this->query_d = $sql_ins;
return $sql_ins;
}
function select($tbl,$wh,$val){
$sql_sel = "SELECT $wh FROM $tbl";
$this->query_d = $sql_sel;
return $sql_sel;
}
function update($tbl,$val){
$sql_upd = "UPDATE $tbl SET $val";
$this->query_d = $sql_upd;
return $sql_upd;
}
function where($val,$pre = ""){
if ($pre == "")
{
$pre = $this->query_d;
}
$sql_wh = $pre." WHERE ".$val;
$this->query_d = $sql_wh;
return $sql_wh;
}
function order($val,$mod = "ASC",$pre = ""){
if ($pre == "")
{
$pre = $this->query_d;
}
$sql_ob = $pre." ORDER BY".$val.$mod;
$this->query_d = $sql_ob;
return $sql_ob;
}
function fetch_row($query_id = "") {
if ($query_id == "")
{
$query_id = $this->query_id;
}
$this->record_row = mysql_fetch_array($query_id, MYSQL_ASSOC);
return $this->record_row;
}
function get_affected_rows() {
return mysql_affected_rows($this->connection_id);
}
function get_num_rows() {
return mysql_num_rows($this->query_id);
}
function get_insert_id() {
return mysql_insert_id($this->connection_id);
}
function free_result($query_id="") {
if ($query_id == "") {
$query_id = $this->query_id;
}
@mysql_free_result($query_id);
}
function close_db() {
return mysql_close($this->connection_id);
}
function compile_insert($data) {
$field_names = "";
$field_values = "";
foreach ($data as $k => $v)
{
$v = preg_replace( "/'/", "\\'", $v );
$field_names .= "$k,";
$field_values .= "'$v',";
}
$field_names = preg_replace( "/,$/" , "" , $field_names );
$field_values = preg_replace( "/,$/" , "" , $field_values );
return array( 'FIELD_NAMES' => $field_names,
'FIELD_VALUES' => $field_values,
);
}
function compile_update($data) {
$return_string = "";
foreach ($data as $k => $v)
{
$v = preg_replace( "/'/", "\\'", $v );
$return_string .= $k . "='".$v."',";
}
$return_string = preg_replace( "/,$/" , "" , $return_string );
return $return_string;
}
function exe(){
$query_exe = $this->query($this->query_d);
return $query_exe;
}
}
?>