Jump to content

MYSQL multiple rows help


ensellitis

Recommended Posts

I have looked and looked, and I have yet to find an answer to this.  Maybe I have just gone retarded...

 

	$threeup1	= $upuser['3up1'];
	$threeup2	= $upuser['3up2'];
	$threeup3	= $upuser['3up3'];

	if($threeup1 !== "0" && $threeup2 !== "0" && $threeup3 !== "0"){

	}

 

What I am trying to do is pull the the info from $threeup1, $threeup2, and $threeup3 from 3 seperate DB rows, and use the info in one spot.  So if the IDs where repectively 2,10, 12...  I want to grab all 3 of their "level" columns and check them. 

 

The script works like this: If all 3 are level 1 or higher (but all are atleast level 1), it makes you level 2.  The same for all levels up to 5.

 

I hope that makes sense, I tried to give as much detail as possible so you can see what I am trying to do.  Help would be much appreciated.

Link to comment
https://forums.phpfreaks.com/topic/196271-mysql-multiple-rows-help/
Share on other sites

if $upuser is your db row then you aren't getting 3 separate db rows. you're pulling from the same row.

 

if you want from three different rows in your result set then i think you want something like this:

//get level from three consecutive rows in the result set from the db query
$threeup1	= mysql_result($dbresults,0,'level');
$threeup2	= mysql_result($dbresults,1,'level');
$threeup3	= mysql_result($dbresults,2,'level');

//make sure all are greater than or equal to 1
	if($threeup1 >= 1 && $threeup2 >= 1 && $threeup3 >= 1){
		//level up
	}



 

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.