need help with this code currently I understand abit of what this code is doing but I need to make use of the same logic to send my data to actionscripts so how do I do it?
This is the code logic:
[PHP]
<?php
$sqlconnect=mysql_connect("localhost","hyperian_tr ack","gsmtrack");
if(!$sqlconnect)
die(mysql_error());
mysql_select_db("hyperian_track", $sqlconnect);
$fetched=mysql_query("SELECT * FROM location");
while($row = mysql_fetch_array($fetched))
{
$temp[]=$row[uname];
}
$names=sizeof($temp);
$report="total=$names&";
foreach($temp as $list)
$report.="name".$names--."=".$list."&";
echo $report;
mysql_close($con);
?>
[/PHP]
As you can see this part of the code is reallx confusing: $report.="name".$names--."=".$list."&"; but I want to do the same method so how do I do it in my code I need the uid and uname to be send to actionscript below is my code currently:
[PHP]
<?php
$temp="";
$sqlconnect=mysql_connect("localhost","hyperian_tr ack","gsmtrack");
if(!$sqlconnect)
die(mysql_error());
mysql_select_db("hyperian_track", $sqlconnect);
if($_GET['postal']))
$postalcode=substr($_GET['postal'],0,2); //will return from 0 position 2 characters
$resultpostal=mysql_query("SELECT location.uname,location.uid FROM location,districts WHERE districts.districtno = '".$postalcode."' AND
location.lat BETWEEN districts.startlat AND districts.endlat AND location.lng BETWEEN districts.startlng AND districts.endlng");
if($row = mysql_fetch_array($resultpostal))
{
$temp[]=$row[uid];
$temp1[]=$row[uname];
}
foreach($temp as $result)
$report.="
foreach($temp1 as $result)
$report.="
echo $report;
}//end of if loops
mysql_close($con);
[/PHP]
My code I created 2 temp to take in the uid and uname but how do I continue from this part here to send it to actionscripts? foreach($temp as $result)
$report.="
foreach($temp1 as $result)
$report.="
echo $report; 29 1725
Your code is only supposed to print out 1 users information, is that correct?
your code would look like
$report = 'uid=' . $result[0] . '&uname=' . $result[1];
this will print out: uid=1&uname=somename
Your code is only supposed to print out 1 users information, is that correct?
your code would look like
$report = 'uid=' . $result[0] . '&uname=' . $result[1];
this will print out: uid=1&uname=somename
Yes it should just print out 1 users information so my code I edited it like that iszit correct do I need to make any changes?
[PHP]
<?php
$temp="";
$sqlconnect=mysql_connect("localhost","hyperian_tr ack","gsmtrack");
if(!$sqlconnect)
die(mysql_error());
mysql_select_db("hyperian_track", $sqlconnect);
if($_GET['postal']))
$postalcode=substr($_GET['postal'],0,2); //will return from 0 position 2 characters
$resultpostal=mysql_query("SELECT location.uname,location.uid FROM location,districts WHERE districts.districtno = '".$postalcode."' AND
location.lat BETWEEN districts.startlat AND districts.endlat AND location.lng BETWEEN districts.startlng AND districts.endlng");
if($row = mysql_fetch_array($resultpostal))
{
$temp[]=$row[uid];
$temp1[]=$row[uname];
}
foreach($temp as $result)
foreach($temp1 as $result)
$report ='uid='.$result[0].'&uname='.$result[1];
echo $report;
}//end of if loops
mysql_close($con);
[/PHP]
Is anyone around to help?
Is it reallx no one??????????
I can't understand what's so hard about that, you are just trying to concatenate them.
I noticed your always asking us to explain this part of the code, when the code is really not that hard to understand. Maybe its time to learn them right? Logic is not taught its learned.
Are you always copying your code?
Why is my uname and uid undefined when I run the output on actionscriptS? It should show the uname and uid but instead it show me undefined anyone noe?
my code:
PHP Code:
[PHP]
<?php
$sqlconnect=mysql_connect("localhost","hyperian_tr ack","gsmtrack");
if(!$sqlconnect)
die(mysql_error());
mysql_select_db("hyperian_track", $sqlconnect);
if($_GET['postal']))
$postalcode=substr($_GET['postal'],0,2); //will return from 0 position 2 characters
$resultpostal=mysql_query("SELECT location.uname,location.uid FROM location,districts WHERE districts.districtno = '".$postalcode."' AND
location.lat BETWEEN districts.startlat AND districts.endlat AND location.lng BETWEEN districts.startlng AND districts.endlng");
if($row = mysql_fetch_array($resultpostal))
{
$temp[]=$row[uid];
$temp1[]=$row[uname];
}
foreach($temp as $result)
$report ='uid'."=".$result."&";
foreach($temp1 as $result1)
$report ='uname'."=".$result1."&";
echo $report;
mysql_close($con);
}
?>
[/PHP]
-
$temp[]=$row[uid];
-
$temp1[]=$row[uname];
-
check that part of your code...
You are trying to retrieve $row[uid] and $row[uname].
That should be a numeric value. It should go something like $row[0] and $row[1]. Make sure that $row is an array first. check arrays in php at http://w3schools.com/php/php_arrays.asp
I advice you not to copy code. How can you learn by that. Copy them if you really understand them. That's an advice its up to you if you want to learn.
-
$temp[]=$row[uid];
-
$temp1[]=$row[uname];
-
check that part of your code...
You are trying to retrieve $row[uid] and $row[uname].
That should be a numeric value. It should go something like $row[0] and $row[1]. Make sure that $row is an array first. check arrays in php at http://w3schools.com/php/php_arrays.asp
I advice you not to copy code. How can you learn by that. Copy them if you really understand them. That's an advice its up to you if you want to learn.
thx for the advice I only want to extact out the uname and uid from the array that is stored inside the variable $temp[] except I reallx gt no idea how to go about it doing that
PHP Code:
[PHP]
<?php
$sqlconnect=mysql_connect("localhost","hyperian_tr ack","gsmtrack");
if(!$sqlconnect)
die(mysql_error());
mysql_select_db("hyperian_track", $sqlconnect);
if($_GET['postal']))
$postalcode=substr($_GET['postal'],0,2); //will return from 0 position 2 characters
$resultpostal=mysql_query("SELECT location.uname,location.uid FROM location,districts WHERE districts.districtno = '".$postalcode."' AND
location.lat BETWEEN districts.startlat AND districts.endlat AND location.lng BETWEEN districts.startlng AND districts.endlng");
$counterx=0;
while($row=mysql_fetch_array($resultpostal)){
foreach($row as $col_value){
$temp[$counterx]=$col_value;
$counterx++;
}
$report ='uid'."=".$temp[0]."&";
$report .='uname'."=".$temp[1]."&";
echo $report;
mysql_close($con);
}
?>
[/PHP][/quote]
edit it to fit to your problem. I gave the code already.....
PHP Code:
[PHP]
<?php
$sqlconnect=mysql_connect("localhost","hyperian_tr ack","gsmtrack");
if(!$sqlconnect)
die(mysql_error());
mysql_select_db("hyperian_track", $sqlconnect);
if($_GET['postal']))
$postalcode=substr($_GET['postal'],0,2); //will return from 0 position 2 characters
$resultpostal=mysql_query("SELECT location.uname,location.uid FROM location,districts WHERE districts.districtno = '".$postalcode."' AND
location.lat BETWEEN districts.startlat AND districts.endlat AND location.lng BETWEEN districts.startlng AND districts.endlng");
$counterx=0;
while($row=mysql_fetch_array($resultpostal)){
foreach($row as $col_value){
$temp[$counterx]=$col_value;
$counterx++;
}
$report ='uid'."=".$temp[0]."&";
$report .='uname'."=".$temp[1]."&";
echo $report;
mysql_close($con);
}
?>
[/PHP]
edit it to fit to your problem. I gave the code already.....[/quote]
Thank alot for your help !!!
dafodil mind if I ask why do you create a counter? $counterx=0;
dafodil mind if I ask why do you create a counter? $counterx=0;
Looks like it'd normalize the temporary array into a normal numerical array, but there are array functions that could simplify that a lot. However, seeing as you're always asking questions about the code, adding in a bunch of array functions would be counter-productive.
Correct me If I am wrong basically this code is
[PHP]
$counterx=0;
while($row=mysql_fetch_array($resultpostal)){
foreach($row as $col_value){
$temp[$counterx]=$col_value;
$counterx++;
}
$report.='uid'."=".$temp[0]."&";
$report.='uname'."=".$temp[1]."&"
[/PHP]
Creating a counterx first then store the whole $resultpostal inside row then foreach row as $col_value then the counterx will + 1 if there is a value to be store inside the $temp that mean in my case it will just increment 2 time as I only select the uid and uname correct?
Then bottom is sending the uid and uname to the actionscript erm am I correct?
Just trying to learn this code thx
Correct me If I am wrong basically this code is
[PHP]
$counterx=0;
while($row=mysql_fetch_array($resultpostal)){
foreach($row as $col_value){
$temp[$counterx]=$col_value;
$counterx++;
}
$report.='uid'."=".$temp[0]."&";
$report.='uname'."=".$temp[1]."&"
[/PHP]
Creating a counterx first then store the whole $resultpostal inside row then foreach row as $col_value then the counterx will + 1 if there is a value to be store inside the $temp that mean in my case it will just increment 2 time as I only select the uid and uname correct?
Then bottom is sending the uid and uname to the actionscript erm am I correct?
Just trying to learn this code thx
Yes you can increment it only 2 times...
And remember when you want to retrieve what you had stored in
$temp[$counterx], you'll have to call it like this $temp[0] or $temp[1] beacuse it started with zero and incremented.
I'm glad that it helped you.
Yes you can increment it only 2 times...
And remember when you want to retrieve what you had stored in
$temp[$counterx], you'll have to call it like this $temp[0] or $temp[1] beacuse it started with zero and incremented.
I'm glad that it helped you.
Thank alot for your wonderful help thx thx
Guy need some help again basically this code right is returning my actionscript undefined value:
[PHP]
if($_GET['postal']))
$postalcode=substr($_GET['postal'],0,2); //will return from 0 position 2 characters
$resultpostal=mysql_query("SELECT location.uname,location.uid FROM location,districts WHERE districts.districtno ='$postalcode' AND
location.lat BETWEEN districts.startlat AND districts.endlat AND location.lng BETWEEN districts.startlng AND districts.endlng");
[/PHP]
Mean that it is quite unable to get the postal code from actionscripts?
Then I did another test run like that
[PHP]
$resultpostal=mysql_query("SELECT location.uname,location.uid FROM location,districts WHERE districts.districtno ='56'AND
location.lat BETWEEN districts.startlat AND districts.endlat AND location.lng BETWEEN districts.startlng AND districts.endlng");
[/PHP]
I change to districtno=56 and it does return me the uname but the problem is how come the top part the GET POSTAL section code always return me undefined value iszit something wrong with the GET method?
You're code is really making less and less sense. What does "if($_GET['postal']))" do? Why are there two ending parentheses? Why aren't you using isset()?
You're code is really making less and less sense. What does "if($_GET['postal']))" do? Why are there two ending parentheses? Why aren't you using isset()?
I use the GET postal is to get the input postal code by the user from actionscripts and use php to extact out the first 2 value you mean something is wrong with the way I get the postal from acitonscriptS?
I don't think I can use the isset() function because I am taking a pass value from the actionscript and the isset() only works with variables as passing anything else will result in a parse error
I don't think I can use the isset() function because I am taking a pass value from the actionscript and the isset() only works with variables as passing anything else will result in a parse error
What? The PURPOSE of isset() is to check and see if the variable exists or not. Do you think that $_GET is not a variable?
Heya, Rocky.
What do you want your code to do? Give an example.
What is your code doing that you don't want it to do? Give an example.
What is your code *not* doing that it is supposed to? Give an example.
Heya, Rocky.
What do you want your code to do? Give an example.
What is your code doing that you don't want it to do? Give an example.
What is your code *not* doing that it is supposed to? Give an example.
I want my code to be able to GET the postal from actionscript, the postal is a user input in actionscripts
My code is unable to GET the postal from the actionscripts
My code is suppoosed to get the postal number example 560894 and in PHP it will extact out the first 2 number which is 56 and store it inside a variable to compare it in the SQL statement and show the record that matches the 56 .
I want my code to be able to GET the postal from actionscript, the postal is a user input in actionscripts
My code is unable to GET the postal from the actionscripts
My code is suppoosed to get the postal number example 560894 and in PHP it will extact out the first 2 number which is 56 and store it inside a variable to compare it in the SQL statement and show the record that matches the 56 .
And in your ActionScript, you send this data through the URL?
And in your ActionScript, you send this data through the URL?
No is not throught URL is through PHP
My actionscripts: -
postalOut.postal=assign.postal.text;
-
var postalOut:LoadVars = new LoadVars();
-
postalOut.sendAndLoad(passingurl, postalIn, "POST");
-
My PHP:
[PHP]
$postalno=substr($_POST['postal'],0,2);
$resultpostal=mysql_query("SELECT location.uname,location.uid FROM location,districts WHERE districts.districtno ='$postalno' AND
location.lat BETWEEN districts.startlat AND districts.endlat AND location.lng BETWEEN districts.startlng AND districts.endlng");
[/PHP]
I try both the GET and POST method it does not seen to work
I haven't done anything in ActionScript in a while... Try sending the variables to this test script and get the data:
[php]echo 'GET: ' . print_r($_GET, true) . "\n\n" . 'POST: ' . print_r($_POST, true);[/php]
That should show you if the requests are going through the way you think they are.
I haven't done anything in ActionScript in a while... Try sending the variables to this test script and get the data:
[php]echo 'GET: ' . print_r($_GET, true) . "\n\n" . 'POST: ' . print_r($_POST, true);[/php]
That should show you if the requests are going through the way you think they are.
Just want to know is this the correct way to put in a variable in SQL statement?
[PHP]
$postalno=$_GET["postal"];
$resultpostal=mysql_query("SELECT location.uname,location.uid FROM location,districts WHERE districts.districtno ='".$postalno."' AND
location.lat BETWEEN districts.startlat AND districts.endlat AND location.lng BETWEEN districts.startlng AND districts.endlng");
[/PHP]
WHERE districts.districtno = '".$postalno."'
or
WHERE districts.districtno = '$postalno'
WHERE districts.districtno ='".$postalno."'
or
WHERE districts.districtno ='$postalno'
Those are the exact same thing.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: - |
last post by:
Hi to All,
To reproduce:
The expression:
object result = flag ? (long) 0 : (double) 0;
always evaluated as a double... see dissassembly to ensure the bad compiled
code.
|
by: hazz |
last post by:
before I start filling up the first page of perhaps many pages of code with
if/then or switch:case buckets, I wanted to step back and see if there is a
better way...
I will have a table with up to...
|
by: MS newsgroup |
last post by:
I don't have clear reasons why we need business logic layer and data logic
layer instead of having only data logic layer.
Are there any good reasons for that?
|
by: JoeC |
last post by:
I am writing a game and I am having a challenge with my combat
function. All I want to do is find out how to group pieces that are in
the same space. There are two sides and all the units that...
|
by: Frank van Wensveen |
last post by:
Friend, coders, fellow wage slaves, lend my your ears.
I believe that in a perfect world the design of a website (or feature
on a website) should be totally separated from its design and the data...
|
by: Bob Jones |
last post by:
I have an odd business requirement and I think that the implementation
is not correct in the terms of OOP development. Any help on the
concepts would be very appreciated!
We currently have a...
|
by: Jonathan |
last post by:
Hi all,
I have a file consisting fixed width records from which I need to
extract only those lines meeting certain conditions.
These conditions do change and I find myself recoding/compiling...
|
by: bruno.desthuilliers |
last post by:
On 27 juin, 18:09, "John Salerno" <johnj...@NOSPAMgmail.comwrote:
For which definitions of "content" and "logic" ???
The point of mvc is to keep domain logic separated from presentation
logic,...
|
by: vamsioracle |
last post by:
Hi Folks
I have written a code to send emails from oracle. Below is the code. I have registered this is Apps and scheduled the concurrent program to run every day. Now i want implement logic, such...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |