Jump to content

Need a PHP Guru for complicated Coord manipulation


drisate

Recommended Posts

hey guys

I have a problem

 

1:113:13

 

- The first number called 'G' can not exeed 9

- The seconde called 'S' can not exeed 499

- The third called 'P' can not exeed 15

 

So if you add 4P to the obove coord it would now be 1:114:2

 

I need to be able to select 50S range from an sql query

 

How can i make a script that would select everything inside a range of 50S in a MYSQL table where G, S and P are seperated

[code]somethin like this

<?php

$test ='1:113:13';

$add = '50S';

$test = explode(':',$test);

$number = ($test[0]-1)*499*15+($test[1]-1)*15+($test[2]-1);

$t = substr($add, -1);

switch ($t){

case 'G':

$add *= 499;

case 'S':

$add *= 15;

case 'P' :

$add *= 1;

}

$new_number = $number+$add;

$sql = "SELECT * FROM table_name WHERE ((G-1)*499*15+(S-1)*15+P-1) BETWEEN $number AND $new_number";

?>[/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.