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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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