php-general Digest 16 Oct 2011 21:32:41 -0000 Issue 7523
php-general Digest 16 Oct 2011 21:32:41 - Issue 7523 Topics (messages 315319 through 315327): starting php by asking basic questions 315319 by: saeed ahmed 315320 by: Lars Nielsen 315321 by: Govinda 315322 by: tamouse mailing lists Re: Seeking strategy/algorithm for maintaining order of records 315323 by: tamouse mailing lists 315324 by: Jim Giner 315325 by: Tedd Sperling 315326 by: Jim Giner 315327 by: Stephen Administrivia: To subscribe to the digest, e-mail: php-general-digest-subscr...@lists.php.net To unsubscribe from the digest, e-mail: php-general-digest-unsubscr...@lists.php.net To post to the list, e-mail: php-gene...@lists.php.net -- ---BeginMessage--- i want to learn php and i do not know much and my english is also limited.isthere anyone who can explain me php by most simple example,like explainig to a child,something like this:if you put this symbol or writing, in your php script,when someone open this page,will see this messagelong time not see . at the moment ,i am scared of terms used by professionals. thnks,for many this could a stupid but this is what i am facing. thanks. ---End Message--- ---BeginMessage--- søn, 16 10 2011 kl. 11:40 +0200, skrev saeed ahmed: i want to learn php and i do not know much and my english is also limited.isthere anyone who can explain me php by most simple example,like explainig to a child,something like this:if you put this symbol or writing, in your php script,when someone open this page,will see this messagelong time not see . at the moment ,i am scared of terms used by professionals. thnks,for many this could a stupid but this is what i am facing. thanks. You could start at http://php.net/manual/en/getting-started.php which gives a basic introduction to php-concepts. What is you preferred spoken language? Try to google for php basic tutorial or php getting started. Try somthing similar in you own language. Regards Lars www.lfweb.dk ---End Message--- ---BeginMessage--- i want to learn php and i do not know much and my english is also limited.isthere anyone who can explain me php by most simple example,like explainig to a child,something like this:if you put this symbol or writing, in your php script,when someone open this page,will see this messagelong time not see . at the moment ,i am scared of terms used by professionals. thnks,for many this could a stupid but this is what i am facing. thanks. saeed PHP is so widely used that by now there are tutorials that speak to every level of understanding and in so many possible tones, in many languages too. When you ask someone to explain PHP to you, in english anyway, that is too broad a request to get much specific help. You are just going to have start at the beginning and learn the basics first. Try to find a tutorial that teaches the basics, as Lars said. I am just adding here encouragement because when I looked for them, then I have found what I think you want - really gentle PHP tutorials that make it so easy to digest and learn from. If you still felt overwhelmed, then perhaps another approach that might work for you is to somehow serve/give to someone who would take you on as a personal student, and teach you, step by step. You can get that kind of help here, but to solicit that, you have to *break your requests down to very small and specific things* that you want to know. No one can answer explain PHP to you in less than consecutive days/weeks/months. Here is my starter tutorial for you, based on what you asked: PHP is software that runs on a server computer. When someone goes to a webpage then their browser (like Internet Explorer, of Firefox, etc.) effectively asks the server to hand over a webpage to the browser. But if the designer of that webpage used PHP to build the webpage, then before the server hands over the webpage to the browser, it first sends the page to the PHP software. PHP looks in the code of the page for things it is supposed to do. There are so so many things you can make PHP do with the PHP code you (as the designer) write and put in the webpage. One thing you will do often is use PHP code to make values appear in the page that are dynamic, meaning things that change, depending on variables. Like maybe you want to show the date to the end user (the browser). Well you can't just put the date in your webpage with only text/HTML, because then you would have to change the webpage code every day for it to be accurate. And even then that would not work because depending on the time zone of the user it might already be a different day. So you just use one of the many many hundreds of PHP constructs (bits/lines of PHP code that you can write) which will give the date. Like this in the webpage code:
Re: [PHP] Extending an instantiated class
On Sat, Oct 15, 2011 at 7:01 AM, Alain Williams a...@phcomp.co.uk wrote: I have an application where a Screen (web page) may contain several Forms. The Forms will want to access properties, etc, from their Screen. So what I want is to do something like: You're using an is-a relationship between Form and Screen, but I think has-a would be better since a Screen has one or more Forms. Keep the $screen property in Form, but break the inheritance relationship. Define methods in Form to allow you to set properties on its containing Screen. class Form { private $screen; public function __construct(Screen $screen) { $this-screen = $screen; } public function AddJsVar($name, $value) { $this-screen-AddJsVar($name, $value); } public function GetJsVar($name) { return $this-screen-GetJsVar($name); } } Now adding a var to a Form passes it on to its owning Screen. It's also a lot simpler than using reflection. Peace, David
[PHP] starting php by asking basic questions
i want to learn php and i do not know much and my english is also limited.isthere anyone who can explain me php by most simple example,like explainig to a child,something like this:if you put this symbol or writing, in your php script,when someone open this page,will see this messagelong time not see . at the moment ,i am scared of terms used by professionals. thnks,for many this could a stupid but this is what i am facing. thanks.
Re: [PHP] starting php by asking basic questions
søn, 16 10 2011 kl. 11:40 +0200, skrev saeed ahmed: i want to learn php and i do not know much and my english is also limited.isthere anyone who can explain me php by most simple example,like explainig to a child,something like this:if you put this symbol or writing, in your php script,when someone open this page,will see this messagelong time not see . at the moment ,i am scared of terms used by professionals. thnks,for many this could a stupid but this is what i am facing. thanks. You could start at http://php.net/manual/en/getting-started.php which gives a basic introduction to php-concepts. What is you preferred spoken language? Try to google for php basic tutorial or php getting started. Try somthing similar in you own language. Regards Lars www.lfweb.dk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] starting php by asking basic questions
i want to learn php and i do not know much and my english is also limited.isthere anyone who can explain me php by most simple example,like explainig to a child,something like this:if you put this symbol or writing, in your php script,when someone open this page,will see this messagelong time not see . at the moment ,i am scared of terms used by professionals. thnks,for many this could a stupid but this is what i am facing. thanks. saeed PHP is so widely used that by now there are tutorials that speak to every level of understanding and in so many possible tones, in many languages too. When you ask someone to explain PHP to you, in english anyway, that is too broad a request to get much specific help. You are just going to have start at the beginning and learn the basics first. Try to find a tutorial that teaches the basics, as Lars said. I am just adding here encouragement because when I looked for them, then I have found what I think you want - really gentle PHP tutorials that make it so easy to digest and learn from. If you still felt overwhelmed, then perhaps another approach that might work for you is to somehow serve/give to someone who would take you on as a personal student, and teach you, step by step. You can get that kind of help here, but to solicit that, you have to *break your requests down to very small and specific things* that you want to know. No one can answer explain PHP to you in less than consecutive days/weeks/months. Here is my starter tutorial for you, based on what you asked: PHP is software that runs on a server computer. When someone goes to a webpage then their browser (like Internet Explorer, of Firefox, etc.) effectively asks the server to hand over a webpage to the browser. But if the designer of that webpage used PHP to build the webpage, then before the server hands over the webpage to the browser, it first sends the page to the PHP software. PHP looks in the code of the page for things it is supposed to do. There are so so many things you can make PHP do with the PHP code you (as the designer) write and put in the webpage. One thing you will do often is use PHP code to make values appear in the page that are dynamic, meaning things that change, depending on variables. Like maybe you want to show the date to the end user (the browser). Well you can't just put the date in your webpage with only text/HTML, because then you would have to change the webpage code every day for it to be accurate. And even then that would not work because depending on the time zone of the user it might already be a different day. So you just use one of the many many hundreds of PHP constructs (bits/lines of PHP code that you can write) which will give the date. Like this in the webpage code: date_default_timezone_set('America/New_York'); echo date('r'); ...will output this on the page in the browser: Sun, 16 Oct 2011 11:28:31 -0400 Good luck, -Govinda -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] starting php by asking basic questions
On Sun, Oct 16, 2011 at 10:34 AM, Govinda govinda.webdnat...@gmail.com wrote: i want to learn php and i do not know much and my english is also limited.isthere anyone who can explain me php by most simple example,like explainig to a child,something like this:if you put this symbol or writing, in your php script,when someone open this page,will see this messagelong time not see . at the moment ,i am scared of terms used by professionals. thnks,for many this could a stupid but this is what i am facing. thanks. First of all, php is a programming language. If you are not familiar with any sort of programming, don't despair, php is pretty easy to use. However, I would strongly recommend getting some basic books on programming and software development so you don't go off the rails (npi). For a quick start though, you could do a lot worse than the webmonkey intro tutorial: http://www.webmonkey.com/2010/02/php_tutorial_for_beginners/ that was updated last year. Also, lifehacker ran a series of articles on beginning programming which you may find helpful: http://lifehacker.com/5401954/programmer-101-teach-yourself-how-to-code This mailing list is not set up to teach people how to program in php. It is pretty much expected that you already know the basics and then we are here when you've exhausted your manuals, books, web sites, etc. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Seeking strategy/algorithm for maintaining order of records
In Sat, Oct 15, 2011 at 7:57 PM, Stephen stephe...@rogers.com wrote: I am building a site for my photography. Cool! The photographs are displayed by category. The category table has a field for order In my control panel I want to be able to change the order of the categories by changing the values in the category field. I can dynamically build a form of all categories and have a field for new order number, Then loop through the POST and update the values. The field is not unique, so I am not worried about DB errors. But I wonder if there is a better way. Thoughts please? I'm not 100% sure I understand what you're trying to do here, but it seems like a custom sort based on the list of categories is the order of the day? What is sounds like you're attempting to do is what is similar to the netflix queue ordering, if you're famliar with that -- basically something like this in your form page for each category: label for=category_oneCategory One/label input type=text name=category_one value=(current sort order for category one) id=category_one / Then the user sets the category sort order by via the input boxes. That seems pretty straight forward. The advanced class will do this with drag-and-drop interactive widget. The hairy part come when you snag the photo info from the database getting the ordering right there. I don't know if there's a way to do that in a single query or not, I'm guessing resorting to a stored procedure may be your best bet here, perhaps with generating a temporary table on the fly. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Seeking strategy/algorithm for maintaining order of records
tamouse mailing lists tamouse.li...@gmail.com wrote in message news:cahuc_t8icx4y4mca05rrgzopv4ze7hwsndaiyjjmdvbambv...@mail.gmail.com... In Sat, Oct 15, 2011 at 7:57 PM, Stephen stephe...@rogers.com wrote: \label for=category_oneCategory One/label input type=text name=category_one value=(current sort order for category one) id=category_one / I would capture the input fields by using an array name (category[]) instead of specific names (ie, category_one. That way you don't have to modify your input procesing if/when you add a new category. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Seeking strategy/algorithm for maintaining order of records
On Oct 15, 2011, at 8:57 PM, Stephen wrote: I am building a site for my photography. The photographs are displayed by category. The category table has a field for order In my control panel I want to be able to change the order of the categories by changing the values in the category field. I can dynamically build a form of all categories and have a field for new order number, Then loop through the POST and update the values. The field is not unique, so I am not worried about DB errors. But I wonder if there is a better way. Thoughts please? Thank you Stephen Stephen: What you describe is a multistep problem. There are many ways to show pictures (images) in any order you want. I commonly store images in a database with their associated data, such as id, image name, size, type, category, and other such data. Then when I want to display any image(s), I simply pull the images from the database in the order and/or category as I want them displayed. If I want to sort them in some fashion, I can use any field by using a MySQL query string, such as SELECT * FROM image_db WHERE what=whatfield ASC ORDER BY whatever. From there it's a simple process to display the data obtained from the database by using a pagination scheme of some type, like this: http://php1.net/b/pagination-images/ or this: http://webbytedd.com/bbb/paging/ In some instances, I even have a content management system where I can set the order of the pictures I want to appear in what order by assigning them a sort order number/category. For example, if I have 20 pictures (numbers 1-20) each having a sort number, they will be shown in that order. If I want to change the order of the presentation, such as insert image 16 into position 3, I simply change the order number of picture 16 to 2.5 and resort the categories on integer. Bingo, the images are resorted as I want. There are many ways to do this -- you just need to define what you specifically want to do and break it down into manageable parts. Cheers, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Seeking strategy/algorithm for maintaining order of records
Tedd Sperling tedd.sperl...@gmail.com wrote in message news:4c4ff11f-24ea-48cc-a367-48803df58...@gmail.com... Stephen: What you describe is a multistep problem. There are many ways to show pictures (images) in any order you want. * So far, the OP has only asked how to keep his categories in order. Curious, yes, but he hasn't even asked how to display the images in order - maybe he doesn't care about that.. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Seeking strategy/algorithm for maintaining order of records
On 11-10-16 04:10 PM, Jim Giner wrote: Stephen: What you describe is a multistep problem. There are many ways to show pictures (images) in any order you want. * So far, the OP has only asked how to keep his categories in order. Curious, yes, but he hasn't even asked how to display the images in order - maybe he doesn't care about that.. Well, I want to deal with one part of the design at a time :) Thanks to all who replied. This is a collective response. Displaying in an order is easy when you have a field called order. SELECT descriptions FROM categories ORDER by order; My issue is, say I have three records: ID CategoryOrder 1BW1 2Landscapes 2 3Nudes 3 I am looking for the best way to be able to change the values to ID CategoryOrder 1BW3 2Landscapes 2 3Nudes 1 Dynamically building a form, entering the new order value, and then looping through the post, with a SQL UPDATE is the best I can come up with. A future issue will be doing the same to the table category-photograph ID Category_id photo_id order This table is needed to allow a photograph to be in more than one category. Cheers Stephen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Seeking strategy/algorithm for maintaining order of records
On Sun, 2011-10-16 at 17:32 -0400, Stephen wrote: On 11-10-16 04:10 PM, Jim Giner wrote: Stephen: What you describe is a multistep problem. There are many ways to show pictures (images) in any order you want. * So far, the OP has only asked how to keep his categories in order. Curious, yes, but he hasn't even asked how to display the images in order - maybe he doesn't care about that.. Well, I want to deal with one part of the design at a time :) Thanks to all who replied. This is a collective response. Displaying in an order is easy when you have a field called order. SELECT descriptions FROM categories ORDER by order; My issue is, say I have three records: ID CategoryOrder 1BW1 2Landscapes 2 3Nudes 3 I am looking for the best way to be able to change the values to ID CategoryOrder 1BW3 2Landscapes 2 3Nudes 1 Dynamically building a form, entering the new order value, and then looping through the post, with a SQL UPDATE is the best I can come up with. A future issue will be doing the same to the table category-photograph ID Category_id photo_id order This table is needed to allow a photograph to be in more than one category. Cheers Stephen It depends on how you're presenting the ordering to the end user. I've used different methods depending on the requirements of the CMS. a) You swap over the order of two items in a list (which could be applicable in your example but the dataset is too small to say) b) You move an item up or down within the list, then you use some queries (take care because multiple queries won't guarantee freedom of DB collisions) to increment or decrement the order of all the items to either side of the item you move up or down, then finally you increment/decrement that individual item. c) Lastly you could allow for a free-form entry for the order field, and allow for multiple items to share the same order. A cleanup routine could then arrange them properly during quiet periods for example if you're worried about order field collision. With any of these methods I'd swing for using transactions if you can, because you're going to be performing multiple queries and the system may be used by other people at the same time. -- Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] Image Rotation Script
There are tons of (free) jquery gadgets that do image rotation. All you'd need to do is push the list out to the jquery script. Cheers, Curtis On 10/15/2011 10:50 AM, d...@nkmo.com wrote: We have a simple script which rotates and image to a random value, saves it to a cache directory and displays it. For some reason when I move the script from a Debian box over to the production CentOS machine, it no longer caches any of the images. the rest works, but not the cache. If you could look at it and see if anything jumps out at you, please let me know. install the code below to the directory /angles .htaccess: RewriteEngine on RewriteRule ^rotate_(\d+)(?:_(?:\d+))?.png$ rotate.php?im=$1 rotate.php: ?php // Setup if(isset($_GET['im']) file_exists($_GET['im'].'.png')) { header('Content-type: image/png'); $im = $_GET['im'].'.png'; $degrees = rand(0, 360); $save = 'cache/'.$_GET['im'].'_'.$degrees.'.png'; if(!file_exists($save)) { // Rotate via command line and cache it exec('convert '.$im.' -filter \'Lanczos\' -resize \'150x150\' -rotate '.$degrees.' -black-threshold 40% '.$save, $out); } // Output out (newly?) cached file echo file_get_contents($save); } else { die(Image not found); } ? Use it by url: http://www.servername.com/angles/rotate_019.png Each time you reload page the angle should rotate to a new position.