php-general Digest 5 Dec 2007 19:57:48 -0000 Issue 5165
Topics (messages 265464 through 265478):
auto-populating multiple boxes... php and pg_fetch_array problem?
265464 by: pere roca
265465 by: Jochem Maas
Re: Calendar
265466 by: Richard Heyes
265478 by: Andrew Ballard
Array numeric key -> alpha key replacement
265467 by: scotdiddle.silverdarkroom.com
265468 by: C.R.Vegelin
265469 by: Jochem Maas
265471 by: scotdiddle.silverdarkroom.com
265473 by: Jochem Maas
265477 by: Jochem Maas
Re: howto get .tar.gz content's filenames
265470 by: Cesar D. Rodas
Configure option for external expat directory
265472 by: Elyse Salberg
Maps
265474 by: Robert Fitzpatrick
265475 by: Daniel Brown
Re: Maps]
265476 by: Jochem Maas
Administrivia:
To subscribe to the digest, e-mail:
[EMAIL PROTECTED]
To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]
To post to the list, e-mail:
[EMAIL PROTECTED]
----------------------------------------------------------------------
--- Begin Message ---
hi everybody,
there is a nice tool using jquery/php to populate multiple select boxes out
there : http://remysharp.com/2007/09/18/auto-populate-multiple-select-boxes/
it must be a very stupid question but I’m trying to apply this tool to get
data from postgreSQL, but I always get an empty [] value. It means that the
array $json[] is not filled in the while statement. But the dbase connection
and the query is correct ( I can check applying a echo “data: “.$row[0].”";
and all the data is displayed).
I suppose pg_fetch_array is not used correctly (I have checked also
pg_fetch_object)...but I'm not sure because I'n newbie to jquery and json.
If someone has success connecting to postgresql...
Thanks!
After inserting data....
$postgis_result=pg_query("select * from select_chain where
genus='".strtolower(pg_escape_string(strip_tags($_REQUEST['category'])))."'");
$json = array();
while (is_resource($postgis_result) && $row =
pg_fetch_array($postgis_result)) {
$json[] = '"' . $row->label . '"';
}
echo '[' . implode(',', $json) . ']';
die();
--
View this message in context:
http://www.nabble.com/auto-populating-multiple-boxes...-php-and-pg_fetch_array-problem--tf4948560.html#a14168475
Sent from the PHP - General mailing list archive at Nabble.com.
--- End Message ---
--- Begin Message ---
pere roca wrote:
> hi everybody,
> there is a nice tool using jquery/php to populate multiple select boxes out
> there : http://remysharp.com/2007/09/18/auto-populate-multiple-select-boxes/
>
> it must be a very stupid question but I’m trying to apply this tool to get
> data from postgreSQL, but I always get an empty [] value. It means that the
> array $json[] is not filled in the while statement.
does it? have you actually checked var_dump($json) ?
> But the dbase connection
> and the query is correct ( I can check applying a echo “data: “.$row[0].”";
> and all the data is displayed).
please note: '$row[0]' != '$row->label'
>
> I suppose pg_fetch_array is not used correctly (I have checked also
> pg_fetch_object)...but I'm not sure because I'n newbie to jquery and json.
> If someone has success connecting to postgresql...
>
> Thanks!
> After inserting data....
>
> $postgis_result=pg_query("select * from select_chain where
> genus='".strtolower(pg_escape_string(strip_tags($_REQUEST['category'])))."'");
>
> $json = array();
>
> while (is_resource($postgis_result) && $row =
I think it's safe to assume that $postgis_result will be a resource all the
way through the while loop.
> pg_fetch_array($postgis_result)) {
so you fetch an array and then use the result as an object??
> $json[] = '"' . $row->label . '"';
> }
>
> echo '[' . implode(',', $json) . ']';
> die();
$json = array();
while ($row = pg_fetch_array($postgis_result, NULL, PGSQL_ASSOC))
$json[] = $row['label'];
echo json_encode($json); // this function may not be available in your version
of php
--- End Message ---
--- Begin Message ---
There is not much "simple" about a calendar, especially when you start
dealing with recurring events. How far into the future your calendar
allow events to recur will depend at least in part on how you intend
to store them. For instance, you can store them in a database where
you create a separate event row for each occurrence (though still be
linked by a common ID as you said), but you'll probably set your
limits based on storage to prevent adding a daily event for the next
10 years.
Stipulating an event to be daily could be as simple as a 0 or 1 flag. So
where's the storage concern?
> You could also store a single event record that includes the
rules for recurrence and then calculate the dates of each instance as
needed, but that could get pretty CPU intensive. (I'm assuming you
want to stick with "simple" periodic recursion, not more complex
things like the date for Easter or events that don't have any set
pattern.)
I really don't see anything CPU intensive about this. At most you're
going to be storing some set dates that the event should occur on.
Nothing CPU intensive about that.
I know this probably muddies your original question even further, but
I'll say again -- there is not much "simple" when it comes to
calendars.
Calendars can be simple, or they can account for a lot and be complex.
--
Richard Heyes
http://www.websupportsolutions.co.uk
Knowledge Base and HelpDesk software
that can cut the cost of online support
** NOW OFFERING FREE ACCOUNTS TO CHARITIES AND NON-PROFITS **
--- End Message ---
--- Begin Message ---
On Dec 5, 2007 6:09 AM, Richard Heyes <[EMAIL PROTECTED]> wrote:
> > There is not much "simple" about a calendar, especially when you start
> > dealing with recurring events. How far into the future your calendar
> > allow events to recur will depend at least in part on how you intend
> > to store them. For instance, you can store them in a database where
> > you create a separate event row for each occurrence (though still be
> > linked by a common ID as you said), but you'll probably set your
> > limits based on storage to prevent adding a daily event for the next
> > 10 years.
>
> Stipulating an event to be daily could be as simple as a 0 or 1 flag. So
> where's the storage concern?
The storage concern comes if you opt to store one copy of the event
for every day for as long as the event recurs. Why? Perhaps you want
to provide the ability to alter the time of a specific instance of a
recurring event (or delete one instance altogether) without changing
the other instances.
> > You could also store a single event record that includes the
> > rules for recurrence and then calculate the dates of each instance as
> > needed, but that could get pretty CPU intensive. (I'm assuming you
> > want to stick with "simple" periodic recursion, not more complex
> > things like the date for Easter or events that don't have any set
> > pattern.)
>
> I really don't see anything CPU intensive about this. At most you're
> going to be storing some set dates that the event should occur on.
> Nothing CPU intensive about that.
>
If you are only storing a single row for an recurring event rather
than one row for each instance, then you have to evaluate your rule
for each event inside the view you are displaying (month, year, etc.)
to determine the dates for the event. I'm not talking grinding a
server to a halt, but depending on how many events have to be
calculated and how many users you have at a given moment, it could
become noticable.
> > I know this probably muddies your original question even further, but
> > I'll say again -- there is not much "simple" when it comes to
> > calendars.
>
> Calendars can be simple, or they can account for a lot and be complex.
>
> --
> Richard Heyes
> http://www.websupportsolutions.co.uk
>
> Knowledge Base and HelpDesk software
> that can cut the cost of online support
>
> ** NOW OFFERING FREE ACCOUNTS TO CHARITIES AND NON-PROFITS **
>
Calendars themselves aren't that much to build. Even simple one-time
events are pretty easy. Beyond that, all I'm saying is that you have
to make a design decision based on your needs as to whether you store
a lot to avoid repeating calculations or calculate more to store less.
In any event, the biggest troublemaker I've had to deal with when it
comes to calendars have been related to time zones and daylight saving
time.
Andrew
--- End Message ---
--- Begin Message ---
Hello All,
Is the a built-in PHP call that I am overlooking which lets me
replace key values in an array.
$inputArray = array(0 => array, 1 => array); (generated programtically)
I want to end up with :
$newArray = array('FAF1' => array, 'ODM1' => array);
Thanks.
Scot L. Diddle, UPS Freight, Richmond VA
--- End Message ---
--- Begin Message ---
----- Original Message -----
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, December 05, 2007 1:00 PM
Subject: [PHP] Array numeric key -> alpha key replacement
Hello All,
Is the a built-in PHP call that I am overlooking which lets me
replace key values in an array.
$inputArray = array(0 => array, 1 => array); (generated
programtically)
I want to end up with :
$newArray = array('FAF1' => array, 'ODM1' => array);
Thanks.
Scot L. Diddle, UPS Freight, Richmond VA
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
What about:
$inputArray = array();
$inputArray['FAF1'] = array();
$inputArray['ODM1'] = array();
print_r($inputArray);
HTH, Cor
--- End Message ---
--- Begin Message ---
[EMAIL PROTECTED] wrote:
> Hello All,
>
> Is the a built-in PHP call that I am overlooking which lets me
> replace key values in an array.
>
> $inputArray = array(0 => array, 1 => array); (generated programtically)
>
> I want to end up with :
>
> $newArray = array('FAF1' => array, 'ODM1' => array);
>
> Thanks.
$newArray = array('FAF1', 'ODM1', /* bla bla bla */);
$inputArray = array_combine($newArray, $inputArray);
I guess reading through this page was too much trouble for you:
http://php.net/array
>
> Scot L. Diddle, UPS Freight, Richmond VA
>
--- End Message ---
--- Begin Message ---
Quoting Jochem Maas <[EMAIL PROTECTED]>:
[EMAIL PROTECTED] wrote:
Hello All,
Is the a built-in PHP call that I am overlooking which lets me
replace key values in an array.
$inputArray = array(0 => array, 1 => array); (generated programtically)
I want to end up with :
$newArray = array('FAF1' => array, 'ODM1' => array);
Thanks.
$newArray = array('FAF1', 'ODM1', /* bla bla bla */);
$inputArray = array_combine($newArray, $inputArray);
I guess reading through this page was too much trouble for you:
http://php.net/array
Jochem: Nope, not too much trouble... I tried to find what I was
looking for on http://php.net/array.
Sorry I was such a bother.
Scot
Scot L. Diddle, UPS Freight, Richmond VA
--- End Message ---
--- Begin Message ---
[EMAIL PROTECTED] wrote:
> Quoting Jochem Maas <[EMAIL PROTECTED]>:
>
...
>>
>> $newArray = array('FAF1', 'ODM1', /* bla bla bla */);
>> $inputArray = array_combine($newArray, $inputArray);
>>
>> I guess reading through this page was too much trouble for you:
>>
>> http://php.net/array
>
> Jochem: Nope, not too much trouble... I tried to find what I was looking
> for on http://php.net/array.
>
> Sorry I was such a bother.
no bother, if everyone read the manual and found their answers there who would
I vent my speel at?
I'll assume that array_combine() does the trick for you.
--- End Message ---
--- Begin Message ---
[EMAIL PROTECTED] wrote:
> Jochem,
>
> Yes, that did the trick quite nicely.
>
> As I said, I overlooked it... a function called array_combine did not
> cause me to read the drill-down, because I figured it was for a union of
> two arrays ( it is, kind of... ) and I wanted to replace key values, not
> combine arrays : array_combine( (1,2,3,4), (5,6,7,8)) =
> array(1,2,3,4,5,6,7,8) which is what the name of the function implies is
> does, and which, for those of us who have read that portion of the
> manual knows, is accomplished by array_merge.
granted the names are less than perfect, you do illustrate very well that
assumptions (of any kind) pretty much suck (at least when it comes to this
kind of work) ... I assume you understand what I mean ;-)
I do recommend a thorough read of all the major sections of the docs
(those covering core functionality more than anything). garanteed you'll
come accross stuff that you'll use 3 months down the line which you would
otherwise have to search deity knows how long for
... at least that's my experience.
>
> Thanks for the help.
please come back soon. my spleen needs the exercise. ;-)
>
> Scot
>
> Quoting Jochem Maas <[EMAIL PROTECTED]>:
>
>> [EMAIL PROTECTED] wrote:
>>> Quoting Jochem Maas <[EMAIL PROTECTED]>:
>>>
>>
>> ...
>>
>>>>
>>>> $newArray = array('FAF1', 'ODM1', /* bla bla bla */);
>>>> $inputArray = array_combine($newArray, $inputArray);
>>>>
>>>> I guess reading through this page was too much trouble for you:
>>>>
>>>> http://php.net/array
>>>
>>> Jochem: Nope, not too much trouble... I tried to find what I was looking
>>> for on http://php.net/array.
>>>
>>> Sorry I was such a bother.
>>
>> no bother, if everyone read the manual and found their answers there
>> who would
>> I vent my speel at?
spleen. doh.
>>
>> I'll assume that array_combine() does the trick for you.
>>
>
>
>
--- End Message ---
--- Begin Message ---
On 05/12/2007, Per Jessen <[EMAIL PROTECTED]> wrote:
>
> Cesar D. Rodas wrote:
>
> > Call exec is not good, because you are executing other program,
> > instead of that you should use some PHP program, take a look here
> >
> > http://www.phpclasses.org/search.html?words=tar&x=0&y=0&go_search=1
> >
>
> "The access to the internal site search engine is restricted to premium
> users."
Sorry for that :-) here is one links of a php class for create/read
compressed files
+ http://www.phpclasses.org/browse/package/945.html
/Per Jessen, Zürich
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
Best Regards
Cesar D. Rodas
http://www.cesarodas.com
http://www.thyphp.com
http://www.phpajax.org
Phone: +595-961-974165
--- End Message ---
--- Begin Message ---
PHP version: 5.2.5 / Platform: Solaris 9 (SPARC) / Expat version: 1.95.8
The PHP manual's section on XML ( http://us2.php.net/manual/en/
ref.xml.php ) states that the "--with-expat-dir=DIR" option should be
used if you wish to use an external expat library. However, when I
attempted to do so, I received the following error:
"Notice: Following unknown configure options were used: --with-expat-
dir=/usr/local"
After checking the configure script itself, I believe I was able to
specify the external version of expat via "--with-libexpat-dir
[=DIR]". However, I was hoping someone could help me answer the
following (at least #1):
1) Is --with-libexpat-dir the correct option (i.e. is this a
documentation error)? If not, what is the recommended method for
having PHP compile using an external expat library?
2) Is pointing to an external version of expat deprecated in favor of
using the bundled version (as some online searching suggests), or
will this option continue to exist in some form? Since I'm still
refining my build, if the plan is to rely on the bundled version,
I'll stop pointing to our external one. However, we do prefer to use
external packages for libraries when possible.
Thanks for any thoughts,
Elyse Salberg
--- End Message ---
--- Begin Message ---
Well, I have two clients that both want mapping for their sales people.
I have been looking at the Google API and Phoogle
(www.systemsevendesigns.com/phoogle). I assume with these examples I
will be able to produce what they need? Which is to select several
addresses and produce a fastest route map with directions to those
addresses from a start address. Not clear from my reading yet, but can
someone with some experience tell me if this is possible with the Google
API or some hints that might speed up my process of the best way to go
for this...
Thanks in advance!
--
Robert
--- End Message ---
--- Begin Message ---
On Dec 5, 2007 1:27 PM, Robert Fitzpatrick <[EMAIL PROTECTED]> wrote:
> Well, I have two clients that both want mapping for their sales people.
> I have been looking at the Google API and Phoogle
> (www.systemsevendesigns.com/phoogle). I assume with these examples I
> will be able to produce what they need? Which is to select several
> addresses and produce a fastest route map with directions to those
> addresses from a start address. Not clear from my reading yet, but can
> someone with some experience tell me if this is possible with the Google
> API or some hints that might speed up my process of the best way to go
> for this...
To be honest, your best bet would be to ask in one of their
groups. Google has groups specifically-dedicated to its API, so you'd
probably be better off asking there than on the PHP list.
--
Daniel P. Brown
[Phone Numbers Go Here!]
[They're Hidden From View!]
If at first you don't succeed, stick to what you know best so that you
can make enough money to pay someone else to do it for you.
--- End Message ---
--- Begin Message ---
I forgot to CC the list, sorry.
-------- Original Message --------
Subject: Re: [PHP] Maps
Date: Wed, 05 Dec 2007 20:25:06 +0100
From: Jochem Maas <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
References: <[EMAIL PROTECTED]>
Robert Fitzpatrick wrote:
> Well, I have two clients that both want mapping for their sales people.
> I have been looking at the Google API and Phoogle
> (www.systemsevendesigns.com/phoogle). I assume with these examples I
> will be able to produce what they need? Which is to select several
> addresses and produce a fastest route map with directions to those
> addresses from a start address. Not clear from my reading yet, but can
> someone with some experience tell me if this is possible with the Google
> API or some hints that might speed up my process of the best way to go
> for this...
google maps is no real help here, your able to plot points but there is no
API interface with their routing functionality (so you have no idea where roads
actually are) ... you've been asked to solve the travelling salesman problem,
this is hard.
time to start reading:
http://www.google.com/search?q=travelling+salesman+problem
and more specifically (with an eye to finding something that solves the problem
for you):
http://www.google.com/search?q=travelling+salesman+problem+google+maps
chances are you'll end up building something expensive, likely that offering
something
that allows these salepeople to quickly/easily link to google/yahoo/whatever
maps and
then manually view/tweak their route will be a lot less painful to implement
and alot
more cost effective.
--- End Message ---