php-general Digest 24 Apr 2006 15:19:48 -0000 Issue 4090
Topics (messages 234603 through 234623):
Re: How to find <img> tag and get src of image
234603 by: Paul Novitski
234610 by: T.Lensselink
234615 by: Paul Scott
234619 by: Philip Thompson
Re: shopping carts
234604 by: Richard Lynch
234607 by: Robert Cummings
234613 by: Jochem Maas
234620 by: Tom Cruickshank
PHP Variables sizes
234605 by: David Killen
234606 by: chris smith
Need help with an if statement
234608 by: Pub
234609 by: admin.ensifex.nl
234611 by: Anthony Ettinger
Re: strange php url
234612 by: nicolas figaro
234618 by: Ahmed Saad
Re: CMS for Auto Parts
234614 by: Johan Martin
Jay-> RE: [PHP] How to find <img> tag and get src of image
234616 by: Ryan A
Re: Jay-> RE: [PHP] How to find <img> tag and get src of image OT
234617 by: Jay Blanchard
234623 by: Ryan A
Re: sorting troubles
234621 by: Philip Thompson
234622 by: Philip Thompson
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 ---
At 05:30 PM 4/23/2006, Pham Huu Le Quoc Phuc wrote:
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>
Pham,
Before you do anything else, fix your HTML syntax which is full of
errors. Your </table> tag appears in the middle of the table and
your id syntax is invalid:
id=userupload/78/Autumn.jpg
The specification for id [1] says it's an element of type 'name' [2]:
<quote>
ID and NAME tokens must begin with a letter ([A-Za-z]) and may be
followed by any number of letters, digits ([0-9]), hyphens ("-"),
underscores ("_"), colons (":"), and periods (".").
</quote>
In other words, you can't have slashes in your id.
Put your HTML through the W3C markup validator before trying to write
script that parses it:
http://validator.w3.org/
When you're ready, you can locate an image src using a Regular
Expression such as this:
/<img\s+[^>]*src=\"([^"])*[^>]*>\"/
which means:
<img\s+ = <img followed by one or more whitespace characters
[^>]* = zero or more characters not including a close-bracket
src=\" = src="
([^"])* = zero or more characters not including a close-quote
(THIS IS YOUR SRC VALUE)
\" = close-quote
[^>]* = any number of characters excluding close-bracket
> = close-bracket
The src attribute value will be captured by $aMatches[1] by the logic:
$sRegExp = <<< hdRE
/<img\s+[^>]*src=\"([^"])*[^>]*>\"/
hdRE;
preg_match($sRegExp, $sText, $aMatches);
This RegExp is designed to confine its result to a single HTML IMG tag.
Documentation on PHP regular expression processing begins here:
http://php.net/pcre
Regards,
Paul
[1] specification for 'id':
http://www.w3.org/TR/html4/struct/global.html#adef-id
[2] element type 'name': http://www.w3.org/TR/html4/types.html#type-name
--- End Message ---
--- Begin Message ---
Use preg_match_all
Think this will work. But i'm for sure no regular expresion guru :)
preg_match_all("/src=(.*)\040/i", $Text, $Result);
print_r($Result);
Gr,
Thijs
> 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>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--- End Message ---
--- Begin Message ---
On Mon, 2006-04-24 at 07:30 +0700, Pham Huu Le Quoc Phuc wrote:
> Hi everybody!
> I want to get src of image form a $text, I have a below text
>
Regex - there is one for exactly that on http://fsiu.uwc.ac.za check out
the wiki page of regular expressions.
--Paul
--- End Message ---
--- Begin Message ---
On Apr 23, 2006, at 10:10 PM, Paul Novitski wrote:
At 05:30 PM 4/23/2006, Pham Huu Le Quoc Phuc wrote:
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>
Pham,
Before you do anything else, fix your HTML syntax which is full of
errors. Your </table> tag appears in the middle of the table and
your id syntax is invalid:
id=userupload/78/Autumn.jpg
The specification for id [1] says it's an element of type 'name' [2]:
<quote>
ID and NAME tokens must begin with a letter ([A-Za-z]) and may be
followed by any number of letters, digits ([0-9]), hyphens ("-"),
underscores ("_"), colons (":"), and periods (".").
</quote>
In other words, you can't have slashes in your id.
Put your HTML through the W3C markup validator before trying to
write script that parses it:
http://validator.w3.org/
When you're ready, you can locate an image src using a Regular
Expression such as this:
/<img\s+[^>]*src=\"([^"])*[^>]*>\"/
which means:
<img\s+ = <img followed by one or more whitespace characters
[^>]* = zero or more characters not including a close-bracket
src=\" = src="
([^"])* = zero or more characters not including a close-quote
(THIS IS YOUR SRC VALUE)
\" = close-quote
[^>]* = any number of characters excluding close-bracket
> = close-bracket
The src attribute value will be captured by $aMatches[1] by the logic:
$sRegExp = <<< hdRE
/<img\s+[^>]*src=\"([^"])*[^>]*>\"/
hdRE;
preg_match($sRegExp, $sText, $aMatches);
This RegExp is designed to confine its result to a single HTML IMG
tag.
Documentation on PHP regular expression processing begins here:
http://php.net/pcre
Regards,
Paul
[1] specification for 'id': http://www.w3.org/TR/html4/struct/
global.html#adef-id
[2] element type 'name': http://www.w3.org/TR/html4/types.html#type-
name
Paul,
I think you are too kind. I think my response would have been likes
Jay's... RTFM. However, you went above and beyond. Isn't this
listserv great!! =D
~Phil
--- End Message ---
--- Begin Message ---
On Sun, April 23, 2006 9:01 am, tedd wrote:
> This apparently is a common theme -- "I want a good basic shopping
> cart that works AND I don't want to pay over $100 for it."
>
> Well... I want a good basic car and not pay over $100 for it too.
> But, everyone knows that those two wants are mutually exclusives. My
> question is, why aren't shopping carts viewed in the same common
> sense perspective?
>
> What's the reason?
Much good stuff deleted.
I think one of the reasons goes like this:
The Internet is such a huge marketplace.
Shopping carts are so ubiquitous (sp?)
Based on sheer volume, there oughta be a fifty dolla basic shopping
cart that is easy to install and doesn't try to do everything for
everybody.
The problem is, that inevitably, each user needs "just that one feature"
Maybe it's shipping costs.
Maybe it's T-Shirt sizes that may or may not cost more.
Maybe it's quantity discounts.
Maybe it's Taxes. :-^
Maybe it's...
And, next thing you know, you've got this nasty MONSTER on your hands
of a shopping cart that nobody without a Ph.D. can figure out how to
work the damn thing.
Another aspect is this:
Why do we call it a shopping cart?
Look, a shopping cart is a goddam big basket on wheels.
What we call a "shopping cart" on-line is actually, your entire stock
catalog, fulfillment, cash register, check-out, delivery, stock
management, and internal accounting system, with credit card POS
widgets. And baggers.
Hey. That ain't a "shopping cart" That's a friggin' store.
[shrug]
--
Like Music?
http://l-i-e.com/artists.htm
--- End Message ---
--- Begin Message ---
On Sun, 2006-04-23 at 23:20, Richard Lynch wrote:
>
> Another aspect is this:
> Why do we call it a shopping cart?
>
> Look, a shopping cart is a goddam big basket on wheels.
>
> What we call a "shopping cart" on-line is actually, your entire stock
> catalog, fulfillment, cash register, check-out, delivery, stock
> management, and internal accounting system, with credit card POS
> widgets. And baggers.
>
> Hey. That ain't a "shopping cart" That's a friggin' store.
>
> [shrug]
*lol* Thanks for the Sunday night comedy :)
Cheers,
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'
--- End Message ---
--- Begin Message ---
cheers Richard! you brightened up my monday morning.
the badger reference will keep me going till wednesday ;-)
Richard Lynch wrote:
On Sun, April 23, 2006 9:01 am, tedd wrote:
...
Another aspect is this:
Why do we call it a shopping cart?
Look, a shopping cart is a goddam big basket on wheels.
What we call a "shopping cart" on-line is actually, your entire stock
catalog, fulfillment, cash register, check-out, delivery, stock
management, and internal accounting system, with credit card POS
widgets. And baggers.
Hey. That ain't a "shopping cart" That's a friggin' store.
[shrug]
--- End Message ---
--- Begin Message ---
Have you checked out oscommerce? www.oscommerce.com?
It does what I think you need. And I think it might even be free, that is,
if your time
doesn't cost anything. As for it being simple....you'll need to define that
term.
Simple for me could be rather complicated for you or vice versa.
Tom
On 4/22/06, Lisa A <[EMAIL PROTECTED]> 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,
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--- End Message ---
--- Begin Message ---
Is there a maximum size for a variable in PHP. A client of mine is
having problems working with a file of around 4Mb. Not really being a
php developer I cannot really answer him. To quote him:
We are not uploading excel from ftp. We are reading excel file which is
about 4 MB. In php settings maximum size of any variable is set to 2 MB so
this setting has to change. As any file reading in a variable will only read
up to 2 MB and then it will stop.
I wasn't aware of any setting that allows you to change the max variable
size. Can anyone shed any light on this?
Cheers,
David.
--- End Message ---
--- Begin Message ---
On 4/24/06, David Killen <[EMAIL PROTECTED]> wrote:
> Is there a maximum size for a variable in PHP. A client of mine is
> having problems working with a file of around 4Mb. Not really being a
> php developer I cannot really answer him. To quote him:
>
> We are not uploading excel from ftp. We are reading excel file which is
> about 4 MB. In php settings maximum size of any variable is set to 2 MB so
> this setting has to change. As any file reading in a variable will only read
> up to 2 MB and then it will stop.
>
> I wasn't aware of any setting that allows you to change the max variable
> size. Can anyone shed any light on this?
memory_limit will affect this.
http://www.php.net/manual/en/ini.core.php and
http://www.php.net/manual/en/ini.php#ini.list will show you how to
change the limit.
--
Postgresql & php tutorials
http://www.designmagick.com/
--- End Message ---
--- Begin Message ---
Hello,
I am really new to all this and I am really hoping I can get some
help PLEASE...
I am making a website with x-cart which uses PHP and Smarty templates.
I need to make an " if " statement that puts a little arrow gif in
front of the link that is clicked on! make any sense?
In other words:
item 1 (not selected)
item 2 (not selected)
> item 3 (selected)
item 4 (not selected)
This is what I have now, but I don't know what to call my {if ?????}
{if ?????}<A href="{?????}"><FONT class="buttontextonly"><IMG
src="{$ImagesDir}/arrow.gif" width="9" height="7" border="0"
align="abstop">{$menu_content}</FONT></A>
{else}
<FONT class="VertMenuTitle">{$menu_content}</FONT>
{/if}</TD>
--- End Message ---
--- Begin Message ---
Kinda depends on how you build the list of links i guess. What you need is
a unique identifier. But would be more easy if you show some code.
item 1 cart.php?item=1
item 2 cart.php?item=2
Then when you make the links. Use a loop
foreach($links as $link) {
if ($link["id"] == $_GET["item"])
{
// arrow image here
}
}
Well anyway. Show some code how you build the links list. My code sucks
but it's a start. It's to early :)
Gr,
Thijs
> Hello,
>
> I am really new to all this and I am really hoping I can get some
> help PLEASE...
> I am making a website with x-cart which uses PHP and Smarty templates.
>
> I need to make an " if " statement that puts a little arrow gif in
> front of the link that is clicked on! make any sense?
>
> In other words:
>
> item 1 (not selected)
> item 2 (not selected)
> > item 3 (selected)
> item 4 (not selected)
>
> This is what I have now, but I don't know what to call my {if ?????}
>
> {if ?????}<A href="{?????}"><FONT class="buttontextonly"><IMG
> src="{$ImagesDir}/arrow.gif" width="9" height="7" border="0"
> align="abstop">{$menu_content}</FONT></A>
> {else}
> <FONT class="VertMenuTitle">{$menu_content}</FONT>
> {/if}</TD>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--- End Message ---
--- Begin Message ---
Yikes...<font>? that's been deprecated since the turn of the century!
do it with css...
html
<ul>
<li>item 1</li>
<li class="selected">item 2</li>
<li>item 3</li>
</ul>
css:
ul li { background-image: url("/img/arrow-off.png"); color: gray; }
ul .selected { background-image: url("/img/arrow-on.png"); color: red; }
http://www.w3.org/TR/CSS21/colors.html#propdef-background-image
The real question here though is looping through your menu items or
"nodes" in your tree (unordered list)...you'll need to read up on DOM
in php5 or domxml in php4.
I have broken down my page into libraries, for example, my menu.php is
included at the top of every page, and loops through the tree,
checking for whatever condition (in my case I check the current url
against the anchor href for every list item, and if it's equal, then I
dynamically set the class="selected" on the item (parent of anchor),
which can turn it blue, and add an arrowon.png (this part should be
taken care of with css, so you can easily redesign it without changing
your code.
<?php
function selectMenuItem()
{
global $htdocs;
global $uri;
$uri = getenv('REQUEST_URI');
$dom = new DOMDocument;
#xhtml fragment which contains the menu
$dom->load("$htdocs/xml/menu.xml");
$xpath = new DOMXPath($dom);
#uses xpath query to find anchors with parent of list item
$nodes = $xpath->query("//a[parent::li]");
foreach ($nodes as $node)
{
$attr = $node->getAttribute('href');
if($attr == $uri)
{
$node->setAttribute('class', 'selected');
}
}
#print $dom->saveXML(); #prepends xml declaration and breaks
in IE6 if not the first line.
print $dom->saveHTML();
}
You can read more about dom with php here: http://www.php.net/dom
Be aware, that you can decorate the heck out of your class/id with
css, an unordered list can look like a set of tabs if needed.
On 4/23/06, Pub <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I am really new to all this and I am really hoping I can get some
> help PLEASE...
> I am making a website with x-cart which uses PHP and Smarty templates.
>
> I need to make an " if " statement that puts a little arrow gif in
> front of the link that is clicked on! make any sense?
>
> In other words:
>
> item 1 (not selected)
> item 2 (not selected)
> > item 3 (selected)
> item 4 (not selected)
>
> This is what I have now, but I don't know what to call my {if ?????}
>
> {if ?????}<A href="{?????}"><FONT class="buttontextonly"><IMG
> src="{$ImagesDir}/arrow.gif" width="9" height="7" border="0"
> align="abstop">{$menu_content}</FONT></A>
> {else}
> <FONT class="VertMenuTitle">{$menu_content}</FONT>
> {/if}</TD>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>
--
Anthony Ettinger
Signature: http://chovy.dyndns.org/hcard.html
--- End Message ---
--- Begin Message ---
Hi all and thanks for the answers.
On my server, the building of some webpages with url like the one below
produces a loop
and crashes the server.
(http://myurl.mydomain/path/index.php/path/index.php).
As I never heard about the PATH_INFO before, I'm not sure the site uses
this value.
(I'll check the code to be sure).
If I can make sure the PATH_INFO isn't used anywhere in the code, is
there a way to
change the config in order to generate a 404 for each url with a not
null PATH_INFO ?
Nicolas Figaro
Joe Wollard a écrit :
I believe Kevin is on the right track there. To expand a bit, you can use
$_SERVER['PATH_INFO'] with these urls instead of $_GET to make use of the
data it contains
example for url http://www.example.com/index.php/foo/bar
<?php
echo $_SERVER['PATH_INFO'];
?>
produces:
/foo/bar
You can then parse this string, (generally by using the '/' character as a
deliminator) and extract the data. MediaWiki even provides information
(can't think of where at the moment) on how to use Apache's mod_rewrite to
hide index.php thus making the url even cleaner:
http://www.example.com/foo/bar
Cheers!
- Joe
On 4/21/06, Kevin Kinsey <[EMAIL PROTECTED]> wrote:
Hi,
could anyone tell me why the following url doesn't
generate a "page not found" ?
http://www.php.net/manual/en/function.checkdnsrr.php/manual/
you can try with a longer url after the last .php.
I tried with ../manual instead of manual and this produces a 404.
I checked with www.php.net because my own site does the same and I
wanted to be sure it didn't come from my config.
thanks
Nicolas Figaro
[EMAIL PROTECTED] wrote:
The other thing that could happen is they could be
using something like the Apache mod_rewrite (some
info at http://www.modrewrite.com/ among others) which
can dynamically change the requested URL to a more
standard URL before sending back to the user.
Something like this:
http://www.testserver.com/tgryffyn/homepage/middlesection
Could be turned into something like:
http://www.testserver.com/userpage.php?user=tgryffyn&page=home#middleanchor
But to the user requesting the page, it'll always look like the first
URL.
Forgive me if I got any syntax or capability of mod_rewrite wrong,
never used it myself just know that's the general sort of thing that it
does.
Pretty good thoughts, there. Some years ago, Tim Perdue
(of PHPBuilder and SourceForge fame) had a popular
article on "Search Engine Friendly URL's" (or some such),
in which he described use of the Apache ForceLocal
directive to make a site just One Big Script, parsing
the slashed portions of the query string as variables
(instead of GET, a la "?section=man&term=foo") so that
the browser appears to be accessing documents in subfolders,
but it's really just telling the server to grab a page with certain
values defined in the URI.
It sure looks like a possibility of this or similar magic in
this case. Of course, I could be way off my tree...
Kevin Kinsey
--
Byte your tongue.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
On 4/21/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> redirects to:
> http://www.example.com/index.php?action=edit&type=customer&id=1234&adminaccess=1
and you put admin access flags (read, determine roles) in URL parameters?
-ahmed
--- End Message ---
--- Begin Message ---
On 23 Apr 2006, at 8:03 PM, John Hicks 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
You may want to look into openlaszlo. http://www.openlaszlo.org/ You
can use it to provide the Internet front-end and use PHP for the back-
end. Also, now has the option for either DHTML or Flash on the client
side.
Johan Martin
Catenare LLC
--- End Message ---
--- Begin Message ---
--- Jay Blanchard <[EMAIL PROTECTED]> wrote:
> [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
Jay, a warning would be nice before you post stuff
like you posted above... I am _supposed_ to be working
here and suddenly when I burst into laughter and then
control myself to a big smile on my face everyone
looks at me and thinks I am not working but just
goofing off on the job.
Cheers!
------
- The faulty interface lies between the chair and the keyboard.
- Creativity is great, but plagiarism is faster!
- Smile, everyone loves a moron. :-)
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
--- End Message ---
--- Begin Message ---
[snip]
> I want to get src of image form a $text
> And I want a pony!
>
Jay, a warning would be nice before you post stuff
like you posted above... I am _supposed_ to be working
here and suddenly when I burst into laughter and then
control myself to a big smile on my face everyone
looks at me and thinks I am not working but just
goofing off on the job.
[/snip]
PHP Comic Relief! Send in your money now! I will see if I can conjure up
an appropriate disclaimer.
--- End Message ---
--- Begin Message ---
--- Jay Blanchard <[EMAIL PROTECTED]> wrote:
> [snip]
> > I want to get src of image form a $text
>
> > And I want a pony!
> >
>
> Jay, a warning would be nice before you post stuff
> like you posted above... I am _supposed_ to be
> working
> here and suddenly when I burst into laughter and
> then
> control myself to a big smile on my face everyone
> looks at me and thinks I am not working but just
> goofing off on the job.
> [/snip]
>
> PHP Comic Relief! Send in your money now! I will see
> if I can conjure up
> an appropriate disclaimer.
"Send in your money now!"????!!??
ok, stopped laughing.....
------
- The faulty interface lies between the chair and the keyboard.
- Creativity is great, but plagiarism is faster!
- Smile, everyone loves a moron. :-)
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
--- End Message ---
--- Begin Message ---
On Apr 22, 2006, at 4:49 AM, 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? Like
A20
B17
B16
C15
C14
D13
D12
Thanks
-Will
Maybe I'm missing something, but I don't think that I've seen anyone
mention this. Can you not just sort the data before it reaches your
php code... meaning, via the db? My example uses MySQL:
<?
$result = msyql_query("SELECT * FROM your_database ORDER BY ASC",
$link);
while ($row = mysql_fetch_array($result, MYSQL_ASSOC))
$column[$i++] = $row["your_column"];
...
for ($i=0; $i<$numOfCols; $i++)
echo "$column[$i]<br/>";
?>
Again, I may have misread what you are asking, but this appears to be
a simple solution when pulling from a database.
Good luck,
~Philip
--- End Message ---
--- Begin Message ---
On Apr 24, 2006, at 9:06 AM, Philip Thompson wrote:
On Apr 22, 2006, at 4:49 AM, 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? Like
A20
B17
B16
C15
C14
D13
D12
Thanks
-Will
Maybe I'm missing something, but I don't think that I've seen
anyone mention this. Can you not just sort the data before it
reaches your php code... meaning, via the db? My example uses MySQL:
<?
$result = msyql_query("SELECT * FROM your_database ORDER BY ASC",
$link);
Ooops!
... ORDER BY your_column ASC ...
while ($row = mysql_fetch_array($result, MYSQL_ASSOC))
$column[$i++] = $row["your_column"];
...
for ($i=0; $i<$numOfCols; $i++)
echo "$column[$i]<br/>";
?>
Again, I may have misread what you are asking, but this appears to
be a simple solution when pulling from a database.
Good luck,
~Philip
--- End Message ---