Jump to content

php mysql verify two rows


dsp77

Recommended Posts

i have this code

	$hasRevista = false;
// daca are revista
$query2 = "SELECT * FROM performancecriteria WHERE project_id = $project AND year = 2010 AND type = 1;";
$result2 = mysql_query($query2) or die("can not make query ". mysql_error());
$row = @mysql_fetch_row($result2);
if( $row[1] != 0 )
{
	$hasRevista = true;
}

then i output

if( $hasRevista == true )
echo '<input type="button" style="height:1.8em; width:16em;" value="Anexa IIb" onClick="printAnexa2b();"; ></input>';
else
echo '<input type="button" style="height:1.8em; width:16em;" value="Anexa IIb" onclick="alert(\'message\')">';									

the thing is that i have type = 2 in the db and i want to verify if both or one is zero = false and if both are different from 0 = true. Untill now i just managed to do with type 1

Link to comment
https://forums.phpfreaks.com/topic/196099-php-mysql-verify-two-rows/
Share on other sites

i solved by doin like this:

	$hasRevista = false;
// daca are revista
$query2 = "SELECT * FROM performancecriteria WHERE project_id = $project AND year = 2010 AND type = 1;";
$query3 = "SELECT * FROM performancecriteria WHERE project_id = $project AND year = 2010 AND type = 2;";
$result2 = mysql_query($query2) or die("can not make query ". mysql_error());
$result3 = mysql_query($query3) or die("can not make query ". mysql_error());
$row = @mysql_fetch_row($result2);
$row3 = @mysql_fetch_row($result3);
if( $row[1] != 0 )
if( $row3[1] != 0 )
{
	$hasRevista = true;
}

i'm sure there is a better way...

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.