To display or order the HTML elements with

I of the small functions or very simple PHP scripts which have some under the boot. Using two tables we will choose mark out to be displayed in our Web page and which order in order to amend the structure of our document without touching with the HTML code. With this intention, it will be enough to fill the G-string which goes well in .

in (yes, yes, I know… )

All starts with the statement of both . Could these boards be in a distinct file to include with <? “”? >:

  • - contains the elements () to display,
  • - makes it possible to order the elements in question.

    <? 
         =  (
            “”,
            “content”
        );
= ( “0 ' =>' ”, “1 ' =>' content” ); ? >

A loop and some yew.

  1. A loop includes the whole of the document to increment the variable according to the number of elements contained in table ,

  2. We check for each element concerned:

    • its presence and its sequence number in table ,
    • its presence in table .
      <?  
       (;  ; ) { 
      ? >
      <? yew ( [] ==' && (“”, )) { ? > " " > of the <? }? >
      <? yew ( [] ==' && (“content”, )) { ? > " content " > of the <? }? > <? } ? >

To display an element, put it in table . To amend the command of display of the elements (to place after , for example), change the command of the elements in table .

Stay tuned and mind the gap!

: , ,
Published on October 27th, 2008 by Bruno .


Ca can interest you”


7 participations in the item

  1.  
    1 spoke on October 27th, 2008 with 23:27 |
     

    error: error, `=', `)' in one 8

    Attention with the associative : instead of “`0 ′ =' ',” one writes “`0 ′ =>' ',”

    One will put that on the back of the editor ; D

  2.  
    2 Bruno spoke on October 28th, 2008 with 00:03 |
     

    @Darklg:

    One will put that on the back of the editor ; D

    , it is not the fault with … I have right pitch paid attention by transforming the opening and closing herringbones. It is repaired! Thank you for your vigilance;)

  3.  
    3 spoke on October 28th, 2008 with 00:39 |
     

    (Another register: your isn't hour of winter per? )

  4. 4 spoke on October 28th, 2008 with 09:38 |
     

    , the idea is interesting. How is it done in to change the command of the various elements in the side columns?

  5. 5 spoke on November 6th, 2008 with 09:41 |
     

    The under the condition of for it is too not, it revalues the size of the board to each loop.

    Something like ( = 0, = ; <= , ) it is already better (to be checked that functions, that made an eternity which I did not do of ).

    And I will find a prettier with reading, but that does not change anything; -).

  6. 6 spoke on December 11th, 2008 with 16:33 |
     

    Some remarks and corrections of code:

    • If you guards the “”, you loop once too. It is thus necessary to remove it “=” before the :

    ( = 0; < ; ) {

    • Like known as by , to put the function directly in comparison is optimized less for the referred to reason (see its correction).

    • Your is useless and of the blow obliges you to duplicate contents. You can abolish it and use in your .

    • To use an instruction “” to traverse a board is obsolete, it would be necessary to prefer to use the . The final code could thus resemble that:

      = (“0” => “”, “1” => “content”,); // Sorts the board according to the keys, // the following loop will then display them in the order ; ( ace ) { (. “”); }

    There would be thus an HTML page for each “”, and on behalf of this “”. Several advantages with that:

    • One avoids unnecessarily duplicating the names of the “” (in two boards, comparisons, , etc);
    • One separates a minimum the PHP code from the HTML code => easier Maintenance.
  7.  
    7 Bruno spoke on December 13rd, 2008 with 13:26 |
     

    @Josselin: Thank you ' for all these precise details and these examples. Well considering, the blow of the : very subtle;)

    Fortunately that all the readers are not like @Neovov: who all alone criticizes and keeps his examples for him: D (not to type, not type).

Take part in the item

Your email never will not be published or will be revealed.

Enrich your comment with syntax.

To follow the comments of this bank note by RSS?