php-general Digest 24 Apr 2006 02:56:19 -0000 Issue 4089
Topics (messages 234586 through 234602):
Re: sorting troubles
234586 by: chris smith
234600 by: David Tulloh
Problems Posting - PLEASE IGNORE!
234587 by: Porpoise
TEST - PLEASE IGNORE!
234588 by: Porpoise
At Last!
234589 by: Porpoise
Re: CMS for Auto Parts
234590 by: John Hicks
234592 by: Joe Wollard
234593 by: CK
Re: PHP Script to open phpBB2 accounts
234591 by: Weber Sites LTD
Re: array problem
234594 by: Brian V Bonini
Re: array problem + humor (all those with joke allergies beware)
234595 by: Brian V Bonini
234596 by: Dave Goodchild
Re: New image already cached. (SOLVED)
234597 by: tedd
234602 by: Richard Lynch
Re: shopping carts
234598 by: Lester Caine
How to find <img> tag and get src of image
234599 by: Pham Huu Le Quoc Phuc
234601 by: Jay Blanchard
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 ---
> I have a column in DB that contains this kind of data,
> A20,B16,B17C14,C15,D13,D12 etc.
>
> I would like to print this data to a page and sort it ascending by the
> letter an descending by the number. Can this be done? Like
>
> A20
> B17
> B16
> C15
> C14
> D13
> D12
Depending on how many records you have and how many you want per page,
you might be better off doing this in your database query (eg you have
d01 -> d99 and only want to show 30 per page)...
Depending on which db you use, different syntaxes will apply.. so if
you need further help send which db and which version.
--
Postgresql & php tutorials
http://www.designmagick.com/
--- End Message ---
--- Begin Message ---
William Stokes wrote:
> Hello,
>
> Any idea how to sort this?
>
> I have a column in DB that contains this kind of data,
> A20,B16,B17C14,C15,D13,D12 etc.
>
> I would like to print this data to a page and sort it ascending by the
> letter an descending by the number. Can this be done?
PHP has the usort() function which allows you to sort by another
function. This allows you to very neatly sort by virtually any criteria.
I knocked up a fairly simple function to do the sort that you described.
The format for the comparison function is in the usort() documentation
as well as several examples.
<php
function weird_comparison($a, $b) {
# return -1, 0, 1 if $a is less than, equal to or greater than $b
if($a{0} > $b{0})
return 1;
elseif($a{0} < $b{0})
return -1;
else {
$a_num = substr($a, 1);
$b_num = substr($b, 1);
if($a_num > $b_num)
return -1;
elseif($a_num < $b_num)
return 1;
else
return 0;
}
}
$arr = explode(',', 'A20,B16,B17,C14,C15,D13,D12');
print_r($arr);
usort($arr, 'weird_comparison');
print_r($arr);
?>
David
--- End Message ---
--- Begin Message ---
Been having problems posting. If this gets through OK please ignore
--- End Message ---
--- Begin Message ---
dsfk;ghjfdskjgjdsalkjfksd
--- End Message ---
--- Begin Message ---
Well, that was hardly an intuitive process - to get to the point of being
able to post to the group..... Why couldn't they put clearer instructions on
the website? Or, maybe it's just me being thick......... ;-) Or, maybe I
just lost the <[SPAM] PHP list posting confirmation for...> amongst the
spam.........
Obviously need to "white-list" it......
Enough drivelling already........!! Let's get on with the posting....
--- End Message ---
--- Begin Message ---
CK wrote:
> Hi,
> On Apr 22, 2006, at 1:26 PM, John Hicks wrote:
>
>> CK wrote:
>>> Hi,
>>> I've been commissioned to design a web application for auto parts
>>> sales. The Flash Front end will communicate with a MySQL DB via PHP.
>>> In addition, PHP/XML should be used with a client-side Web GUI to
>>> upload images, part no., descriptions and inventory into the DB; a
>>> Product Management System.
>>>
>> I am curious as to how you plan to using XML for the client's back
>> end? (I don't see any reason to use it.)
>
> Using XML to keep an "inventory" dynamically, was the thought. The XML
> file would be updated with each entry, then could be imported into a
> spreadsheet.
>
If you are storing your inventory in an XML document, then what are you
using the MySQL database for?
>>> After "Googling" the returned queries have been slim, any leads on
>>> more specific examples?
What specifically are you looking for and how are you googling for it?
--John
--- End Message ---
--- Begin Message ---
I could be off here, but I think he's talking about using XML to transfer
data back and forth between the flash app and the PHP app. That's just me
reading between the lines though. Maybe I'm taking too much from "PHP/XML
should be used with a client-side Web GUI to upload images, part no.,
descriptions and inv[...]"
Even so, I can't really offer anything that specifically does what's needed.
I'd think the easiest way to go about it (aside from building it yourself)
would be to pick an existing AJAX + PHP framework and modify it to work with
FLASH as the front end instead of JavaScript.
- Just a thought.
/shrug
On 4/23/06, John Hicks <[EMAIL PROTECTED]> wrote:
>
> CK wrote:
> > Hi,
> > On Apr 22, 2006, at 1:26 PM, John Hicks wrote:
> >
> >> CK wrote:
> >>> Hi,
> >>> I've been commissioned to design a web application for auto parts
> >>> sales. The Flash Front end will communicate with a MySQL DB via PHP.
> >>> In addition, PHP/XML should be used with a client-side Web GUI to
> >>> upload images, part no., descriptions and inventory into the DB; a
> >>> Product Management System.
> >>>
> >> I am curious as to how you plan to using XML for the client's back
> >> end? (I don't see any reason to use it.)
> >
> > Using XML to keep an "inventory" dynamically, was the thought. The XML
> > file would be updated with each entry, then could be imported into a
> > spreadsheet.
> >
>
> If you are storing your inventory in an XML document, then what are you
> using the MySQL database for?
>
> >>> After "Googling" the returned queries have been slim, any leads on
> >>> more specific examples?
>
> What specifically are you looking for and how are you googling for it?
>
> --John
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--- End Message ---
--- Begin Message ---
On Apr 23, 2006, at 11:55 AM, Joe Wollard wrote:
I could be off here, but I think he's talking about using XML to
transfer data back and forth between the flash app and the PHP app.
That was the idea or using AMFPHP to pass a native PHP Object to FLASH.
That's just me reading between the lines though. Maybe I'm taking
too much from "PHP/XML should be used with a client-side Web GUI to
upload images, part no., descriptions and inv[...]"
Even so, I can't really offer anything that specifically does
what's needed. I'd think the easiest way to go about it (aside from
building it yourself) would be to pick an existing AJAX + PHP
framework and modify it to work with FLASH as the front end instead
of JavaScript.
Planning on building it myself.
- Just a thought.
/shrug
On 4/23/06, John Hicks <[EMAIL PROTECTED]> wrote:
CK wrote:
> Hi,
> On Apr 22, 2006, at 1:26 PM, John Hicks wrote:
>
>> CK wrote:
>>> Hi,
>>> I've been commissioned to design a web application for auto parts
>>> sales. The Flash Front end will communicate with a MySQL DB via
PHP.
>>> In addition, PHP/XML should be used with a client-side Web GUI to
>>> upload images, part no., descriptions and inventory into the DB; a
>>> Product Management System.
>>>
>> I am curious as to how you plan to using XML for the client's back
>> end? (I don't see any reason to use it.)
>
> Using XML to keep an "inventory" dynamically, was the thought.
The XML
> file would be updated with each entry, then could be imported into a
> spreadsheet.
>
If you are storing your inventory in an XML document, then what are
you
using the MySQL database for?
>>> After "Googling" the returned queries have been slim, any leads on
>>> more specific examples?
What specifically are you looking for and how are you googling for it?
--John
--
PHP General Mailing List (http://www.php.net/ )
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
I'm happy to say that the sites now work both ways.
A user opens an account on WeberDev and an account
Will be opened on WeberForums and vice versa.
A password or email update on one site will trigger
An update on the other.
The code for the accounts on phpBB2 are at :
http://www.weberdev.com/get_example-4383.html
Thanks
berber
-----Original Message-----
From: Gerr D [mailto:[EMAIL PROTECTED]
Sent: Saturday, April 22, 2006 8:51 PM
To: [EMAIL PROTECTED]
Cc: Weber Sites LTD; [email protected]
Subject: Re: [PHP] PHP Script to open phpBB2 accounts
Richard,
On 4/20/06, Richard Lynch <[EMAIL PROTECTED]> wrote:
> Or perhaps you believe you have already completely mined out those
> resources, and PHP-General was your last resort.
>
> Which is fine, but that should have been in your original post.
Are you implying this list is intended to be a "last resort" resource?
That seems a shame, considering the talent I've seen here.
> You cannot possibly be the first (or last) developer to want this
> feature...
I would like it too. ;)
> I'm guessing that a lot of the noise here is that most posters firmly
> believe that your phpBB solution is "out there" and you just need to
> find it, somewhere in phpBB sites.
I'm guessing that most posters indeed believe that, because if you think
about it, it's logical and as such, someone would have already created a
solution. Yet believing that and sending someone off to go look "somewhere"
demonstrates that nobody has actually "seen" the solution... Otherwise why
not share it?
Gerry
--- End Message ---
--- Begin Message ---
On Sat, 2006-04-22 at 15:31, Martin Alterisio wrote:
> You're wrong, he isn't using an associative array, since the keys used
> are only integers.
Well, if you really want to argue semantics then technically we're both
wrong because there are no different indexed and associative array types
in PHP, what was that you said?... "(read the manual!!!)"....
--- End Message ---
--- Begin Message ---
On Sat, 2006-04-22 at 14:16, Jochem Maas wrote:
> with regard to Suresh - do you, Brian, know how many times he has posted
> similar
> question to this list this year? (this is the first time he has even given
> an indication that he knows where the manual is let alone opened it btw) do
> you
> know how many times he's been waiting for a reply/answer? how many times
> people
> have given him answered? how often he has replied (like saying thank you for
> instance) to anyone of the repsonses to his questions in any form whatsovever?
>
Did you need some recommendations on a new email program? Most have a
delete button, not sure how the authors of yours missed that....
--- End Message ---
--- Begin Message ---
Tiresome.
On 23/04/06, Brian V Bonini <[EMAIL PROTECTED]> wrote:
>
> On Sat, 2006-04-22 at 14:16, Jochem Maas wrote:
> > with regard to Suresh - do you, Brian, know how many times he has posted
> similar
> > question to this list this year? (this is the first time he has even
> given
> > an indication that he knows where the manual is let alone opened it btw)
> do you
> > know how many times he's been waiting for a reply/answer? how many times
> people
> > have given him answered? how often he has replied (like saying thank you
> for
> > instance) to anyone of the repsonses to his questions in any form
> whatsovever?
> >
>
> Did you need some recommendations on a new email program? Most have a
> delete button, not sure how the authors of yours missed that....
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
http://www.web-buddha.co.uk
dynamic web programming from Reigate, Surrey UK (php, mysql, xhtml, css)
look out for project karma, our new venture, coming soon!
--- End Message ---
--- Begin Message ---
Richard:
Thank you very much for your detailed explanation -- I finally got it.
However, the solution to my problem was much easier than I had hoped.
My problem was in creating an image on the fly and then using the
same file name each time. As such, some browsers cache the image
while others treat it as a new image.
So, the problem was how to change the name of the image such that all
browsers would see it as a new image and not use a cached image..
The solution:
<img src="images/the_image.png?id=<?php rand(); ?>">
Neither the image tag nor the file cares if there is a random number
attached to the file's url. But, by doing this, most (perhaps all)
browsers think the image name is unique.
Doe anyone see any problems with this?
tedd
---- previously said ---
At 4:29 PM -0500 4/20/06, Richard Lynch wrote:
Here's the crucial info you are missing:
The URL does not have to *END* in the name of the PHP file.
The PHP file could be in the MIDDLE of the URL.
In other words, Apache is perfectly happy to take a url like this:
http://example.com/program.php/whatever_you-want=to+put_here
Example setup:
~/public_html/program
~/public_html/.htaccess
.htaccess:
<Files program>
ForceType application/x-httpd-php
</Files>
program:
<?php
//This stuff should really be in an include file...
$pathinfo = $_SERVER['PATHINFO'];
$parts = explode('/', $pathinfo);
foreach($parts as $part){
list($key, $value) = explode('=', $part);
if (1) echo "DEBUG: Setting _PATH[$key] to $value<br />\n";
$_PATH[$key] = $value;
}
//create your image, using:
//$_PATH['width'] from the URL, max width of image
//$_PATH['copyright'] from the URL, watermark with copyright or not
//$_PATH['filename'] which image file to start with as 'source'
$image = imagecreatefromjpeg($_PATH['filename']);
//etc
?>
So when your URL is this:
http://example.com/program/width=200/copyright=1/filename=source.jpg
Your PHP script in 'program' is called, and Apache gives you all the
other stuff in the URL in 'PATHINFO' which you can use as your
arguments.
It's really just replacing:
?width=200©right=1&filename=source.jpg
and using $_GET with:
/width=200/copyright=1/filename=source.jpg
and using $_PATH (aka $_SERVER['PATHINFO'])
Variants:
To keep the browser from using 'filename=source.jpg' if the user
right-clicks, you could change the URL to just end in the filename,
and you'd have to handle that differently than the explode('=', $part)
To keep the browser from caching your image, embed some random number
in the URL, and your program will just IGNORE that key/value in $_PATH
The whole point of this exercise is to provide the browser with a URL
that it cannot distinguish from a valid static image URL, so the
browser can't screw up. Cuz it will if it can.
On Thu, April 20, 2006 9:06 am, tedd wrote:
Richard:
I'm confused -- let's get back to the basic problem.
I'm using an image tag (<img href="/path/to/an/image.png"> in my html.
Some browsers are caching the image because it's the same url (same
"image.png" name) each time. However, the image is something I
generate each time it's called, so it's new.
Now, you and examples have shown me that I could use .htaccess and
ForceType to make the browser load anything regardless of it's name.
You suggested using a random string and using that in the url to
trick the browser into loading the image each time. OK, I can see how
that could work, but I don't see how I can use .htaccess and
ForceType to firce the browser to load the image without rewriting .
htaccess each time.
That's where I'm confused.
tedd
---
$image_file = 'foo.jpg';
$random = mt_rand(1, 2000000000);
$url = "http://example.com/program/$random/$image_file";
echo "<img src=\"$url\">
In program, if you echo out $_SERVER['PATHINFO'] you will see:
/454398574395/foo.jpg
The number will change, of course.
>>
You can tear that apart and get the foo.jpg part to do whatever you
want.
Or, you could have the URL sometimes have 'copyright' in it, and
sometimes not, and merge only when the URL has copyright in it.
You could even pass is paraeters like this:
http://example.com/program/width=200/2343242343/foo.jpg
Take the width=200 and scale the image to be 200 pixels wide.
Here is a real live example where I do this:
http://uncommonground.com/artist_profile/Ellen+Rosner
Right-click on that image of Ellen in the chair and check out that
URL.
thumbnail is my PHP script.
target is a max width/height (I scale it proporationally and 200 is
max for both)
credits is the photographer credits from my database.
The rest is the URL of the actual real image I'm dinking with.
Feel free to play with the URL and change the 200 to, say, 100, or
make believe YOU took that photograph.
All just from the URL which, as far as the browser can tell, is a
perfectly valid set of directory paths on my machine, so the browser
can't possibly screw up. (Rule #1: Never trust the browser.)
And in the main link, artist_profile is the PHP script, and if you
look at the links to the other artists at the bottom of the page,
you'll see that it also uses PATH_INFO to either show an artist by ID
or to search for their name in our database.
If multiple matches are found, the user is asked which one they
meant:
http://uncommonground.com/artist_profile/Ellen
If I have the ID, then I know exactly which one to display.
I actually would suggest you go with:
/width=200/ though, instead of /width/200/ as it's easier to code and
have optional parameters using = and / as an arg separator.
I haven't bothered to fix that old script, but that's how I do it
nowadays.
On Wed, April 19, 2006 8:19 am, tedd wrote:
You're also better off embedding the parameters in the URL so that
it
"looks like" a directory to the browser:
http://example.com/actual_script/57823642346963/copyright/whatever.png
The PHP scritp is actual_script.
You can use .htaccess and ForceType to make Apache run it.
$_SERVER['PATH_INFO'] will have all the parameters you need.
The embedded parameters pretty much give the browser NO opportunity
to
screw up.
Richard:
> Far out ! -- I never saw .htaccess and ForceType used before. But
it
works slick in dropping the extension of "program.php" to
"program".
(Now if I can only get my editor to still treat the document as
php,
but that's a different matter).
However, I don't see how I can generate a random number for a url
each time an image is needed and have .htaccess and ForceType make
Apache run it -- do I rewrite. htaccess each time, or what?
Also, $_SERVER['PATH_INFO'] (or in my case
$_SERVER['PATH_TRANSLATED'] ) gives me the path -- so how does
that
fit in?
Please explain.
Thanks.
tedd
--
--------------------------------------------------------------------------------
> http://sperling.com
--
Like Music?
http://l-i-e.com/artists.htm
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
--------------------------------------------------------------------------------
http://sperling.com
--
Like Music?
http://l-i-e.com/artists.htm
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
--------------------------------------------------------------------------------
http://sperling.com
--- End Message ---
--- Begin Message ---
On Sun, April 23, 2006 5:25 pm, tedd wrote:
> <img src="images/the_image.png?id=<?php rand(); ?>">
>
> Neither the image tag nor the file cares if there is a random number
> attached to the file's url. But, by doing this, most (perhaps all)
> browsers think the image name is unique.
>
> Doe anyone see any problems with this?
Oh, all the browsers will KNOW it's a unique URL...
But some of them won't believe it's a valid image. :-(
Alas, I do not recall which browser would mess this up -- And it's
probably so old MOST webmasters won't care...
--
Like Music?
http://l-i-e.com/artists.htm
--- End Message ---
--- Begin Message ---
Lisa A wrote:
Can anyone suggest someone to write a simple client side shopping cart I can
use? I need to install something that my client can update the merchandise
themselves. Something inxepensive please.
thanks,
http://www.zen-cart.com/ is free, and not too difficult to manage, but
we have pulled our own version of it and use that in bitweaver, where
there is a bitcommerce module nearing completion -
http://www.bitweaver.org/ - simply because we want a commerce package
that we can use with a number of database engines rather than being
restricted to MySQL :)
Spending time to develop your shopping cart content is different to
spending time fixing problems in other peoples software. Personally I'd
rather put time back into a free project, than spend money on projects
that then still need you to work round their faults ;)
--
Lester Caine - G8HFL
-----------------------------
L.S.Caine Electronic Services
Treasurer - Firebird Foundation Inc.
--- End Message ---
--- Begin Message ---
Hi everybody!
I want to get src of image form a $text, I have a below text
$Text = <table border="1" cellpadding="3%" cellspacing="3%" width="100%">
<tr> <td width="20%">
<img align="middle" border="0" id=userupload/78/Autumn.jpg
src=userupload/78/Autumn.jpg onClick="javascript:ViewImage(this.id);"
width="100" height="100" >
</td>
<td></td></tr> </table>
</td>
<td class="frame2_middle_right"></td>
</tr>
<tr>
<td class="frame2_bottom_left"></td>
<td class="frame2_bottom_center">
</td>
--- End Message ---
--- Begin Message ---
[snip]
Hi everybody!
I want to get src of image form a $text, I have a below text
$Text = <table border="1" cellpadding="3%" cellspacing="3%"
width="100%">
<tr> <td width="20%">
<img align="middle" border="0" id=userupload/78/Autumn.jpg
src=userupload/78/Autumn.jpg onClick="javascript:ViewImage(this.id);"
width="100" height="100" >
</td>
<td></td></tr> </table>
</td>
<td class="frame2_middle_right"></td>
</tr>
<tr>
<td class="frame2_bottom_left"></td>
<td class="frame2_bottom_center">
</td>
[/snip]
And I want a pony!
RTFM http://www.php.net/regex
--- End Message ---