[PHP] Upload using FTP commands

2010-08-26 Thread Matthew Croud


Hi,

I want to give my client the ability to upload large files ( around  
20MB ) to a webspace.
I reckon that using the FTP commands of PHP would be the best bet, but  
is it possible to allow them to do this through an online form.


This is my vision: the client logs in to a form that has an upload  
button, and the upload button uses the FTP commands to upload the file.


Is that do-able in PHP ?

Cheers!







--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] image upload keeps file name ?

2010-04-01 Thread Matthew Croud

Hi Guys,

Can someone confirm for me that the code below will move an uploaded  
file and give it the same name as the original image file name ?



$file_dir = /home/uploads;
foreach($_FILES as $file_name = $file_array) {
echo path: .$file_array[tmp_name].br/\n;
echo name: .$file_array[name].br/\n;
echo type: .$file_array[type].br/\n;
echo size: .$file_array[size].br/\n;

$UploadName[$num] = $file_array[name];
$num++;

if (is_uploaded_file($file_array[tmp_name])) {
		move_uploaded_file($file_array[tmp_name], $file_dir/. 
$file_array[name]) or die (Couldn't copy);

echo file was moved!br/;
}
}



Many thanks,





--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] DOM append to the top

2009-11-20 Thread Matthew Croud

Yo!

I have a working form that adds user input to an XML file, it adds the  
new item element to the bottom of the list of previously created  
item elements.
I would now like the new elements to be added to the top of the list.   
So far i've tried using: insertBefore() but i'm still getting elements  
added to the bottom.


The XML looks like:

Clothes
Item.../Item
Item.../Item
Item.../Item
- new items are added here
Clothes

This is what my code looks like:

$y = $dom - getElementsByTagName(item);
$dom - documentElement - insertBefore($Xitem,$y);

If trying to pass the top most item node to insertbefore() but  
without any luck.  Any ideas ?


Cheers
Mongoose

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Multiple file upload

2009-11-11 Thread Matthew Croud

Dear lords of PHP,

I have a working image upload script that meets all my needs,
My question is I need to upload multiple images using the same form,

This is the PHP part I have so far, largely taken from a book:
_

$file_dir = /public_html/uploads;
foreach($_FILES as $file_name = $file_array) {
echo path: .$file_array[tmp_name].br/\n;
echo name: .$file_array[name].br/\n;

$UploadName = $file_array[name];

if (is_uploaded_file($file_array[tmp_name])) {
		move_uploaded_file($file_array[tmp_name], $file_dir/. 
$file_array[name]) or die (Couldn't copy);

echo file was moved!br/;
}
}
_

Lets say the HTML from that sends data to this script has 3 upload  
forms that get send to $_FILES, would I access the data by modifying  
the following line from the above example:

...
foreach($_FILES[' UPLOADIMAGE1 '] as $file_name = $file_array) {
...

...
foreach($_FILES[' UPLOADIMAGE2 '] as $file_name = $file_array) {
...

...
foreach($_FILES[' UPLOADIMAGE3 '] as $file_name = $file_array) {
...

Thanks for reading!
Matt Cheezoid

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] opposite of quotemeta ?

2009-10-29 Thread Matthew Croud

Hi,

In my script I want the user to enter some html which is saved to a  
file,

I've noticed that php rather cleverly escapes the speech marks, so:

a href=www.google.comGoogle/a

becomes:

a href=\www.google.com\Google/a

Is there some function which prevents or reverts this ? something  
similar to html_entities maybe?


Many thanks!
Matt

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Fun with XSLT

2009-10-22 Thread Matthew Croud

Hi Guys,

Well i;ve been slaving on with my PHP XML endeavors and i'm loving it,  
just finishing the meaty parts of my XSLT for dummies book too.


I have a question which asks is it possible?.

Using XSLT I can collect specific parts of my XML using something sexy  
like xsl:template match=umbungo.  Lets say however, that I need to  
use XSLT, but I would want the user to select which element they  
request. In other words, they are given a form with options and that  
form can manipulate the .XSL file.


Now I know it could be done in a lengthly manner by just opening the  
XSL file and manipulating it like fopen or something like that, but is  
there a way to somehow embed the contents of the xml into the php code  
(like using  EOF for html), and being able to substitute the  
template match string for a variable ?


Any ideas ?

Thanks Gamesmaster,
Matt







Re: [PHP] Re: Fun with XSLT

2009-10-22 Thread Matthew Croud


On 22 Oct 2009, at 16:39, Peter Ford wrote:


Matthew Croud wrote:

Hi Guys,

Well i;ve been slaving on with my PHP XML endeavors and i'm loving  
it,

just finishing the meaty parts of my XSLT for dummies book too.

I have a question which asks is it possible?.

Using XSLT I can collect specific parts of my XML using something  
sexy
like xsl:template match=umbungo.  Lets say however, that I need  
to

use XSLT, but I would want the user to select which element they
request. In other words, they are given a form with options and that
form can manipulate the .XSL file.

Now I know it could be done in a lengthly manner by just opening  
the XSL
file and manipulating it like fopen or something like that, but is  
there
a way to somehow embed the contents of the xml into the php code  
(like
using  EOF for html), and being able to substitute the template  
match

string for a variable ?

Any ideas ?

Thanks Gamesmaster,
Matt


A bit off-topic (since XSLT is not PHP...) but here goes.

First I need to clarify what you are doing -
xsl:template match=umbongo ... /xsl:template
defines the template portion, and that is pretty immutable.

At some point you must have in your XSLT something like
xsl:apply-templates select=umbongo/
This is the bit you can play with:

so:


xsl:stylesheet version=1.0 xmlns:xsl=http://www.w3.org/1999/XSL/Transform 


   xsl:output method=xml encoding=UTF-8 / !-- or whatever --

!-- Pass in a parameter to the XSL to define which thing we want to  
match --

   xsl:parameter name='matchMe'/

!-- Define templates for all the things we might want to match --
   xsl:template match='umbongo'xsl:apply-templates//xsl:template
   xsl:template match='fivealive'xsl:apply-templates// 
xsl:template

   !-- etc. --

!-- now the clever bit --
   xsl:template match='/'
   xsl:apply-templates select='//*[name()=$matchMe]'/
   /xsl:template

/xsl:stylesheet

Essentially you need to apply the template of any element, but only  
those whose

name matches your request.
Note that
xsl:apply-templates select='$matchMe]'/
doesn't work... :(

So now if your PHP does something like

$xslDom = new DOMDocument();
$xslDom-load('matchMe.xsl');
$xslt = new XSLTProcessor();
$xslt-importStylesheet($xslDom);
$xslt-setParameter('','matchMe','umbongo');
$xmlDom = new DOMDocument();
$xmlDom-load('some_document_that_has_an_umbongo_tag.xml');
echo $xslt-transformToXML($xmlDom);

you should get the results of the 'umbongo' template (only)


'f course, this is not tested, but I have used this idea in working  
code





--
Peter Ford  phone: 01580 89
Developer   fax:   01580 893399
Justcroft International Ltd., Staplehurst, Kent

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





Utter brilliance, this is superb, I might drop you a mail to clarify a  
few things later Peter,
but your reply was superb and has given me many options to try out.   
Thanks again!






--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Spry, XML, PHP and XSLT Hell

2009-10-06 Thread Matthew Croud


Okey Doke,

I'll try and be brief,
Well, my client agreed to a small online store that would hold the  
same stock items where only the quantities would differ, we agreed  
that, due to infrequent changes, I would make pages for any new items,  
and she would control stock etc using an e-shopping package I bought.


The site also has a page of Returned items, this takes the form of a  
Spry list, which uses an XML  list of clothing and their properties.

 It all worked great.

Yesterday my client said she wanted the ability to add, remove, edit  
new products by herself,  eek!
I thought about implementing another list similar to the returned  
items page, but I learned that XML will turn HTML elements like  and  
 into lt; and gt;


Then someone on this wonderful mailing list mentioned that HTML can be  
stored in XML using XSLT.


I suppose my question is, to what extend can XSLT decorate and display  
an XML file, can I add style sheets and rollovers, can I control the  
cacheing so that users wont need to empty their cache to see changed  
results ? Does it all work fine with PHP when I include it in a file ?


Sorry if this is a bit weird, but I'm bricking myself with this one,  
and I would just like to hear some voices from people who have been  
there and bought the t shirt,


Cheers folks!

Matt.



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Display HTML in XSL Style Sheet

2009-10-06 Thread Matthew Croud

Hi,
Is there a way to store HTML in an XML file,
Access that node using XLST, and have it display as rendered html ?

So far my attempts either return the text equivalent of the html, with  
nothing rendered.


Cheers,
Matt.








--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] XML. Prevent from turning into lt;

2009-09-09 Thread Matthew Croud


Hiya,
I'm writing an app that let's my client upload images, the image html  
code is added to an XML file.

Take a look at the image element below:

item Code=e1022
codee1022/code
image![CDATA[img src=uploads/image2.jpg alt=Homepage  
Image width=124 height=70 /]]/image

nameBlue Ski Trousers/name
price8.99/price
  /item

Now, whenever PHP writes this to the XML files, it turns the  and   
into lt; and gt; . which means it does not display on the webpage.   
How can I prevent this from happening ?


Many thanks,
Matt


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] XML. Prevent from turning into lt;

2009-09-09 Thread Matthew Croud


On 9 Sep 2009, at 14:26, Bastien Koert wrote:

On Wed, Sep 9, 2009 at 5:27 AM, Matthew  
Croudm...@obviousdigital.com wrote:


Hiya,
I'm writing an app that let's my client upload images, the image  
html code

is added to an XML file.
Take a look at the image element below:

item Code=e1022
   codee1022/code
   image![CDATA[img src=uploads/image2.jpg alt=Homepage Image
width=124 height=70 /]]/image
   nameBlue Ski Trousers/name
   price8.99/price
 /item

Now, whenever PHP writes this to the XML files, it turns the  and  
 into
lt; and gt; . which means it does not display on the webpage.   
How can I

prevent this from happening ?

Many thanks,
Matt


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




str_replace?


--

Bastien

Cat, the other other white meat



I've tried that but no matter what i do in the PHP side of things, as  
soon as I save that XML the conversion takes place.
Should the XML be encoded in any way, is there a setting somewhere  
that prevents this ?


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] XML. Prevent from turning into lt;

2009-09-09 Thread Matthew Croud


On 9 Sep 2009, at 14:36, Bob McConnell wrote:


From: Bastien Koert
On Wed, Sep 9, 2009 at 5:27 AM, Matthew  
Croudm...@obviousdigital.com wrote:


Hiya,
I'm writing an app that let's my client upload images, the image  
html code

is added to an XML file.
Take a look at the image element below:

item Code=e1022
   codee1022/code
   image![CDATA[img src=uploads/image2.jpg alt=Homepage  
Image

width=124 height=70 /]]/image
   nameBlue Ski Trousers/name
   price8.99/price
 /item

Now, whenever PHP writes this to the XML files, it turns the  and  
 into
lt; and gt; . which means it does not display on the webpage.   
How can I

prevent this from happening ?



str_replace?



Does the xml string get passed to htmlentities() or a similar  
function before it is sent to the browser? That would explain the  
substitutions. I saw an xmlentities() variation mentioned somewhere.


Bob McConnell

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Hi Bob,

Nope the string doesn't get passed into any function.
Here is the XML:
_

?xml version=1.0 encoding=UTF-8?
clothes

  item Code=e1021
codee1021/code
image![CDATA[img src=uploads/image1.jpg alt=Homepage  
Image width=124 height=70 border=1  
onclick=MM_openBrWindow('uploads/ 
image1.jpg','Preview','width=680,height=520') /]]/image

nameRed Jacket/name
descAn adult sized red jacket/desc
sizeadult/size
price12.99/price
  /item

  item Code=e1022
codee1022/code
image![CDATA[img src=uploads/image2.jpg alt=Homepage  
Image width=124 height=70 border=1  
onclick=MM_openBrWindow('uploads/ 
image2.jpg','Preview','width=680,height=520') /]]/image

nameBlue Ski Trousers/name
descA pair of Blue Ski Trousers/desc
sizechild/size
price8.99/price
  /item

/clothes



Now the image tags I have written here I have done manually, but when  
I use PHP using DOM they come out like this (note the image element):


item Code=e1024
codee1024/code
imagelt;![CDATA[lt;img src=uploads/image4.jpg alt=Homepage  
Image width=124 height=70 border=1  
onclick=MM_openBrWindow('uploads/ 
image4.jpg','Preview','width=680,height=520') /gt;]]gt;/image

nameorange top/name
descan orange jacket/desc
sizelarge/size
price14.50/price
/item




Matthew Croud
Studio

Obvious Print Solutions Limited
Unit 3 Abbeygate Court
Stockett Lane
Maidstone
Kent
ME15 0PP

T | 0845 094 9704
F | 0845 094 9705
www.obviousprint.com







Re: [PHP] XML. Prevent from turning into lt;

2009-09-09 Thread Matthew Croud


On 9 Sep 2009, at 16:37, Ashley Sheridan wrote:


On Wed, 2009-09-09 at 15:14 +0100, Matthew Croud wrote:

On 9 Sep 2009, at 15:09, Ashley Sheridan wrote:


On Wed, 2009-09-09 at 14:46 +0100, Matthew Croud wrote:

On 9 Sep 2009, at 14:36, Bob McConnell wrote:


From: Bastien Koert

On Wed, Sep 9, 2009 at 5:27 AM, Matthew
Croudm...@obviousdigital.com wrote:


Hiya,
I'm writing an app that let's my client upload images, the image
html code
is added to an XML file.
Take a look at the image element below:

item Code=e1022
 codee1022/code
 image![CDATA[img src=uploads/image2.jpg alt=Homepage
Image
width=124 height=70 /]]/image
 nameBlue Ski Trousers/name
 price8.99/price
/item

Now, whenever PHP writes this to the XML files, it turns the   
and

into

lt; and gt; . which means it does not display on the webpage.
How can I
prevent this from happening ?



str_replace?



Does the xml string get passed to htmlentities() or a similar
function before it is sent to the browser? That would explain the
substitutions. I saw an xmlentities() variation mentioned  
somewhere.


Bob McConnell

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Hi Bob,

Nope the string doesn't get passed into any function.
Here is the XML:
_

?xml version=1.0 encoding=UTF-8?
clothes

 item Code=e1021
   codee1021/code
   image![CDATA[img src=uploads/image1.jpg alt=Homepage
Image width=124 height=70 border=1
onclick=MM_openBrWindow('uploads/
image1.jpg','Preview','width=680,height=520') /]]/image
   nameRed Jacket/name
   descAn adult sized red jacket/desc
   sizeadult/size
   price12.99/price
 /item

 item Code=e1022
   codee1022/code
   image![CDATA[img src=uploads/image2.jpg alt=Homepage
Image width=124 height=70 border=1
onclick=MM_openBrWindow('uploads/
image2.jpg','Preview','width=680,height=520') /]]/image
   nameBlue Ski Trousers/name
   descA pair of Blue Ski Trousers/desc
   sizechild/size
   price8.99/price
 /item

/clothes



Now the image tags I have written here I have done manually, but  
when
I use PHP using DOM they come out like this (note the image  
element):


item Code=e1024
codee1024/code
imagelt;![CDATA[lt;img src=uploads/image4.jpg alt=Homepage
Image width=124 height=70 border=1
onclick=MM_openBrWindow('uploads/
image4.jpg','Preview','width=680,height=520') /gt;]]gt;/image
nameorange top/name
descan orange jacket/desc
sizelarge/size
price14.50/price
/item




Matthew Croud
Studio

Obvious Print Solutions Limited
Unit 3 Abbeygate Court
Stockett Lane
Maidstone
Kent
ME15 0PP

T | 0845 094 9704
F | 0845 094 9705
www.obviousprint.com





I've not experienced this with using any DOM functions, but if we  
can

see your code it might help us.

Thanks,
Ash
http://www.ashleysheridan.co.uk




--  
PHP General Mailing List (http://www.php.net/)

To unsubscribe, visit: http://www.php.net/unsub.php






Well i'll pop the PHP down here, i'll trim it as much as i can:


$code = $_POST['code'];
$name = $_POST['name'];
$desc = $_POST['desc'];
$size = $_POST['size'];
$price = $_POST['price'];


#load an XML document into the DOM

$dom = new DomDocument();
$dom - load(items.xml);

#create elements

$Xitem =  $dom - createElement(item);
$Xcode =  $dom - createElement(code);
$Ximage =  $dom - createElement(image);
$Xname =  $dom - createElement(name);
$Xdesc = $dom - createElement(desc);
$Xsize = $dom - createElement(size);
$Xprice = $dom - createElement(price);

#create text nodes

$Xcodetext =  $dom - createTextNode($code);
$Ximagetext =  $dom - createTextNode( ![CDATA[img src=\uploads/
$UploadName\ alt=\Homepage Image\ width=\124\ height=\70\
border=\1\ onclick=\MM_openBrWindow('uploads/
$UploadName','Preview','width=680,height=520')\ /]] );
$Xnametext =  $dom - createTextNode($name);
$Xdesctext = $dom - createTextNode($desc);
$Xsizetext =$dom - createTextNode($size);
$Xpricetext =$dom - createTextNode($price);

#append the text nodes to the inner nested elements

$Xcode  - appendChild($Xcodetext);
$Ximage  - appendChild($Ximagetext);
$Xname  - appendChild($Xnametext);
$Xdesc - appendChild($Xdesctext);
$Xsize- appendChild($Xsizetext);
$Xprice- appendChild($Xpricetext);

#append the inner nested elements to the item element

$Xitem - appendChild($Xcode);
$Xitem - appendChild($Ximage);
$Xitem - appendChild($Xname);
$Xitem - appendChild($Xdesc);
$Xitem - appendChild($Xsize);
$Xitem - appendChild($Xprice);
$Xitem - setAttribute(Code,$code);

#append the title element to the root element

$dom - documentElement - appendChild($Xitem);

#create a new enlarged xml document

$dom - save(items.xml);

_
It looks like it's because you are creating an image object by  
appending

a text node inside CDATA to it. My guess

Re: [PHP] Return XML attribute in DOM

2009-09-08 Thread Matthew Croud


Cheers Guys,
Your the greatest !



On 8 Sep 2009, at 09:08, Peter Ford wrote:


Matthew Croud wrote:

Doesn't the DOM have the getAttribute() method?


Thanks,
Ash
http://www.ashleysheridan.co.uk


It's not in my reference, though I see it in the PHP manual now.
This is what I have:

_

$dom = new DomDocument();
$dom - load(items.xml);

$topics = $dom - getElementsByTagName(item);

echo(ul);
foreach ($topics as $node )
{
   echo(li. $node - hasAttributes() ./li);
}
echo(/ul);

__

I'm replacing hasAttributes() with getAttribute() but its throwing  
me an

error, I'm probably using it incorrectly.
I think I'm drowning in the deep end =/
Could you advise Gamesmaster ?



It's a method on DomElement:
http://uk3.php.net/manual/en/function.domelement-get-attribute.php

and you need to tell it which attribute to get... :)

--
Peter Ford  phone: 01580 89
Developer   fax:   01580 893399
Justcroft International Ltd., Staplehurst, Kent

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Matthew Croud
Studio

Obvious Print Solutions Limited
Unit 3 Abbeygate Court
Stockett Lane
Maidstone
Kent
ME15 0PP

T | 0845 094 9704
F | 0845 094 9705
www.obviousprint.com







[PHP] Return XML attribute in DOM

2009-09-07 Thread Matthew Croud



I'm at my wits end here, so close to the finishing line!

Is there a method to return an attribute value of an XML node using  
DOM, I can check to see if an attribute exists using hasAttributes()

But I can't retrieve the value.

I'm so desperate i've started to eat dirt.

Many thanks,
Matt

Re: [PHP] Return XML attribute in DOM

2009-09-07 Thread Matthew Croud

Doesn't the DOM have the getAttribute() method?


Thanks,
Ash
http://www.ashleysheridan.co.uk


It's not in my reference, though I see it in the PHP manual now.
This is what I have:

_

$dom = new DomDocument();
$dom - load(items.xml);

$topics = $dom - getElementsByTagName(item);

echo(ul);
foreach ($topics as $node )
{
echo(li. $node - hasAttributes() ./li); 
}
echo(/ul);

__

I'm replacing hasAttributes() with getAttribute() but its throwing me  
an error, I'm probably using it incorrectly.

I think I'm drowning in the deep end =/
Could you advise Gamesmaster ?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Some help with SimpleXML :`(

2009-09-04 Thread Matthew Croud


Well, you guys are awesome.

So the script below doesn't cause any errors (nice), however it  
doesn't save the newly added child to the xml file (items.xml):




$xml = simplexml_load_file(items.xml);

$item = $xml-addChild('item');
$item-addChild('name', $name);
$item-addChild('desc', $desc);
$item-addChild('size', $size);
$item-addChild('price', $price);



I thought it would ?  would i need to write using fwrite ?


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Some help with SimpleXML :`(

2009-09-03 Thread Matthew Croud

Hi foks,

Could someone lend me a little hand with simpleXML ?
I've been looking at examples in the PHP manual and W3C, i'm at the  
pinnacle of figuring it out but alas i need a hand from the mailing  
list dudes.


My aim is to add another item node, so i'll start with my XML file  
called items.xml


Item.xml_

?xml version=1.0 encoding=iso-8859-1?
clothes

  item
nameRed Gloves/name
desca pair of red gloves/desc
sizeadult/size
price12.99/price
  /item

  item
nameSnow Boots/name
descsome snow boots/desc
sizechild/size
price23.99/price
  /item

/clothes
__


And now the PHP i'm using to create a new item node:


$xml = simplexml_load_file('items.xml');

$item = $xml-clothes-addChild('item');
$item-addChild('name', 'blue gloves');
$item-addChild('desc', 'some blue gloves');
$item-addChild('size', 'adult');
$item-addChild('price', '4.99');

__

The error i'm getting is:  Cannot add child. Parent is not a  
permanent member of the XML tree



Help me Gamesmaster!
Matt

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Host that allows edit of php.ini

2009-07-08 Thread Matthew Croud

Apologies if this type of question is frowned upon in the mailing list,
however I would like to pop the question to those in the know.

Can anyone recommend a UK host that allows you to edit ( or a copy  
of ) the php.ini file,
allowing me to increase the file upload size to 100mb for clients PDF  
artwork files.

I wish to create an upload site for my print firm.

Your recommendations are greatly appreciated.

Matt.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Advise on starting a web store site

2009-07-06 Thread Matthew Croud

Hi,

I'm going to start my first e commerce website for a small web shoe  
store.
I think I know enough PHP to keep my head above water, I'm using an  
add on shopping cart package to deal with the transactions.


My question is, what's the best way to design a site where each  
product appears to have its own page.


Is there a way to create the site *without* having each product have a  
physical separate page ?


Is there a method of web design which makes creating new pages simple  
if they all follow the same pattern. i.e thumbnail, description etc.


Thanks guys,

Matt.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] difference between two times? Date_diff and DateTime::diff

2009-06-16 Thread Matthew Croud


Hello,

My journey of learning PHP is going well, so i've decided to make a  
small program which works out the difference between two times and  
records the data in a text file.


I've searched the PHP manual for functions which can help me out, and  
I discovered the function Date_diff ( http://uk3.php.net/manual/en/function.date-diff.php 
 )and the class DateTime::diff ( http://uk3.php.net/manual/en/datetime.diff.php 
 )


My question is, how on earth do I use these functions ? I really don't  
understand the manual documentation.


I've just moved onto the subject of classes and so I'm fairly new to  
the concept, although I am following it well.


If someone could explain to me how to use ether of these ( Date_diff  
and DateTime::diff ) I would be VERY grateful.


Thank you so much!
Matt

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] difference between two times? Date_diff and DateTime::diff

2009-06-16 Thread Matthew Croud

Hi Tom,

Thanks for the reply,  I believe I have a fair understanding of  
functions, and I have followed the example on the PHP manual page ( http://uk3.php.net/manual/en/function.date-diff.php 
 ), ideally I want to know how to use the class DateTime::diff, how  
can I use the DateTime::diff to get the difference between two times/ 
dates ? I suppose then I'm after the syntax


would it be like this for example:
$DIfferenceInTime  = DateTime::diff(10:00,12:32);

Thanks again for helping me out.



On 16 Jun 2009, at 12:33, Tom Chubb wrote:


Matt,
Do you understand how to use functions?
A function is defined like this:

function () {
//code goes here
}

You can pass arguments to be used in a function like this:

function($arg1, $arg2) {
//code goes here
}

In the first example on the following page: 
http://uk3.php.net/manual/en/function.date-diff.php
To call the function you need to provide two arguments: $dtTime1
$dtTime2


To use in a script, you need to first define the function, as per  
the example:


?php

function GetDeltaTime($dtTime1, $dtTime2)
{
  $nUXDate1 = strtotime($dtTime1-format(Y-m-d H:i:s));
  $nUXDate2 = strtotime($dtTime2-format(Y-m-d H:i:s));

  $nUXDelta = $nUXDate1 - $nUXDate2;
  $strDeltaTime =  . $nUXDelta/60/60; // sec - hour

  $nPos = strpos($strDeltaTime, .);
  if (nPos !== false)
$strDeltaTime = substr($strDeltaTime, 0, $nPos + 3);

  return $strDeltaTime;
}

?

Then you need to call the function like this:

?php
GetDeltaTime(time1-goes-here, time2-goes-here)
?

And it should spit out the difference.

Code is untested and if you didn't follow that I suggest you read up  
on functions: http://www.w3schools.com/php/php_functions.asp


Hope this helps - I'm probably in a similar situation to you and  
have been dabbling with PHP for a few years just as a hobby but  
thought I'd try and help out.

You'll learn a lot from reading this list as well.

Cheers and good luck,

Tom


2009/6/16 Matthew Croud m...@obviousdigital.com

Hello,

My journey of learning PHP is going well, so i've decided to make a  
small program which works out the difference between two times and  
records the data in a text file.


I've searched the PHP manual for functions which can help me out,  
and I discovered the function Date_diff ( http://uk3.php.net/manual/en/function.date-diff.php 
 )and the class DateTime::diff ( http://uk3.php.net/manual/en/datetime.diff.php 
 )


My question is, how on earth do I use these functions ? I really  
don't understand the manual documentation.


I've just moved onto the subject of classes and so I'm fairly new to  
the concept, although I am following it well.


If someone could explain to me how to use ether of these ( Date_diff  
and DateTime::diff ) I would be VERY grateful.


Thank you so much!
Matt

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php






Matthew Croud
Studio

Obvious Print Solutions Limited
Unit 3 Abbeygate Court
Stockett Lane
Maidstone
Kent
ME15 0PP

T | 0845 094 9704
F | 0845 094 9705
www.obviousprint.com







Re: [PHP] difference between two times? Date_diff and DateTime::diff

2009-06-16 Thread Matthew Croud

Hi Dajve and Tom,

Thanks again, I totally didn't realise that this function is yet to be  
implemented in the mainstream PHP,


So is there no function that exists in vanilla PHP that can take two  
dates/times and supply the difference ?
If there isn't I do apologise, i've been talking to my friend who does  
ASP.net and he said he was sure there is for PHP.






On 16 Jun 2009, at 13:11, Dajve Green wrote:



Hi Matthew,

A quick note on the DateTime::diff() method - it's only available as  
from
PHP 5.3, which is currently in release candidate stage, meaning  
unless you
have your own server running PHP, it won't be available to use  
(hopefully -

I would be sceptical of any webhost which rolls out RCs on production
servers).

If you need to know what version of PHP you're running, use:
phpversion() or phpinfo()


-Original Message-
From: Matthew Croud [mailto:m...@obviousdigital.com]
Sent: 16 June 2009 12:42
To: Tom Chubb
Cc: PHP General list
Subject: Re: [PHP] difference between two times? Date_diff and
DateTime::diff

Hi Tom,

Thanks for the reply,  I believe I have a fair understanding of
functions, and I have followed the example on the PHP manual page (
http://uk3.php.net/manual/en/function.date-diff.php
 ), ideally I want to know how to use the class DateTime::diff, how
can I use the DateTime::diff to get the difference between two times/
dates ? I suppose then I'm after the syntax

would it be like this for example:
$DIfferenceInTime  = DateTime::diff(10:00,12:32);

Thanks again for helping me out.



On 16 Jun 2009, at 12:33, Tom Chubb wrote:


Matt,
Do you understand how to use functions?
A function is defined like this:

function () {
//code goes here
}

You can pass arguments to be used in a function like this:

function($arg1, $arg2) {
//code goes here
}

In the first example on the following page:

http://uk3.php.net/manual/en/function.date-diff.php

To call the function you need to provide two arguments: $dtTime1 
$dtTime2

To use in a script, you need to first define the function, as per
the example:

?php

function GetDeltaTime($dtTime1, $dtTime2)
{
 $nUXDate1 = strtotime($dtTime1-format(Y-m-d H:i:s));
 $nUXDate2 = strtotime($dtTime2-format(Y-m-d H:i:s));

 $nUXDelta = $nUXDate1 - $nUXDate2;
 $strDeltaTime =  . $nUXDelta/60/60; // sec - hour

 $nPos = strpos($strDeltaTime, .);
 if (nPos !== false)
   $strDeltaTime = substr($strDeltaTime, 0, $nPos + 3);

 return $strDeltaTime;
}

?

Then you need to call the function like this:

?php
GetDeltaTime(time1-goes-here, time2-goes-here)
?

And it should spit out the difference.

Code is untested and if you didn't follow that I suggest you read up
on functions: http://www.w3schools.com/php/php_functions.asp

Hope this helps - I'm probably in a similar situation to you and
have been dabbling with PHP for a few years just as a hobby but
thought I'd try and help out.
You'll learn a lot from reading this list as well.

Cheers and good luck,

Tom


2009/6/16 Matthew Croud m...@obviousdigital.com

Hello,

My journey of learning PHP is going well, so i've decided to make a
small program which works out the difference between two times and
records the data in a text file.

I've searched the PHP manual for functions which can help me out,
and I discovered the function Date_diff (

http://uk3.php.net/manual/en/function.date-diff.php

)and the class DateTime::diff (

http://uk3.php.net/manual/en/datetime.diff.php

)

My question is, how on earth do I use these functions ? I really
don't understand the manual documentation.

I've just moved onto the subject of classes and so I'm fairly new to
the concept, although I am following it well.

If someone could explain to me how to use ether of these ( Date_diff
and DateTime::diff ) I would be VERY grateful.

Thank you so much!
Matt

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php






Matthew Croud
Studio

Obvious Print Solutions Limited
Unit 3 Abbeygate Court
Stockett Lane
Maidstone
Kent
ME15 0PP

T | 0845 094 9704
F | 0845 094 9705
www.obviousprint.com








--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Matthew Croud
Studio

Obvious Print Solutions Limited
Unit 3 Abbeygate Court
Stockett Lane
Maidstone
Kent
ME15 0PP

T | 0845 094 9704
F | 0845 094 9705
www.obviousprint.com







Re: [PHP] difference between two times? Date_diff and DateTime::diff

2009-06-16 Thread Matthew Croud
Wonderful, thanks Ian for your function, and also thank you Tom for  
having a head scratch on my behalf ;)




On 16 Jun 2009, at 16:20, Ian wrote:


On 16 Jun 2009 at 14:05, Matthew Croud wrote:


Hi Dajve and Tom,

Thanks again, I totally didn't realise that this function is yet to  
be

implemented in the mainstream PHP,

So is there no function that exists in vanilla PHP that can take two
dates/times and supply the difference ?
If there isn't I do apologise, i've been talking to my friend who  
does

ASP.net and he said he was sure there is for PHP.


Hi,

This is a quick function that works using unix time stamps.  Its a  
bit quick and messy but
works ok.  Take a look at the manual page for the strtotime()  
function to get a better idea

of what it can handle.

?

$Date1_UnixTimeStamp=strtotime(10:10:45);
$Date2_UnixTimeStamp=strtotime(12:45:03);

print_r(DateDiff( $Date1_UnixTimeStamp, $Date2_UnixTimeStamp));

function DateDiff( $Date1_UnixTimeStamp, $Date2_UnixTimeStamp){

$return_difference  = Array(
Days=   0,
Hours   =   0,
Minutes =   0,
Seconds =   0
);

$amounts= Array(
Days=   60*60*24,
Hours   =   60*60,
Minutes =   60
);

$difference = $Date2_UnixTimeStamp - $Date1_UnixTimeStamp;

if($difference = $amounts[Days]){
$return_difference[Days] = floor($difference / 
$amounts[Days]);
$difference -=  $return_difference[Days] * $amounts[Days];
}

if($difference = $amounts[Hours]){
		$return_difference[Hours] = floor($difference /  
$amounts[Hours]);

$difference -=   $return_difference[Hours] * 
$amounts[Hours];
}
if($difference = $amounts[Minutes]){
		$return_difference[Minutes] = floor($difference /  
$amounts[Minutes]);

$difference -=  $return_difference[Minutes] * 
$amounts[Minutes];
}

$return_difference[Seconds] = $difference;

return $return_difference;
}

?

Regards

Ian
--




On 16 Jun 2009, at 13:11, Dajve Green wrote:



Hi Matthew,

A quick note on the DateTime::diff() method - it's only available as
from
PHP 5.3, which is currently in release candidate stage, meaning
unless you
have your own server running PHP, it won't be available to use
(hopefully -
I would be sceptical of any webhost which rolls out RCs on  
production

servers).

If you need to know what version of PHP you're running, use:
phpversion() or phpinfo()


-Original Message-
From: Matthew Croud [mailto:m...@obviousdigital.com]
Sent: 16 June 2009 12:42
To: Tom Chubb
Cc: PHP General list
Subject: Re: [PHP] difference between two times? Date_diff and
DateTime::diff

Hi Tom,

Thanks for the reply,  I believe I have a fair understanding of
functions, and I have followed the example on the PHP manual page (
http://uk3.php.net/manual/en/function.date-diff.php
), ideally I want to know how to use the class DateTime::diff, how
can I use the DateTime::diff to get the difference between two  
times/

dates ? I suppose then I'm after the syntax

would it be like this for example:
$DIfferenceInTime  = DateTime::diff(10:00,12:32);

Thanks again for helping me out.



On 16 Jun 2009, at 12:33, Tom Chubb wrote:


Matt,
Do you understand how to use functions?
A function is defined like this:

function () {
//code goes here
}

You can pass arguments to be used in a function like this:

function($arg1, $arg2) {
//code goes here
}

In the first example on the following page:

http://uk3.php.net/manual/en/function.date-diff.php

To call the function you need to provide two arguments: $dtTime1 
$dtTime2

To use in a script, you need to first define the function, as per
the example:

?php

function GetDeltaTime($dtTime1, $dtTime2)
{
$nUXDate1 = strtotime($dtTime1-format(Y-m-d H:i:s));
$nUXDate2 = strtotime($dtTime2-format(Y-m-d H:i:s));

$nUXDelta = $nUXDate1 - $nUXDate2;
$strDeltaTime =  . $nUXDelta/60/60; // sec - hour

$nPos = strpos($strDeltaTime, .);
if (nPos !== false)
  $strDeltaTime = substr($strDeltaTime, 0, $nPos + 3);

return $strDeltaTime;
}

?

Then you need to call the function like this:

?php
GetDeltaTime(time1-goes-here, time2-goes-here)
?

And it should spit out the difference.

Code is untested and if you didn't follow that I suggest you  
read up

on functions: http://www.w3schools.com/php/php_functions.asp

Hope this helps - I'm probably in a similar situation to you and
have been dabbling with PHP for a few years just as a hobby but
thought I'd try and help out.
You'll learn a lot from reading this list as well.

Cheers and good luck,

Tom


2009/6/16 Matthew Croud m...@obviousdigital.com

Hello,

My journey of learning PHP is going well, so i've decided to  
make a

small program which works out

[PHP] Question about template systems

2009-03-03 Thread Matthew Croud

Hello,

First post here, I'm in the process of learning PHP , I'm digesting a  
few books as we speak.
I'm working on a content heavy website that provides a lot of  
information, a template system would be great and so i've been looking  
at ways to create dynamic data with a static navigation system.


So far, using the require_once(); function seems to fit the bill in  
order to bring in the same header html file on each page.

I've also looked at Smartys template system.

I wondered how you folk would go about creating a template system ?

My second question might be me jumping the gun here, I haven't come  
across this part in my book but i'll ask about it anyway.  I often see  
websites that have a dynamic body and static header, and their web  
addresses end like this: index.php?id=445 where 445 i presume is  
some file reference.
What is this called ?  It seems like the system i'm after but it  
doesn't appear in my book,  If anyone could let me know what this page  
id subject is called i can do some research on the subject.


Thanks for any help you can provide :)

Matt.
 


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Question about template systems

2009-03-03 Thread Matthew Croud

Excellent, thanks for your help guys, you've been really helpful :)



On 3 Mar 2009, at 10:20, Marcus Gnaß wrote:


Matthew Croud wrote:

Hello,

First post here, I'm in the process of learning PHP , I'm digesting  
a few books as we speak.
I'm working on a content heavy website that provides a lot of  
information, a template system would be great and so i've been  
looking at ways to create dynamic data with a static navigation  
system.


So far, using the require_once(); function seems to fit the bill in  
order to bring in the same header html file on each page.

I've also looked at Smartys template system.

I wondered how you folk would go about creating a template system ?
Smarty is a good choice, although some people might prefer other  
templating systems. This is kind of a religious question like with  
programming questions in general. But I guess that most people would  
advise you to use an existing templating system instead of writing  
one on your own.
My second question might be me jumping the gun here, I haven't come  
across this part in my book but i'll ask about it anyway.  I often  
see websites that have a dynamic body and static header, and their  
web addresses end like this: index.php?id=445 where 445 i presume  
is some file reference.
What is this called ?  It seems like the system i'm after but it  
doesn't appear in my book,  If anyone could let me know what this  
page id subject is called i can do some research on the subject.

Have a look at the PHP manual and be sure to bookmark it! ;) 
http://www.php.net/manual/en/

The ID you mentioned is a query. id=445other_id=653 would be a  
querystring.
To retrieve data passed via this querystring you can use $_GET (http://de.php.net/manual/en/reserved.variables.get.php 
).



Have fun






--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php