Jump to content

Randomizing over and over untill it is clear with the sql query.


Dethman

Recommended Posts

Ok guys a brief overview,

 

I have listed where I need to something and what inside the comments hope it helps This is making me dizzy .lol.

 

Here just look at what I am trying to do:

 

<?php

#
# Basically I need to make this function in order to randomly place the user on the map
#

function setPlayerOnMap(){

$q=mysql_query("SELECT * FROM `SystemInfo` WHERE `id` = '1'") or die("Unable to connect");

$row=mysql_fetch_array($q);

$set_land=$row['land'];
$set_area=$row['area'];
$set_line=$row['line'];

while(mysql_num_rows(mysql_query("SELECT `villageID` FROM `map` WHERE `land` = '$set_land' AND `line` = '$set_line' AND `area` = '$set_area'")) > 0){


/*
      Basically I need to randomize $set_land, $set_area and $set_line untill we come to a 
  villageID that is not greater than zero the max info is below thanx for all your help.
  
  $set_land max is 7
  
  $set_area max is 60
  
  $set_line max is 6
  
  so we have :
  
  $set_land places are 1-7
  
  $set_area places are 1-60
  
  $set_line places are 1-6
  
  Again I must randomize each var and check each time it is randomized to see if it the 
  current randomizes are  making the villageID in the table map is not greater than zero if it is not keep randomizing until it is.

Thanx for any Help,
Brian Flores CEO
Nimbus Games,llc
*/




}

?>

 

 

Thanx for any Help,

Brian Flores CEO

Nimbus Games,llc

That is trivial you should only get 1 Location don't u want to randomize it to a random location?

 

<?php
$query=("SELECT `land`, `line`, `area`, `villageID` FROM `map` WHERE `villageID` = '0'");
$res=mysql_query($query) OR DIE("UNABLE TO CONNECT, ERROR:<BR /><BR /><BR />".mysql_error());
$landmarks = array();
while($row = mysql_fetch_assoc($r)){
foreach($row as $key=>$value){
        $landmarks[$row['villageID']][$key] = $value;
}
}
?>

Then select a random item from the array $landmarks (array_rand) and then your are all set

 

?>

[/code]

 

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.