473,387 Members | 1,834 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to use this logic to apply to my code?

93
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;
Aug 1 '07 #1
29 1725
ronnil
134 Expert 100+
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
Aug 1 '07 #2
Rocky86
93
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]
Aug 1 '07 #3
Rocky86
93
Is anyone around to help?
Aug 1 '07 #4
Rocky86
93
Is it reallx no one??????????
Aug 2 '07 #5
dafodil
392 256MB
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?
Aug 2 '07 #6
Rocky86
93
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]
Aug 2 '07 #7
dafodil
392 256MB
Expand|Select|Wrap|Line Numbers
  1. $temp[]=$row[uid];
  2.  $temp1[]=$row[uname];
  3.  
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.
Aug 2 '07 #8
Rocky86
93
Expand|Select|Wrap|Line Numbers
  1. $temp[]=$row[uid];
  2.  $temp1[]=$row[uname];
  3.  
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
Aug 2 '07 #9
dafodil
392 256MB
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.....
Aug 2 '07 #10
Rocky86
93
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 !!!
Aug 2 '07 #11
Rocky86
93
dafodil mind if I ask why do you create a counter? $counterx=0;
Aug 2 '07 #12
kovik
1,044 Expert 1GB
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.
Aug 2 '07 #13
Rocky86
93
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
Aug 3 '07 #14
dafodil
392 256MB
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.
Aug 3 '07 #15
Rocky86
93
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
Aug 3 '07 #16
Rocky86
93
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?
Aug 3 '07 #17
Rocky86
93
Anyone around to help?
Aug 4 '07 #18
kovik
1,044 Expert 1GB
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()?
Aug 4 '07 #19
Rocky86
93
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?
Aug 4 '07 #20
Rocky86
93
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
Aug 5 '07 #21
kovik
1,044 Expert 1GB
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?
Aug 5 '07 #22
pbmods
5,821 Expert 4TB
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.
Aug 5 '07 #23
Rocky86
93
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 .
Aug 6 '07 #24
kovik
1,044 Expert 1GB
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?
Aug 6 '07 #25
Rocky86
93
And in your ActionScript, you send this data through the URL?
No is not throught URL is through PHP

My actionscripts:
Expand|Select|Wrap|Line Numbers
  1. postalOut.postal=assign.postal.text;
  2. var postalOut:LoadVars = new LoadVars();
  3. postalOut.sendAndLoad(passingurl, postalIn, "POST");
  4.  
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
Aug 6 '07 #26
kovik
1,044 Expert 1GB
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.
Aug 6 '07 #27
Rocky86
93
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'
Aug 6 '07 #28
kovik
1,044 Expert 1GB
WHERE districts.districtno ='".$postalno."'
or
WHERE districts.districtno ='$postalno'
Those are the exact same thing.
Aug 6 '07 #29
pbmods
5,821 Expert 4TB
Heya, Rocky.

Check out this document.
Aug 6 '07 #30

Sign in to post your reply or Sign up for a free account.

Similar topics

8
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.
11
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...
16
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?
73
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...
10
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...
12
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...
10
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...
15
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,...
5
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...
0
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,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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...
0
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...
0
BarryA
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...
1
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...
0
marktang
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,...
0
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...
0
Oralloy
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,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.