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

Link to comment
Share on other sites

[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]

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.