471,319 Members | 1,602 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

using the unpack function to grab a field name

I have used this function to create a string called $headers:

function GetHeaders($file_name){
return "<th><a href='".$file_name."&order_by=l_e'>L_E</a></th>
<th><a href='".
$file_name."&order_by=carnumber'>Carnumber</a></th>
<th><a href='".
$file_name."&order_by=location'>Location</a></th>
<th><a href='".
$file_name."&order_by=sighting_date_asc'>Sighting
Date</a></th>
<th><a href='".
$file_name."&order_by=classification'>Code</a></th>
<th><a href='".$file_name."&order_by=railroad'>RR</a></
th>
<th><a href='".$file_name."order_by=origin'>Origin</
a></th>
<th><a href='".
$file_name."&order_by=destination'>Destination</a></
th>
<th width='15%'><a href='".$file_name."'>ETA</a></
th>";

}

Now I want to unpack the $header array and create two strings,
called s1 and s2. I want s1 to be field names for excel and s2 to
be the column names. For example l_e is the field name and L_E is
capitalized to be the column header in Excel. In other words, I want
is the two fields after the order_by= without the 'and the </a>.

How to use unpack?

s1=unpack($headers/37, 9, $data)

I don't know how to use unpack but I have the $header array as the
string, I counted 37 characters to the word order_by and the word
order_by= is 9 characters I want to grab that word before the '.
How do I make use of the unpack function to get what I want?

I forgot to mention it would be good if I could make it dynamic
instead of a hardwired number because I have many of these strings
that are the same with different field names.

tia,
Sep 9 '08 #1
19 1705
JRough wrote:
I have used this function to create a string called $headers:

function GetHeaders($file_name){
return "<th><a href='".$file_name."&order_by=l_e'>L_E</a></th>
<th><a href='".
$file_name."&order_by=carnumber'>Carnumber</a></th>
<th><a href='".
$file_name."&order_by=location'>Location</a></th>
<th><a href='".
$file_name."&order_by=sighting_date_asc'>Sighting
Date</a></th>
<th><a href='".
$file_name."&order_by=classification'>Code</a></th>
<th><a href='".$file_name."&order_by=railroad'>RR</a></
th>
<th><a href='".$file_name."order_by=origin'>Origin</
a></th>
<th><a href='".
$file_name."&order_by=destination'>Destination</a></
th>
<th width='15%'><a href='".$file_name."'>ETA</a></
th>";

}

Now I want to unpack the $header array and create two strings,
called s1 and s2. I want s1 to be field names for excel and s2 to
be the column names. For example l_e is the field name and L_E is
capitalized to be the column header in Excel. In other words, I want
is the two fields after the order_by= without the 'and the </a>.

How to use unpack?

s1=unpack($headers/37, 9, $data)

I don't know how to use unpack but I have the $header array as the
string, I counted 37 characters to the word order_by and the word
order_by= is 9 characters I want to grab that word before the '.
How do I make use of the unpack function to get what I want?

I forgot to mention it would be good if I could make it dynamic
instead of a hardwired number because I have many of these strings
that are the same with different field names.

tia,
See my response to your other post on this subject.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Sep 9 '08 #2
On Sep 9, 2:13*pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
JRough wrote:
I have used this function to create a string called $headers:
function GetHeaders($file_name){
* return "<th><a href='".$file_name."&order_by=l_e'>L_E</a></th>
* * * * * * * * <th><a href='".
$file_name."&order_by=carnumber'>Carnumber</a></th>
* * * * * * * * <th><a href='".
$file_name."&order_by=location'>Location</a></th>
* * * * * * * * <th><a href='".
$file_name."&order_by=sighting_date_asc'>Sighting
Date</a></th>
* * * * * * * * <th><a href='".
$file_name."&order_by=classification'>Code</a></th>
* * * * * * * * <th><a href='".$file_name."&order_by=railroad'>RR</a></
th>
* * * * * * * * <th><a href='".$file_name."order_by=origin'>Origin</
a></th>
* * * * * * * * <th><a href='".
$file_name."&order_by=destination'>Destination</a></
th>
* * * * * * * * <th width='15%'><a href='".$file_name."'>ETA</a></
th>";
}
Now I want to *unpack the $header array and create two *strings,
called s1 and s2. *I want s1 to be *field names for *excel *ands2 to
be the column names. *For example l_e is the *field name and L_E is
capitalized to be the column header in Excel. *In other words, I want
is the two fields after the order_by= without the 'and the </a>.
How to use unpack?
s1=unpack($headers/37, 9, $data)
I don't know how to use unpack but I have the $header array as the
string, I counted 37 characters to the word order_by and the word
order_by= is 9 characters I want to grab that word before the '.
How do I make use of the unpack function to get what I want?
I forgot to mention it would be good if I could make it dynamic
instead of a hardwired number because I have many of these strings
that are the same with different field names.
tia,

See my response to your other post on this subject.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================
get is not a variable, it is only an anchor. I need to know how to
unpack the array.
Sep 9 '08 #3
JRough wrote:
On Sep 9, 2:13 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
>JRough wrote:
>>I have used this function to create a string called $headers:
function GetHeaders($file_name){
return "<th><a href='".$file_name."&order_by=l_e'>L_E</a></th>
<th><a href='".
$file_name."&order_by=carnumber'>Carnumber</a></th>
<th><a href='".
$file_name."&order_by=location'>Location</a></th>
<th><a href='".
$file_name."&order_by=sighting_date_asc'>Sightin g
Date</a></th>
<th><a href='".
$file_name."&order_by=classification'>Code</a></th>
<th><a href='".$file_name."&order_by=railroad'>RR</a></
th>
<th><a href='".$file_name."order_by=origin'>Origin</
a></th>
<th><a href='".
$file_name."&order_by=destination'>Destination </a></
th>
<th width='15%'><a href='".$file_name."'>ETA</a></
th>";
}
Now I want to unpack the $header array and create two strings,
called s1 and s2. I want s1 to be field names for excel and s2 to
be the column names. For example l_e is the field name and L_E is
capitalized to be the column header in Excel. In other words, I want
is the two fields after the order_by= without the 'and the </a>.
How to use unpack?
s1=unpack($headers/37, 9, $data)
I don't know how to use unpack but I have the $header array as the
string, I counted 37 characters to the word order_by and the word
order_by= is 9 characters I want to grab that word before the '.
How do I make use of the unpack function to get what I want?
I forgot to mention it would be good if I could make it dynamic
instead of a hardwired number because I have many of these strings
that are the same with different field names.
tia,
See my response to your other post on this subject.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================

get is not a variable, it is only an anchor. I need to know how to
unpack the array.
No, $_GET is an array of the name/value pairs passed in a GET request -
which is the type of request you get from an anchor (<a href...) tag.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Sep 10 '08 #4
JRough wrote:
On Sep 9, 2:13 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
>JRough wrote:
>>I have used this function to create a string called $headers:
function GetHeaders($file_name){
return "<th><a href='".$file_name."&order_by=l_e'>L_E</a></th>
<th><a href='".
$file_name."&order_by=carnumber'>Carnumber</a></th>
<th><a href='".
$file_name."&order_by=location'>Location</a></th>
<th><a href='".
$file_name."&order_by=sighting_date_asc'>Sightin g
Date</a></th>
<th><a href='".
$file_name."&order_by=classification'>Code</a></th>
<th><a href='".$file_name."&order_by=railroad'>RR</a></
th>
<th><a href='".$file_name."order_by=origin'>Origin</
a></th>
<th><a href='".
$file_name."&order_by=destination'>Destination </a></
th>
<th width='15%'><a href='".$file_name."'>ETA</a></
th>";
}
Now I want to unpack the $header array and create two strings,
called s1 and s2. I want s1 to be field names for excel and s2 to
be the column names. For example l_e is the field name and L_E is
capitalized to be the column header in Excel. In other words, I want
is the two fields after the order_by= without the 'and the </a>.
How to use unpack?
s1=unpack($headers/37, 9, $data)
I don't know how to use unpack but I have the $header array as the
string, I counted 37 characters to the word order_by and the word
order_by= is 9 characters I want to grab that word before the '.
How do I make use of the unpack function to get what I want?
I forgot to mention it would be good if I could make it dynamic
instead of a hardwired number because I have many of these strings
that are the same with different field names.
tia,
See my response to your other post on this subject.

get is not a variable, it is only an anchor. I need to know how to
unpack the array.
You're misunderstanding things here. Your very difficult-to-read
function body simply returns a string (try heredocs), there is no
array involved from where I can see. When the user clicks one of those
links, the query string variables are sent to $file_name.

The code in $file_name should use $_GET to handle the data in the
query string. $_GET['order_by'] will output 'railroad', or whatever.
You won't need unpack() unless you're planning to manually parse the
query string, but there's absolutely no reason to do that in PHP. :)

Also, there's no need to post two (or more) threads for the same question.

--
Curtis
Sep 10 '08 #5
On Sep 9, 7:58*pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
JRough wrote:
On Sep 9, 2:13 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
JRough wrote:
I have used this function to create a string called $headers:
function GetHeaders($file_name){
* return "<th><a href='".$file_name."&order_by=l_e'>L_E</a></th>
* * * * * * * * <th><a href='".
$file_name."&order_by=carnumber'>Carnumber</a></th>
* * * * * * * * <th><a href='".
$file_name."&order_by=location'>Location</a></th>
* * * * * * * * <th><a href='".
$file_name."&order_by=sighting_date_asc'>Sighti ng
Date</a></th>
* * * * * * * * <th><a href='".
$file_name."&order_by=classification'>Code</a></th>
* * * * * * * * <th><a href='".$file_name."&order_by=railroad'>RR</a></
th>
* * * * * * * * <th><a href='".$file_name."order_by=origin'>Origin</
a></th>
* * * * * * * * <th><a href='".
$file_name."&order_by=destination'>Destination</a></
th>
* * * * * * * * <th width='15%'><a href='".$file_name."'>ETA</a></
th>";
}
Now I want to *unpack the $header array and create two *strings,
called s1 and s2. *I want s1 to be *field names for *excel *and s2 to
be the column names. *For example l_e is the *field name and L_E is
capitalized to be the column header in Excel. *In other words, I want
is the two fields after the order_by= without the 'and the </a>.
How to use unpack?
s1=unpack($headers/37, 9, $data)
I don't know how to use unpack but I have the $header array as the
string, I counted 37 characters to the word order_by and the word
order_by= is 9 characters I want to grab that word before the '.
How do I make use of the unpack function to get what I want?
I forgot to mention it would be good if I could make it dynamic
instead of a hardwired number because I have many of these strings
that are the same with different field names.
tia,
See my response to your other post on this subject.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================
get is not a variable, it is only an anchor. *I need to know how to
unpack the array.

No, $_GET is an array of the name/value pairs passed in a GET request -
which is the type of request you get from an anchor (<a href...) tag.
JERRY
I got Array() as the output when I did print_r($_GET)
Janis

Sep 10 '08 #6
On Sep 9, 7:58*pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
JRough wrote:
On Sep 9, 2:13 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
JRough wrote:
I have used this function to create a string called $headers:
function GetHeaders($file_name){
* return "<th><a href='".$file_name."&order_by=l_e'>L_E</a></th>
* * * * * * * * <th><a href='".
$file_name."&order_by=carnumber'>Carnumber</a></th>
* * * * * * * * <th><a href='".
$file_name."&order_by=location'>Location</a></th>
* * * * * * * * <th><a href='".
$file_name."&order_by=sighting_date_asc'>Sighti ng
Date</a></th>
* * * * * * * * <th><a href='".
$file_name."&order_by=classification'>Code</a></th>
* * * * * * * * <th><a href='".$file_name."&order_by=railroad'>RR</a></
th>
* * * * * * * * <th><a href='".$file_name."order_by=origin'>Origin</
a></th>
* * * * * * * * <th><a href='".
$file_name."&order_by=destination'>Destination</a></
th>
* * * * * * * * <th width='15%'><a href='".$file_name."'>ETA</a></
th>";
}
Now I want to *unpack the $header array and create two *strings,
called s1 and s2. *I want s1 to be *field names for *excel *and s2 to
be the column names. *For example l_e is the *field name and L_E is
capitalized to be the column header in Excel. *In other words, I want
is the two fields after the order_by= without the 'and the </a>.
How to use unpack?
s1=unpack($headers/37, 9, $data)
I don't know how to use unpack but I have the $header array as the
string, I counted 37 characters to the word order_by and the word
order_by= is 9 characters I want to grab that word before the '.
How do I make use of the unpack function to get what I want?
I forgot to mention it would be good if I could make it dynamic
instead of a hardwired number because I have many of these strings
that are the same with different field names.
tia,
See my response to your other post on this subject.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================
get is not a variable, it is only an anchor. *I need to know how to
unpack the array.

No, $_GET is an array of the name/value pairs passed in a GET request -
which is the type of request you get from an anchor (<a href...) tag.
I did print_r($_GET) and I got a result:
Array( )
Select * from Internal_Settings

The select query is to a table that only has the url and the site
name.
The data pairs are being sent to the web site?
I don't know why it is saying Array( ) though

Sep 10 '08 #7
JRough wrote:
On Sep 9, 7:58 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
>JRough wrote:
>>On Sep 9, 2:13 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
JRough wrote:
I have used this function to create a string called $headers:
function GetHeaders($file_name){
return "<th><a href='".$file_name."&order_by=l_e'>L_E</a></th>
<th><a href='".
$file_name."&order_by=carnumber'>Carnumber</a></th>
<th><a href='".
$file_name."&order_by=location'>Location</a></th>
<th><a href='".
$file_name."&order_by=sighting_date_asc'>Sight ing
Date</a></th>
<th><a href='".
$file_name."&order_by=classification'>Code</a></th>
<th><a href='".$file_name."&order_by=railroad'>RR</a></
th>
<th><a href='".$file_name."order_by=origin'>Origin</
a></th>
<th><a href='".
$file_name."&order_by=destination'>Destination </a></
th>
<th width='15%'><a href='".$file_name."'>ETA</a></
th>";
}
Now I want to unpack the $header array and create two strings,
called s1 and s2. I want s1 to be field names for excel and s2 to
be the column names. For example l_e is the field name and L_E is
capitalized to be the column header in Excel. In other words, I want
is the two fields after the order_by= without the 'and the </a>.
How to use unpack?
s1=unpack($headers/37, 9, $data)
I don't know how to use unpack but I have the $header array as the
string, I counted 37 characters to the word order_by and the word
order_by= is 9 characters I want to grab that word before the '.
How do I make use of the unpack function to get what I want?
I forgot to mention it would be good if I could make it dynamic
instead of a hardwired number because I have many of these strings
that are the same with different field names.
tia,
See my response to your other post on this subject.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================
get is not a variable, it is only an anchor. I need to know how to
unpack the array.
No, $_GET is an array of the name/value pairs passed in a GET request -
which is the type of request you get from an anchor (<a href...) tag.
JERRY
I got Array() as the output when I did print_r($_GET)
Janis

Are you sure you did print_r() instead of print()? print_r() expands
the array.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Sep 10 '08 #8
On Sep 10, 9:55*am, Jerry Stuckle <jstuck...@attglobal.netwrote:
JRough wrote:
On Sep 9, 7:58 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
JRough wrote:
On Sep 9, 2:13 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
JRough wrote:
I have used this function to create a string called $headers:
function GetHeaders($file_name){
* return "<th><a href='".$file_name."&order_by=l_e'>L_E</a></th>
* * * * * * * * <th><a href='".
$file_name."&order_by=carnumber'>Carnumber</a></th>
* * * * * * * * <th><a href='".
$file_name."&order_by=location'>Location</a></th>
* * * * * * * * <th><a href='".
$file_name."&order_by=sighting_date_asc'>Sighti ng
Date</a></th>
* * * * * * * * <th><a href='".
$file_name."&order_by=classification'>Code</a></th>
* * * * * * * * <th><a href='".$file_name."&order_by=railroad'>RR</a></
th>
* * * * * * * * <th><a href='".$file_name."order_by=origin'>Origin</
a></th>
* * * * * * * * <th><a href='".
$file_name."&order_by=destination'>Destinatio n</a></
th>
* * * * * * * * <th width='15%'><a href='".$file_name."'>ETA</a></
th>";
}
Now I want to *unpack the $header array and create two *strings,
called s1 and s2. *I want s1 to be *field names for *excel *and s2 to
be the column names. *For example l_e is the *field name and L_E is
capitalized to be the column header in Excel. *In other words, I want
is the two fields after the order_by= without the 'and the </a>..
How to use unpack?
s1=unpack($headers/37, 9, $data)
I don't know how to use unpack but I have the $header array as the
string, I counted 37 characters to the word order_by and the word
order_by= is 9 characters I want to grab that word before the '..
How do I make use of the unpack function to get what I want?
I forgot to mention it would be good if I could make it dynamic
instead of a hardwired number because I have many of these strings
that are the same with different field names.
tia,
See my response to your other post on this subject.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================
get is not a variable, it is only an anchor. *I need to know how to
unpack the array.
No, $_GET is an array of the name/value pairs passed in a GET request -
which is the type of request you get from an anchor (<a href...) tag.
JERRY
I got Array() as the output when I did print_r($_GET)
Janis

Are you sure you did print_r() instead of print()? *print_r() expands
the array.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================
I did print_r a couple times. At first I thought I just got the
message Array( ) and a blank page with the home menu
but then I noticed under the home menu at the bottom is select *
internal_settings. I wonder if a query is blocking it or it
just wants the array data to pass to the site url?

I think I need to get the data out of the array if I can get the data
to print.
I am trying to write a while loop:

do{
$value = $value + isset($_GET['order_by'])? $_GET['order_by'] : '' ;
print_r($_GET);
} while ($_GET['order_by']) >0;

I get an error on the last line.

I guess I should stop with the while loop until I get the data out of
the array.
Sep 10 '08 #9
On Sep 10, 9:55*am, Jerry Stuckle <jstuck...@attglobal.netwrote:
JRough wrote:
On Sep 9, 7:58 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
JRough wrote:
On Sep 9, 2:13 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
JRough wrote:
I have used this function to create a string called $headers:
function GetHeaders($file_name){
* return "<th><a href='".$file_name."&order_by=l_e'>L_E</a></th>
* * * * * * * * <th><a href='".
$file_name."&order_by=carnumber'>Carnumber</a></th>
* * * * * * * * <th><a href='".
$file_name."&order_by=location'>Location</a></th>
* * * * * * * * <th><a href='".
$file_name."&order_by=sighting_date_asc'>Sighti ng
Date</a></th>
* * * * * * * * <th><a href='".
$file_name."&order_by=classification'>Code</a></th>
* * * * * * * * <th><a href='".$file_name."&order_by=railroad'>RR</a></
th>
* * * * * * * * <th><a href='".$file_name."order_by=origin'>Origin</
a></th>
* * * * * * * * <th><a href='".
$file_name."&order_by=destination'>Destinatio n</a></
th>
* * * * * * * * <th width='15%'><a href='".$file_name."'>ETA</a></
th>";
}
Now I want to *unpack the $header array and create two *strings,
called s1 and s2. *I want s1 to be *field names for *excel *and s2 to
be the column names. *For example l_e is the *field name and L_E is
capitalized to be the column header in Excel. *In other words, I want
is the two fields after the order_by= without the 'and the </a>..
How to use unpack?
s1=unpack($headers/37, 9, $data)
I don't know how to use unpack but I have the $header array as the
string, I counted 37 characters to the word order_by and the word
order_by= is 9 characters I want to grab that word before the '..
How do I make use of the unpack function to get what I want?
I forgot to mention it would be good if I could make it dynamic
instead of a hardwired number because I have many of these strings
that are the same with different field names.
tia,
See my response to your other post on this subject.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================
get is not a variable, it is only an anchor. *I need to know how to
unpack the array.
No, $_GET is an array of the name/value pairs passed in a GET request -
which is the type of request you get from an anchor (<a href...) tag.
JERRY
I got Array() as the output when I did print_r($_GET)
Janis

Are you sure you did print_r() instead of print()? *print_r() expands
the array.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================
I did it again one more time. I commented out the while loop. I got
this:
Array ( )
| HOME | LOGIN | LOGOUT |

select * from INTERNAL_settings

-------------
}else{

#do{
#$value = $value + isset($_GET['order_by'])? $_GET['order_by'] : '' ;
#print_r($_GET);
#} while ($_GET['order_by']) >0;

$value = isset($_GET['order_by'])? $_GET['order_by'] : '' ;
print_r($_GET);
#$data.=makexcl();
}
include "footer.php";
Sep 10 '08 #10
JRough wrote:
On Sep 10, 9:55 am, Jerry Stuckle <jstuck...@attglobal.netwrote:
>JRough wrote:
>>On Sep 9, 7:58 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
JRough wrote:
On Sep 9, 2:13 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
>JRough wrote:
>>I have used this function to create a string called $headers:
>>function GetHeaders($file_name){
>> return "<th><a href='".$file_name."&order_by=l_e'>L_E</a></th>
>> <th><a href='".
>>$file_name."&order_by=carnumber'>Carnumber </a></th>
>> <th><a href='".
>>$file_name."&order_by=location'>Location</a></th>
>> <th><a href='".
>>$file_name."&order_by=sighting_date_asc'>Sig hting
>>Date</a></th>
>> <th><a href='".
>>$file_name."&order_by=classification'>Code </a></th>
>> <th><a href='".$file_name."&order_by=railroad'>RR</a></
>>th>
>> <th><a href='".$file_name."order_by=origin'>Origin</
>>a></th>
>> <th><a href='".
>>$file_name."&order_by=destination'>Destinati on</a></
>>th>
>> <th width='15%'><a href='".$file_name."'>ETA</a></
>>th>";
>>}
>>Now I want to unpack the $header array and create two strings,
>>called s1 and s2. I want s1 to be field names for excel and s2 to
>>be the column names. For example l_e is the field name and L_E is
>>capitalized to be the column header in Excel. In other words, I want
>>is the two fields after the order_by= without the 'and the </a>.
>>How to use unpack?
>>s1=unpack($headers/37, 9, $data)
>>I don't know how to use unpack but I have the $header array as the
>>string, I counted 37 characters to the word order_by and the word
>>order_by= is 9 characters I want to grab that word before the '.
>>How do I make use of the unpack function to get what I want?
>>I forgot to mention it would be good if I could make it dynamic
>>instead of a hardwired number because I have many of these strings
>>that are the same with different field names.
>>tia,
>See my response to your other post on this subject.
>--
>==================
>Remove the "x" from my email address
>Jerry Stuckle
>JDS Computer Training Corp.
>jstuck...@attglobal.net
>==================
get is not a variable, it is only an anchor. I need to know how to
unpack the array.
No, $_GET is an array of the name/value pairs passed in a GET request -
which is the type of request you get from an anchor (<a href...) tag.
JERRY
I got Array() as the output when I did print_r($_GET)
Janis
Are you sure you did print_r() instead of print()? print_r() expands
the array.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================
I did print_r a couple times. At first I thought I just got the
message Array( ) and a blank page with the home menu
but then I noticed under the home menu at the bottom is select *
internal_settings. I wonder if a query is blocking it or it
just wants the array data to pass to the site url?

I think I need to get the data out of the array if I can get the data
to print.
I am trying to write a while loop:

do{
$value = $value + isset($_GET['order_by'])? $_GET['order_by'] : '' ;
print_r($_GET);
} while ($_GET['order_by']) >0;

I get an error on the last line.

I guess I should stop with the while loop until I get the data out of
the array.
Look at the source code for your page. Depending on where you have it,
it may not show up in the rendered output - but will be in the source.

I don't know what error you got, but if $_GET['order_by'] has data in
it, it will loop until it times out. However, your problem with the
syntax is that the >0 must also be in the parens.

while ($_GET['order_by'] 0);

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Sep 10 '08 #11
JRough wrote:
On Sep 9, 7:58 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
>JRough wrote:
>>On Sep 9, 2:13 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
JRough wrote:
I have used this function to create a string called $headers:
function GetHeaders($file_name){
return "<th><a href='".$file_name."&order_by=l_e'>L_E</a></th>
<th><a href='".
$file_name."&order_by=carnumber'>Carnumber</a></th>
<th><a href='".
$file_name."&order_by=location'>Location</a></th>
<th><a href='".
$file_name."&order_by=sighting_date_asc'>Sight ing
Date</a></th>
<th><a href='".
$file_name."&order_by=classification'>Code</a></th>
<th><a href='".$file_name."&order_by=railroad'>RR</a></
th>
<th><a href='".$file_name."order_by=origin'>Origin</
a></th>
<th><a href='".
$file_name."&order_by=destination'>Destination </a></
th>
<th width='15%'><a href='".$file_name."'>ETA</a></
th>";
}
Now I want to unpack the $header array and create two strings,
called s1 and s2. I want s1 to be field names for excel and s2 to
be the column names. For example l_e is the field name and L_E is
capitalized to be the column header in Excel. In other words, I want
is the two fields after the order_by= without the 'and the </a>.
How to use unpack?
s1=unpack($headers/37, 9, $data)
I don't know how to use unpack but I have the $header array as the
string, I counted 37 characters to the word order_by and the word
order_by= is 9 characters I want to grab that word before the '.
How do I make use of the unpack function to get what I want?
I forgot to mention it would be good if I could make it dynamic
instead of a hardwired number because I have many of these strings
that are the same with different field names.
tia,
See my response to your other post on this subject.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================
get is not a variable, it is only an anchor. I need to know how to
unpack the array.
No, $_GET is an array of the name/value pairs passed in a GET request -
which is the type of request you get from an anchor (<a href...) tag.
I did print_r($_GET) and I got a result:
Array( )
Select * from Internal_Settings

The select query is to a table that only has the url and the site
name.
The data pairs are being sent to the web site?
I don't know why it is saying Array( ) though

print_r should not be printing Array(). It should be expanding the
array. Look at the source code in your page. The Array() may be coming
from something else.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Sep 10 '08 #12
JRough wrote:
On Sep 9, 7:58 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
>JRough wrote:
>>On Sep 9, 2:13 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
JRough wrote:
I have used this function to create a string called $headers:
function GetHeaders($file_name){
return "<th><a href='".$file_name."&order_by=l_e'>L_E</a></th>
<th><a href='".
$file_name."&order_by=carnumber'>Carnumber</a></th>
<th><a href='".
$file_name."&order_by=location'>Location</a></th>
<th><a href='".
$file_name."&order_by=sighting_date_asc'>Sight ing
Date</a></th>
<th><a href='".
$file_name."&order_by=classification'>Code</a></th>
<th><a href='".$file_name."&order_by=railroad'>RR</a></
th>
<th><a href='".$file_name."order_by=origin'>Origin</
a></th>
<th><a href='".
$file_name."&order_by=destination'>Destination </a></
th>
<th width='15%'><a href='".$file_name."'>ETA</a></
th>";
}
Now I want to unpack the $header array and create two strings,
called s1 and s2. I want s1 to be field names for excel and s2 to
be the column names. For example l_e is the field name and L_E is
capitalized to be the column header in Excel. In other words, I want
is the two fields after the order_by= without the 'and the </a>.
How to use unpack?
s1=unpack($headers/37, 9, $data)
I don't know how to use unpack but I have the $header array as the
string, I counted 37 characters to the word order_by and the word
order_by= is 9 characters I want to grab that word before the '.
How do I make use of the unpack function to get what I want?
I forgot to mention it would be good if I could make it dynamic
instead of a hardwired number because I have many of these strings
that are the same with different field names.
tia,
See my response to your other post on this subject.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================
get is not a variable, it is only an anchor. I need to know how to
unpack the array.
No, $_GET is an array of the name/value pairs passed in a GET request -
which is the type of request you get from an anchor (<a href...) tag.
I did print_r($_GET) and I got a result:
Array( )
Select * from Internal_Settings

The select query is to a table that only has the url and the site
name.
The data pairs are being sent to the web site?
I don't know why it is saying Array( ) though

Ah - my mistake. You do have an array - but it is empty. The string is
not being sent to the server.

You will only get something in $_GET if you do a GET request to the page
with parameters, i.e.

http://www.example.com?foo=bar

will have 'bar' in $_GET['foo']

If you just display the page without parameters, $_GET will be empty.

What do you see as the URL in your browser?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Sep 10 '08 #13
On Sep 10, 10:49*am, Jerry Stuckle <jstuck...@attglobal.netwrote:
JRough wrote:
On Sep 9, 7:58 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
JRough wrote:
On Sep 9, 2:13 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
JRough wrote:
I have used this function to create a string called $headers:
function GetHeaders($file_name){
* return "<th><a href='".$file_name."&order_by=l_e'>L_E</a></th>
* * * * * * * * <th><a href='".
$file_name."&order_by=carnumber'>Carnumber</a></th>
* * * * * * * * <th><a href='".
$file_name."&order_by=location'>Location</a></th>
* * * * * * * * <th><a href='".
$file_name."&order_by=sighting_date_asc'>Sighti ng
Date</a></th>
* * * * * * * * <th><a href='".
$file_name."&order_by=classification'>Code</a></th>
* * * * * * * * <th><a href='".$file_name."&order_by=railroad'>RR</a></
th>
* * * * * * * * <th><a href='".$file_name."order_by=origin'>Origin</
a></th>
* * * * * * * * <th><a href='".
$file_name."&order_by=destination'>Destinatio n</a></
th>
* * * * * * * * <th width='15%'><a href='".$file_name."'>ETA</a></
th>";
}
Now I want to *unpack the $header array and create two *strings,
called s1 and s2. *I want s1 to be *field names for *excel *and s2 to
be the column names. *For example l_e is the *field name and L_E is
capitalized to be the column header in Excel. *In other words, I want
is the two fields after the order_by= without the 'and the </a>..
How to use unpack?
s1=unpack($headers/37, 9, $data)
I don't know how to use unpack but I have the $header array as the
string, I counted 37 characters to the word order_by and the word
order_by= is 9 characters I want to grab that word before the '..
How do I make use of the unpack function to get what I want?
I forgot to mention it would be good if I could make it dynamic
instead of a hardwired number because I have many of these strings
that are the same with different field names.
tia,
See my response to your other post on this subject.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================
get is not a variable, it is only an anchor. *I need to know how to
unpack the array.
No, $_GET is an array of the name/value pairs passed in a GET request -
which is the type of request you get from an anchor (<a href...) tag.
I did print_r($_GET) and I got a result:
Array( )
Select * from Internal_Settings
The select query is to a table that only has the url and the site
name.
The data pairs are being sent to the web site?
I don't know why it is saying Array( ) though

print_r should not be printing Array(). *It should be expanding the
array. *Look at the source code in your page. *The Array() may be coming
from something else.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================
that is what I thought but the page worked before so I wasn't sure. I
will try to find the mistake. thanks very much.
Sep 10 '08 #14
On Sep 10, 10:52*am, Jerry Stuckle <jstuck...@attglobal.netwrote:
JRough wrote:
On Sep 9, 7:58 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
JRough wrote:
On Sep 9, 2:13 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
JRough wrote:
I have used this function to create a string called $headers:
function GetHeaders($file_name){
* return "<th><a href='".$file_name."&order_by=l_e'>L_E</a></th>
* * * * * * * * <th><a href='".
$file_name."&order_by=carnumber'>Carnumber</a></th>
* * * * * * * * <th><a href='".
$file_name."&order_by=location'>Location</a></th>
* * * * * * * * <th><a href='".
$file_name."&order_by=sighting_date_asc'>Sighti ng
Date</a></th>
* * * * * * * * <th><a href='".
$file_name."&order_by=classification'>Code</a></th>
* * * * * * * * <th><a href='".$file_name."&order_by=railroad'>RR</a></
th>
* * * * * * * * <th><a href='".$file_name."order_by=origin'>Origin</
a></th>
* * * * * * * * <th><a href='".
$file_name."&order_by=destination'>Destinatio n</a></
th>
* * * * * * * * <th width='15%'><a href='".$file_name."'>ETA</a></
th>";
}
Now I want to *unpack the $header array and create two *strings,
called s1 and s2. *I want s1 to be *field names for *excel *and s2 to
be the column names. *For example l_e is the *field name and L_E is
capitalized to be the column header in Excel. *In other words, I want
is the two fields after the order_by= without the 'and the </a>..
How to use unpack?
s1=unpack($headers/37, 9, $data)
I don't know how to use unpack but I have the $header array as the
string, I counted 37 characters to the word order_by and the word
order_by= is 9 characters I want to grab that word before the '..
How do I make use of the unpack function to get what I want?
I forgot to mention it would be good if I could make it dynamic
instead of a hardwired number because I have many of these strings
that are the same with different field names.
tia,
See my response to your other post on this subject.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================
get is not a variable, it is only an anchor. *I need to know how to
unpack the array.
No, $_GET is an array of the name/value pairs passed in a GET request -
which is the type of request you get from an anchor (<a href...) tag.
I did print_r($_GET) and I got a result:
Array( )
Select * from Internal_Settings
The select query is to a table that only has the url and the site
name.
The data pairs are being sent to the web site?
I don't know why it is saying Array( ) though

Ah - my mistake. *You do have an array - but it is empty. *The stringis
not being sent to the server.

You will only get something in $_GET if you do a GET request to the page
with parameters, i.e.

http://www.example.com?foo=bar

will have 'bar' in $_GET['foo']

If you just display the page without parameters, $_GET will be empty.

What do you see as the URL in your browser?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================
I think you are right it won't work. First I see this:
www.mywebsite.com/~allrail/idle_cars.php
which as you can see has no pairs, but if I click one of the links:
http://www.mywebsite.com/~allrail/id...er_by=location

so how can I parse the header array like I first asked?
Sep 10 '08 #15
On Sep 10, 10:52*am, Jerry Stuckle <jstuck...@attglobal.netwrote:
JRough wrote:
On Sep 9, 7:58 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
JRough wrote:
On Sep 9, 2:13 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
JRough wrote:
I have used this function to create a string called $headers:
function GetHeaders($file_name){
* return "<th><a href='".$file_name."&order_by=l_e'>L_E</a></th>
* * * * * * * * <th><a href='".
$file_name."&order_by=carnumber'>Carnumber</a></th>
* * * * * * * * <th><a href='".
$file_name."&order_by=location'>Location</a></th>
* * * * * * * * <th><a href='".
$file_name."&order_by=sighting_date_asc'>Sighti ng
Date</a></th>
* * * * * * * * <th><a href='".
$file_name."&order_by=classification'>Code</a></th>
* * * * * * * * <th><a href='".$file_name."&order_by=railroad'>RR</a></
th>
* * * * * * * * <th><a href='".$file_name."order_by=origin'>Origin</
a></th>
* * * * * * * * <th><a href='".
$file_name."&order_by=destination'>Destinatio n</a></
th>
* * * * * * * * <th width='15%'><a href='".$file_name."'>ETA</a></
th>";
}
Now I want to *unpack the $header array and create two *strings,
called s1 and s2. *I want s1 to be *field names for *excel *and s2 to
be the column names. *For example l_e is the *field name and L_E is
capitalized to be the column header in Excel. *In other words, I want
is the two fields after the order_by= without the 'and the </a>..
How to use unpack?
s1=unpack($headers/37, 9, $data)
I don't know how to use unpack but I have the $header array as the
string, I counted 37 characters to the word order_by and the word
order_by= is 9 characters I want to grab that word before the '..
How do I make use of the unpack function to get what I want?
I forgot to mention it would be good if I could make it dynamic
instead of a hardwired number because I have many of these strings
that are the same with different field names.
tia,
See my response to your other post on this subject.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================
get is not a variable, it is only an anchor. *I need to know how to
unpack the array.
No, $_GET is an array of the name/value pairs passed in a GET request -
which is the type of request you get from an anchor (<a href...) tag.
I did print_r($_GET) and I got a result:
Array( )
Select * from Internal_Settings
The select query is to a table that only has the url and the site
name.
The data pairs are being sent to the web site?
I don't know why it is saying Array( ) though

Ah - my mistake. *You do have an array - but it is empty. *The stringis
not being sent to the server.

You will only get something in $_GET if you do a GET request to the page
with parameters, i.e.

http://www.example.com?foo=bar

will have 'bar' in $_GET['foo']

If you just display the page without parameters, $_GET will be empty.

What do you see as the URL in your browser?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================
I tried the $_GET function both ways, after clicking a link and
without and I still got the Array() message.
Sep 10 '08 #16
On Sep 10, 10:52*am, Jerry Stuckle <jstuck...@attglobal.netwrote:
JRough wrote:
On Sep 9, 7:58 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
JRough wrote:
On Sep 9, 2:13 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
JRough wrote:
I have used this function to create a string called $headers:
function GetHeaders($file_name){
* return "<th><a href='".$file_name."&order_by=l_e'>L_E</a></th>
* * * * * * * * <th><a href='".
$file_name."&order_by=carnumber'>Carnumber</a></th>
* * * * * * * * <th><a href='".
$file_name."&order_by=location'>Location</a></th>
* * * * * * * * <th><a href='".
$file_name."&order_by=sighting_date_asc'>Sighti ng
Date</a></th>
* * * * * * * * <th><a href='".
$file_name."&order_by=classification'>Code</a></th>
* * * * * * * * <th><a href='".$file_name."&order_by=railroad'>RR</a></
th>
* * * * * * * * <th><a href='".$file_name."order_by=origin'>Origin</
a></th>
* * * * * * * * <th><a href='".
$file_name."&order_by=destination'>Destinatio n</a></
th>
* * * * * * * * <th width='15%'><a href='".$file_name."'>ETA</a></
th>";
}
Now I want to *unpack the $header array and create two *strings,
called s1 and s2. *I want s1 to be *field names for *excel *and s2 to
be the column names. *For example l_e is the *field name and L_E is
capitalized to be the column header in Excel. *In other words, I want
is the two fields after the order_by= without the 'and the </a>..
How to use unpack?
s1=unpack($headers/37, 9, $data)
I don't know how to use unpack but I have the $header array as the
string, I counted 37 characters to the word order_by and the word
order_by= is 9 characters I want to grab that word before the '..
How do I make use of the unpack function to get what I want?
I forgot to mention it would be good if I could make it dynamic
instead of a hardwired number because I have many of these strings
that are the same with different field names.
tia,
See my response to your other post on this subject.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================
get is not a variable, it is only an anchor. *I need to know how to
unpack the array.
No, $_GET is an array of the name/value pairs passed in a GET request -
which is the type of request you get from an anchor (<a href...) tag.
I did print_r($_GET) and I got a result:
Array( )
Select * from Internal_Settings
The select query is to a table that only has the url and the site
name.
The data pairs are being sent to the web site?
I don't know why it is saying Array( ) though

Ah - my mistake. *You do have an array - but it is empty. *The stringis
not being sent to the server.

You will only get something in $_GET if you do a GET request to the page
with parameters, i.e.

http://www.example.com?foo=bar

will have 'bar' in $_GET['foo']

If you just display the page without parameters, $_GET will be empty.

What do you see as the URL in your browser?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================
Sometimes it has parameters and it still doesn't work? thanks for
explaining $_GET.
Sep 10 '08 #17
Message-ID: <oe_xk.1007$1a2.274@trnddc04from Curtis contained the
following:

>
You might want to thoroughly (re)visit the basics of PHP and HTTP.
I still haven't the foggiest idea what the OP wants to do...

Where does Excel come into this?
--
Geoff Berrow 0110001001101100010000000110
001101101011011001000110111101100111001011
100110001101101111001011100111010101101011
http://slipperyhill.co.uk - http://4theweb.co.uk
Sep 11 '08 #18
Geoff Berrow wrote:
Message-ID: <oe_xk.1007$1a2.274@trnddc04from Curtis contained the
following:

>You might want to thoroughly (re)visit the basics of PHP and HTTP.

I still haven't the foggiest idea what the OP wants to do...

Where does Excel come into this?
Lol, I'm not quite sure either, but I believe the OP wants to take
some data from the query string, and use it to create an excel
spreadsheet. Perhaps the OP could better clarify...

--
Curtis
Sep 11 '08 #19
On 11 Sep, 19:41, Curtis <dye...@gmail.comwrote:
Geoff Berrow wrote:
Message-ID: <oe_xk.1007$1a2.274@trnddc04from Curtis contained the
following:
You might want to thoroughly (re)visit the basics of PHP and HTTP.
I still haven't the foggiest idea what the OP wants to do...
Where does Excel come into this?

Lol, I'm not quite sure either, but I believe the OP wants to take
some data from the query string, and use it to create an excel
spreadsheet. Perhaps the OP could better clarify...

--
Curtis
If you check out the "Unpack a string" thread you'll note that the OP
has no clue as far as programming goes.
Sep 11 '08 #20

This discussion thread is closed

Replies have been disabled for this discussion.

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.