Jump to content

I am stumped


Stieny

Recommended Posts

OK. Here is what I am trying to do. I have the conditions set, and if the conditions are met, I want to randomly find a user id, and username from a table, and then store each of these names in the table of the user that is searching.

 

Essentially, a player will search for another player's "location" and be able to select it from a drop down list once it is found. I am fairly sure I can use serialize to store the data, however I am stumped as to how to retrieve the data to store.

 

Any ideas?

Link to comment
https://forums.phpfreaks.com/topic/186268-i-am-stumped/
Share on other sites

Yes, way past that. Here is what I have so far:

 

$mod = rand (0,100);
$chance = (($user[rangers]*$bonus[rangers]) + ($user[rangers]*$bonus[explore]))*$mod;

	if($user[turns] <= 0)
{
			header('refresh: 4; url= exploration.php');
			echo $error_header;
			echo "You do not have enough turns to do that.";
			echo $footer;
			exit();
}
	if($chance <= 0 and $chance < 199)
{
			header('refresh: 4; url= exploration.php');
			echo $error_header;
			echo "Your rangers have found nothing.";
			echo $footer;
			exit();
}
	if($chance > 200)
{
			$qry="SELECT * FROM members";
			$result = mysql_query($qry);
		while($row = mysql_fetch_array($result))
	{
		$array=array($row[leader]);
	}
			$loc=array_rand($array,1);
			header('refresh: 4; url= exploration.php');
			echo $success_header;
			echo "Your rangers have found $loc.";
			echo $footer;
			exit();
}

Link to comment
https://forums.phpfreaks.com/topic/186268-i-am-stumped/#findComment-983753
Share on other sites

ok, with this code:

      if($chance > 200)
   {
            $qry="SELECT leader FROM members";
            $result = mysql_query($qry);
            $row = mysql_fetch_array($result);		
		$loc=array_rand($row,1);
            header('refresh: 4; url= exploration.php');
            echo $success_header;
            echo "Your rangers have found $loc.";
            echo $footer;
            exit();
   }	

 

I get returns of zero or leader. I would like it to return the name of a leader.

Link to comment
https://forums.phpfreaks.com/topic/186268-i-am-stumped/#findComment-983872
Share on other sites

ok, tried this, but still didn't work....  :confused:

 

      if($chance > 200)
   {
            $qry="SELECT leader FROM members";
            $result = mysql_query($qry);
            $row = mysql_fetch_array($result);		
		$loc=array_rand($row,1);
            header('refresh: 4; url= exploration.php');
            echo $success_header;
            echo "Your rangers have found "; 
		echo $row[$loc[0]];
            echo $footer;
            exit();
   }

Link to comment
https://forums.phpfreaks.com/topic/186268-i-am-stumped/#findComment-983881
Share on other sites

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.