hi thx for the reply just wanted to noe what does this $_REQUEST do?
Searching for a location in the database by latitude/longitude.
Collapse
X
-
tighter code
In PHP you can use the GET or POST methods to pass values between pages. If you use a form with the post method then $_POST can be used to retreived the value, if use a form with the get method then the values can be retreived fro the query strng using $_GET. $_REQUEST will handle both of them and $_COOKIE.Originally posted by Rocky86hi thx for the reply just wanted to noe what does this $_REQUEST do?
Personally I think it's clearer to use the one that corresponds with where the dat is coming from.
For a more detailed description take a look at the W3Schools tutorial.
One further change I would make, that I have just thought of:
[PHP]
if(isset($_GET['postal'])) // assuemd the value is on the URL, otherwise use $_POST
{
$postal = substr($_GET['postal'],0,2);// get the first two characters
$qry = 'SELECT startlat, endlat, startlng, endlng FROM districts WHERE districtno = $postal');
$results=mysql_ query($qry);
}
else
{
// you can add error trapping here if you want, or some alternative if the variable is not available.
}
[/PHP]
nathjComment
-
hi ppl is me right now I am told to merge my code together and send it to actionscript any idea how to do it I am told to follow the example done by other ppl below is the code done by that person
[PHP]
$fetched=mysql_ query("SELECT * FROM location");
while($row = mysql_fetch_arr ay($fetched))
{
$temp[]=$row;
}
foreach($temp as $extract)
foreach($extrac t as $key=>$info)
{
if(!is_numeric( $key)) //somehow it returns number & name of key.so take 1. $coordinates[$key]=$info;
foreach($coordi nates as $key=>$extract)
$report=$report .$key."=".$extr act."&";
echo $report;
[/PHP]
I don't understand what the code is doing and how to join them up
below is the code I have now and is required to follow the code above to join them up and send it to actionscripts
[PHP]
$postal=substr( $_GET['postal'],0,2); //will return from 0 position 2 characters
$resultpostal=m ysql_query("SEL ECT startlat,endlat ,startlng,endln g FROM districts
WHERE districtno = $postal"); //get startlat,endlat ,startlng,endln g of employee location
$resultname=mys ql_query("SELEC T uid,uname FROM location,distri cts
WHERE location.lat < districts.start lat AND location.lat > districts.endla t AND location.lng < districts.start lng
AND location.lng > districts.endln g");
echo("resultpos tal" + "resultname ");
}
[/PHP]
How do I join the code of mine together and send it to actionscript plss help me thx~Comment
-
Heya, Rocky.
Tell whoever gave you that example code that next time, he should use mysql_fetch_ass oc() instead of mysql_fetch_arr ay()
How are you sending the results to actionscript? Do you want to output an XML-formatted document for your Flash object to parse? Do you want to pass the variables as arguments in the query string? Do you want your script to output the actionscript itself?Comment
-
Hi what I want is pass the variables as arguments in the query stringOriginally posted by pbmodsHeya, Rocky.
Tell whoever gave you that example code that next time, he should use mysql_fetch_ass oc() instead of mysql_fetch_arr ay()
How are you sending the results to actionscript? Do you want to output an XML-formatted document for your Flash object to parse? Do you want to pass the variables as arguments in the query string? Do you want your script to output the actionscript itself?Comment
-
To pass the variables in the query string on PHP simply add them on the end of the url:Originally posted by Rocky86Hi what I want is pass the variables as arguments in the query string
Then on index.php the following code will get that value for you:
[CODE=php]
<?php
if (isset($_GET['pageId']))
{
$lnPageID = $_GET['pageId'];
//use the variable however you want
}
else
{
echo 'The query string was not set properly';
// or some other form of exception code
}
?>
[/CODE]
If you wish to pass the values from a form to another page in the query string this is done by setting the form action to 'get'. However, it is more advisable to use 'post' in a form situation. Then the in the code above you would replace $_GET with $_POST.
You can use $_REQUEST for either of these but it is not advisable as you have no idea then when reading the code where the data came from. Using the more specific $_POST or $_GET enables you to tell where the data came from. It makes life a lot easier for you now and in the future.
Alternatively you may wish to use $_SESSION. There are may discussions on this on this forum. But check out the manual for the basics
I hope this helped.
Cheers
nathjComment
-
hi I manage to come out with my php code pls help check iszit correct
[PHP]
<?php
$coordinates=ar ray();
$report="";
$temp="";
$sqlconnect=mys ql_connect("loc alhost","hyperi an_track","gsmt rack");
if(!$sqlconnect )
die(mysql_error ());
mysql_select_db ("hyperian_trac k", $sqlconnect);
if(isset($_GET['postal'])) //check if is true
{
$postal=substr( $_GET['postal'],0,2); //will return from 0 position 2 characters
$resultpostal=m ysql_query("SEL ECT startlat,endlat ,startlng,endln g FROM districts
WHERE districtno = $postal"); //get startlat,endlat ,startlng,endln g of employee location
while($row = mysql_fetch_arr ay($resultposta l))
{
$temp[]=$row; // store each record in an array
}
foreach($temp as $extract)
foreach($extrac t as $key=>$info)
{
if(!is_numeric( $key))
$coordinates[$key]=$info; //detect if what you extracted from $temp is not numeric and store it in $coordinates
}
foreach($coordi nates as $key=>$extract) // store the values in the $coordinates and $extract into $report and display them in the screen....
$report=$report .$key."=".$extr act."&";
echo $report;
$resultname=mys ql_query("SELEC T uid,uname FROM location,distri cts
WHERE location.lat < districts.start lat AND location.lat > districts.endla t AND location.lng < districts.start lng
AND location.lng > districts.endln g");
while($row = mysql_fetch_arr ay($resultname) )
{
$temp[]=$row;
}
foreach($temp as $extract)
foreach($extrac t as $key=>$info)
{
if(!is_numeric( $key))
$coordinates[$key]=$info;
}
foreach($coordi nates as $key=>$extract)
$report=$report .$key."=".$extr act."&";
echo $report;
}//end of if loops
else
{
echo ("error");
}
mysql_close($co n);
[/PHP]
My Objective is:
In php join them up then send it actionscript
actionscript will seperate them outComment
-
Hi Rocky86,
I have read over this quickly and it looks okay, there is lots of array parsing going on. The best way to find out if it is working or not is to run the code. Then work through any issues that you have.
If you come up against anything you can't resolve then post the specifics. I'll do what I can to help out.
Cheers
nathjComment
-
hihi nathj thx for taking the effort to help me out man but do you know how do I send this php code to actionscripts and use the actionscript to separate the code out?Originally posted by nathjHi Rocky86,
I have read over this quickly and it looks okay, there is lots of array parsing going on. The best way to find out if it is working or not is to run the code. Then work through any issues that you have.
If you come up against anything you can't resolve then post the specifics. I'll do what I can to help out.
Cheers
nathj
do I need to create function on actionscript to take in the php code?Comment
-
Unfortunatley thats where my ability dies on this one. I have never done this and am not even sure what it is. I assume its Flash we're talking about? I have only ever done really basic stuff in flash - like image transitions.Originally posted by Rocky86hihi nathj thx for taking the effort to help me out man but do you know how do I send this php code to actionscripts and use the actionscript to separate the code out?
do I need to create function on actionscript to take in the php code?
Sorry I can't be any more help on this.
Cheers
nathjComment
-
Oh anyway nathj you have been a great help thx alot!!Originally posted by nathjUnfortunatley thats where my ability dies on this one. I have never done this and am not even sure what it is. I assume its Flash we're talking about? I have only ever done really basic stuff in flash - like image transitions.
Sorry I can't be any more help on this.
Cheers
nathjComment
-
Comment