473,322 Members | 1,408 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,322 software developers and data experts.

What is this PHP code all about?

93
Hi ppl anyone care to explain to me what is the following PHP code doing?
[PHP]
$uname=$_GET["uname"];
if($uname=="all")
{
$fetched=mysql_query("SELECT * FROM location");

while($row = mysql_fetch_array($fetched))
{
$temp[]=$row;
}

foreach($temp as $extract)
foreach($extract as $key=>$info)
{
if(!is_numeric($key)) //somehow it returns number & name of key.so take 1.
$coordinates[$key]=$info;
}

foreach($coordinates as $key=>$extract)
$report=$report.$key."=".$extract."&";


echo $report;
}
else
{
$fetched=mysql_query("SELECT * FROM location WHERE uname='".$uname."'");

while($row = mysql_fetch_array($fetched))
{
$temp[]=$row;
}

foreach($temp as $extract)
foreach($extract as $key=>$info)
{
if(!is_numeric($key)) //somehow it returns number & name of key.so take 1.
$coordinates[$key]=$info;
}

foreach($coordinates as $key=>$extract)
$report=$report.$key."=".$extract."&";


echo $report;
}

mysql_close($con);

[/PHP]
Jul 9 '07 #1
1 1254
dafodil
392 256MB
Expand|Select|Wrap|Line Numbers
  1. $uname=$_GET["uname"];
  2.  
You are trying to retrieve a value from a previous page with a method get....

Now you are trying to detect if $uname has a value of all
Expand|Select|Wrap|Line Numbers
  1. if($uname=="all")
  2. {
  3.   $fetched=mysql_query("SELECT * FROM location");
  4.  
  5.    while($row = mysql_fetch_array($fetched))
  6.    {
  7.       $temp[]=$row;
  8.    }
  9.  
  10.  
You are trying to retrieve the datas stored from the database whose table name is location, then you store each record in an array
Expand|Select|Wrap|Line Numbers
  1.    foreach($temp as $extract)
  2.      foreach($extract as $key=>$info)
  3.      {
  4.         if(!is_numeric($key))  //somehow it returns number & name of key.so take 1.
  5.             $coordinates[$key]=$info;
  6.             }
  7.  
You detect if what you extracted from $temp is not numeric and store it in $coordinates...
Expand|Select|Wrap|Line Numbers
  1.     foreach($coordinates as $key=>$extract)
  2.         $report=$report.$key."=".$extract."&";
  3.  
  4.  
  5.      echo $report;
  6. }
  7.  
You store the values in the $coordinates and $extract into $report and display them in the screen....
Expand|Select|Wrap|Line Numbers
  1.     else
  2.     {
  3.         $fetched=mysql_query("SELECT * FROM location WHERE uname='".$uname."'");
  4.  
  5.         while($row = mysql_fetch_array($fetched))
  6.         {
  7.             $temp[]=$row;
  8.         }
  9.  
  10.         foreach($temp as $extract)
  11.             foreach($extract as $key=>$info)
  12.             {
  13.                 if(!is_numeric($key))  //somehow it returns number & name of key.so take 1.
  14.                 $coordinates[$key]=$info;
  15.             }
  16.  
  17.         foreach($coordinates as $key=>$extract)
  18.             $report=$report.$key."=".$extract."&";
  19.  
  20.  
  21.         echo $report;
  22.     }
  23.  
Does the same except you are trying to fetch the uname whose value is not equal to all...
Expand|Select|Wrap|Line Numbers
  1.     mysql_close($con);
  2.  
Close the specified connection from the db..
Jul 9 '07 #2

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

Similar topics

23
by: darwinist | last post by:
What PHP Represents There is no shortage of complaints one could make about php as a language, and although the list does shrink with each release, some of them are inherent to the origins and...
54
by: Brandon J. Van Every | last post by:
I'm realizing I didn't frame my question well. What's ***TOTALLY COMPELLING*** about Ruby over Python? What makes you jump up in your chair and scream "Wow! Ruby has *that*? That is SO...
92
by: Reed L. O'Brien | last post by:
I see rotor was removed for 2.4 and the docs say use an AES module provided separately... Is there a standard module that works alike or an AES module that works alike but with better encryption?...
137
by: Philippe C. Martin | last post by:
I apologize in advance for launching this post but I might get enlightment somehow (PS: I am _very_ agnostic ;-). - 1) I do not consider my intelligence/education above average - 2) I am very...
125
by: Sarah Tanembaum | last post by:
Beside its an opensource and supported by community, what's the fundamental differences between PostgreSQL and those high-price commercial database (and some are bloated such as Oracle) from...
2
by: Dan Allen | last post by:
have a lot of questions about ASP.Net. 1. What products do I need from Microsoft to develop and run ASP.NET As background, I currently use Visual InterDev to make ASP applications deployed on...
121
by: typingcat | last post by:
First of all, I'm an Asian and I need to input Japanese, Korean and so on. I've tried many PHP IDEs today, but almost non of them supported Unicode (UTF-8) file. I've found that the only Unicode...
46
by: Keith K | last post by:
Having developed with VB since 1992, I am now VERY interested in C#. I've written several applications with C# and I do enjoy the language. What C# Needs: There are a few things that I do...
13
by: Jason Huang | last post by:
Hi, Would someone explain the following coding more detail for me? What's the ( ) for? CurrentText = (TextBox)e.Item.Cells.Controls; Thanks. Jason
36
by: Pat | last post by:
Hi, I've run into a strange problem, but one that seems like it might be fairly common. I have a single base class, from which several other classes are derived. To keep the example simple,...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.