Jump to content
php.lv forumi

jb4

Reģistrētie lietotāji
  • Posts

    212
  • Joined

  • Last visited

Everything posted by jb4

  1. Vakarnakt uzrakstīju Windows mīļiem PHP, MySQL un Apaches uzstādīšanas "instrukciju": http://www.42901.lv/news.php?c=28 Nav nedz vienīgais, nedz labākais variants - vienkārši stāsts kā tas man veiksmīgi izdevās.
  2. jb4

    Table Vs. Css?

    <code><font color="#000000"> <html> <head> <style type="text/css"> div { /* Starpiņas, lai tu redzētu robežas starp DIViem */ margin: 0.5%; } div#augsha { position: relative; width: 99%; height: 120px; /* Lai tu vizuāli redzētu: */ background-color: #CCCCCC; } div#navigleft { position: relative; float: left; clear: both; width: 17%; /* Lai tu vizuāli redzētu: */ background-color: #CCCCCC; } div#center { position: relative; float: left; width: 50%; /* Lai tu vizuāli redzētu: */ background-color: #CCCCCC; } div#right { position: relative; float: left; width: 28%; /* Lai tu vizuāli redzētu: */ background-color: #CCCCCC; } div#bottom { position: relative; clear: both; width: 99%; /* Lai tu vizuāli redzētu: */ background-color: #CCCCCC; } </style> </head> <body> <div id="augsha">Augša</div> <div id="navigleft">Kreisais</div> <div id="center">Vidus</div> <div id="right">Labais</div> <div id="bottom">Apakša</div> </body> </html></font> </code> Maisīt relatīvos platumus (%) ar absolūtajiem (px) nav pārāk laba doma. Ja tu šo visu regulē ar (px), tad rēķinies, ka ievērojamai daļai lietotāju max platums (visi paddingi, margini + width) ir 800px. Ja tu šo visu regulē ar (%), tad saproti, ka tādu kopā ir tikai 100, bet pārlūki % mīl ne pārāk, tāpēc es parasti izlīdzos ar 97-99.5% lai nesanāktu šmuce. Ja tu tomēr apvieno (%) ar (px) tad rēķini pats - tā lai šīs kombinācijas pie 800px pa horizontu neizskatītos kā caur iluminatoru un pa >1024px pārāk plati un nebaudāmi.
  3. jb4

    Table Vs. Css?

    Pakaļas slimība no CSS? Pirmā dzirdēšana. Strādāju ar IE un NN un vienīgā problēma ir līka mugura. Nu varbūt šad tad notirpst kājas, bet pakaļa? Droši vien kaut kāds kreiss internet pārlūks.
  4. jb4

    Table Vs. Css?

    Ko nozīmē gemo... ?
  5. jb4

    Table Vs. Css?

    Ieejam Google.lv un rakstām: "arguments against tables layout css" Spiežam I'm feeling lucky un nonākam: http://www.saila.com/usage/layouts/cssvtables.shtml
  6. jb4

    Checking Ip

    Iz PHP manuāļa komentāriem: <code><font color="#000000"> <font color="#0000CC"><? </font><font color="#006600">if (</font><font color="#0000CC">[url=http://lv.php.net/getenv]getenv[/url]</font><font color="#006600">(</font><font color="#CC0000">'HTTP_X_FORWARDED_FOR'</font><font color="#006600">)) { </font><font color="#0000CC">$ip </font><font color="#006600">= </font><font color="#0000CC">[url=http://lv.php.net/getenv]getenv[/url]</font><font color="#006600">(</font><font color="#CC0000">'HTTP_X_FORWARD_FOR'</font><font color="#006600">); </font><font color="#0000CC">$host </font><font color="#006600">= </font><font color="#0000CC">[url=http://lv.php.net/gethostbyaddr]gethostbyaddr[/url]</font><font color="#006600">(</font><font color="#0000CC">$ip</font><font color="#006600">); } else { </font><font color="#0000CC">$ip </font><font color="#006600">= </font><font color="#0000CC">[url=http://lv.php.net/getenv]getenv[/url]</font><font color="#006600">(</font><font color="#CC0000">'REMOTE_ADDR'</font><font color="#006600">); </font><font color="#0000CC">$host </font><font color="#006600">= </font><font color="#0000CC">[url=http://lv.php.net/gethostbyaddr]gethostbyaddr[/url]</font><font color="#006600">(</font><font color="#0000CC">$ip</font><font color="#006600">); } </font><font color="#0000CC">?></font> </font> </code>
  7. jb4

    Vispār Kopā.

    Kāpēc jādrukā tas <? xml ... ???? Ja jau esat aizdomājušies līdz XML, tad pēdējais laiks iebraukt šablonos. Defaultais HTML liekams šablonfailā. Šablonu apstrādātājs meklē īpašās vietas un tās aizvieto ar vajadzīgo. Teiksim ar {{CHARSET}} apzīmē vietu, kur jāievieto lapas charsets un notiek tas viss ir nasko str_replace(). Mana šablonu klase (vislabākā pasaulē atrodamā): <code><font color="#000000"> <font color="#0000CC"><? </font><font color="#006600">class </font><font color="#0000CC">MyShape </font><font color="#006600">{ var </font><font color="#0000CC">$ROOT </font><font color="#006600">= </font><font color="#CC0000">""</font><font color="#006600">; var </font><font color="#0000CC">$SHAPENAMES </font><font color="#006600">= array(); var </font><font color="#0000CC">$SHAPES </font><font color="#006600">= array(); function </font><font color="#0000CC">MyShape</font><font color="#006600">(</font><font color="#0000CC">$path_to_root</font><font color="#006600">=</font><font color="#CC0000">''</font><font color="#006600">) { </font><font color="#0000CC">$this</font><font color="#006600">-></font><font color="#0000CC">ROOT </font><font color="#006600">= </font><font color="#0000CC">$path_to_root</font><font color="#006600">; } function </font><font color="#0000CC">get_shape</font><font color="#006600">(</font><font color="#0000CC">$shape</font><font color="#006600">) { if (isset(</font><font color="#0000CC">$this</font><font color="#006600">-></font><font color="#0000CC">SHAPES</font><font color="#006600">[</font><font color="#0000CC">$shape</font><font color="#006600">])) { return </font><font color="#0000CC">$this</font><font color="#006600">-></font><font color="#0000CC">SHAPES</font><font color="#006600">[</font><font color="#0000CC">$shape</font><font color="#006600">]; } else { return(</font><font color="#0000CC">[url=http://lv.php.net/implode]implode[/url]</font><font color="#006600">(</font><font color="#0000CC">[url=http://lv.php.net/file]file[/url]</font><font color="#006600">(</font><font color="#0000CC">$this</font><font color="#006600">-></font><font color="#0000CC">ROOT </font><font color="#006600">. </font><font color="#0000CC">$this</font><font color="#006600">-></font><font color="#0000CC">SHAPENAMES</font><font color="#006600">[</font><font color="#0000CC">$shape</font><font color="#006600">]),</font><font color="#CC0000">""</font><font color="#006600">)); } } function </font><font color="#0000CC">new_shape</font><font color="#006600">(</font><font color="#0000CC">$shape_attributes </font><font color="#006600">= array()) { while (list(</font><font color="#0000CC">$shapename</font><font color="#006600">,</font><font color="#0000CC">$shapesource</font><font color="#006600">) = </font><font color="#0000CC">[url=http://lv.php.net/each]each[/url]</font><font color="#006600">(</font><font color="#0000CC">$shape_attributes</font><font color="#006600">)) { </font><font color="#0000CC">$this</font><font color="#006600">-></font><font color="#0000CC">SHAPENAMES</font><font color="#006600">[</font><font color="#0000CC">$shapename</font><font color="#006600">] = </font><font color="#0000CC">$shapesource</font><font color="#006600">; } } function </font><font color="#0000CC">insert_values</font><font color="#006600">(</font><font color="#0000CC">$shapename</font><font color="#006600">,</font><font color="#0000CC">$fields_and_values</font><font color="#006600">) { </font><font color="#0000CC">$shape </font><font color="#006600">= </font><font color="#0000CC">$this</font><font color="#006600">-></font><font color="#0000CC">get_shape</font><font color="#006600">(</font><font color="#0000CC">$shapename</font><font color="#006600">); while(list(</font><font color="#0000CC">$field_name</font><font color="#006600">,</font><font color="#0000CC">$field_value</font><font color="#006600">) = </font><font color="#0000CC">[url=http://lv.php.net/each]each[/url]</font><font color="#006600">(</font><font color="#0000CC">$fields_and_values</font><font color="#006600">)) { </font><font color="#0000CC">$shape </font><font color="#006600">= </font><font color="#0000CC">[url=http://lv.php.net/str_replace]str_replace[/url]</font><font color="#006600">(</font><font color="#CC0000">"{"</font><font color="#006600">.</font><font color="#0000CC">[url=http://lv.php.net/strtoupper]strtoupper[/url]</font><font color="#006600">(</font><font color="#0000CC">$field_name</font><font color="#006600">).</font><font color="#CC0000">"}"</font><font color="#006600">,</font><font color="#0000CC">$field_value</font><font color="#006600">,</font><font color="#0000CC">$shape</font><font color="#006600">); } </font><font color="#0000CC">$this</font><font color="#006600">-></font><font color="#0000CC">SHAPES</font><font color="#006600">[</font><font color="#0000CC">$shapename</font><font color="#006600">] = </font><font color="#0000CC">$shape</font><font color="#006600">; } function </font><font color="#0000CC">make_list</font><font color="#006600">(</font><font color="#0000CC">$childname</font><font color="#006600">,</font><font color="#0000CC">$data</font><font color="#006600">) { </font><font color="#0000CC">$mothershape </font><font color="#006600">= </font><font color="#CC0000">""</font><font color="#006600">; foreach (</font><font color="#0000CC">$data </font><font color="#006600">as </font><font color="#0000CC">$record</font><font color="#006600">) { </font><font color="#0000CC">$temp_shape </font><font color="#006600">= </font><font color="#0000CC">$this</font><font color="#006600">-></font><font color="#0000CC">get_shape</font><font color="#006600">(</font><font color="#0000CC">$childname</font><font color="#006600">); while(list(</font><font color="#0000CC">$field_name</font><font color="#006600">,</font><font color="#0000CC">$field_value</font><font color="#006600">) = </font><font color="#0000CC">[url=http://lv.php.net/each]each[/url]</font><font color="#006600">(</font><font color="#0000CC">$record</font><font color="#006600">)) { </font><font color="#0000CC">$temp_shape </font><font color="#006600">= </font><font color="#0000CC">[url=http://lv.php.net/str_replace]str_replace[/url]</font><font color="#006600">(</font><font color="#CC0000">"{"</font><font color="#006600">.</font><font color="#0000CC">[url=http://lv.php.net/strtoupper]strtoupper[/url]</font><font color="#006600">(</font><font color="#0000CC">$field_name</font><font color="#006600">).</font><font color="#CC0000">"}"</font><font color="#006600">,</font><font color="#0000CC">$field_value</font><font color="#006600">,</font><font color="#0000CC">$temp_shape</font><font color="#006600">); } </font><font color="#0000CC">$mothershape </font><font color="#006600">.= </font><font color="#0000CC">$temp_shape</font><font color="#006600">; } return </font><font color="#0000CC">$mothershape</font><font color="#006600">; } function </font><font color="#0000CC">make_simple_list</font><font color="#006600">(</font><font color="#0000CC">$childname</font><font color="#006600">,</font><font color="#0000CC">$data</font><font color="#006600">,</font><font color="#0000CC">$indicator</font><font color="#006600">) { </font><font color="#0000CC">$mothershape </font><font color="#006600">= </font><font color="#CC0000">""</font><font color="#006600">; foreach (</font><font color="#0000CC">$data </font><font color="#006600">as </font><font color="#0000CC">$record</font><font color="#006600">) { </font><font color="#0000CC">$temp_shape </font><font color="#006600">= </font><font color="#0000CC">$this</font><font color="#006600">-></font><font color="#0000CC">get_shape</font><font color="#006600">(</font><font color="#0000CC">$childname</font><font color="#006600">); </font><font color="#0000CC">$temp_shape </font><font color="#006600">= </font><font color="#0000CC">[url=http://lv.php.net/str_replace]str_replace[/url]</font><font color="#006600">(</font><font color="#CC0000">"{"</font><font color="#006600">.</font><font color="#0000CC">[url=http://lv.php.net/strtoupper]strtoupper[/url]</font><font color="#006600">(</font><font color="#0000CC">$indicator</font><font color="#006600">).</font><font color="#CC0000">"}"</font><font color="#006600">,</font><font color="#0000CC">$record</font><font color="#006600">,</font><font color="#0000CC">$temp_shape</font><font color="#006600">); </font><font color="#0000CC">$mothershape </font><font color="#006600">.= </font><font color="#0000CC">$temp_shape</font><font color="#006600">; } return </font><font color="#0000CC">$mothershape</font><font color="#006600">; } function </font><font color="#0000CC">end_parse</font><font color="#006600">(</font><font color="#0000CC">$shapename</font><font color="#006600">) { </font><font color="#0000CC">$this</font><font color="#006600">-></font><font color="#0000CC">SHAPES</font><font color="#006600">[</font><font color="#0000CC">$shapename</font><font color="#006600">] = </font><font color="#0000CC">[url=http://lv.php.net/ereg_replace]ereg_replace[/url]</font><font color="#006600">(</font><font color="#CC0000">"{[A-Z_]+}"</font><font color="#006600">,</font><font color="#CC0000">""</font><font color="#006600">,</font><font color="#0000CC">$this</font><font color="#006600">-></font><font color="#0000CC">get_shape</font><font color="#006600">(</font><font color="#0000CC">$shapename</font><font color="#006600">)); } function </font><font color="#0000CC">print_shape</font><font color="#006600">(</font><font color="#0000CC">$name</font><font color="#006600">) { if (isset(</font><font color="#0000CC">$this</font><font color="#006600">-></font><font color="#0000CC">SHAPES</font><font color="#006600">[</font><font color="#0000CC">$name</font><font color="#006600">])) { echo </font><font color="#0000CC">$this</font><font color="#006600">-></font><font color="#0000CC">SHAPES</font><font color="#006600">[</font><font color="#0000CC">$name</font><font color="#006600">]; } } </font><font color="#0000CC">?> </font>}</font> </code> Šeit apskatāms šablonfaili: Pirmais: pamats.tpl <code><font color="#000000"> <html> <head> <title>{LAPAS_VIRSRAKSTS}</title> </head> <body> {LAPAS_VIRSRAKSTS} {SATURS} </body> </html></font> </code> Otrais (viena raksta šablons): raksts.tpl <code><font color="#000000"> <div style="padding: 10px; font-size: 90%;"> <b>{VIRSRAKSTS}</b><br /> {TEKSTS} </div></font> </code> Un tagad šablonu izmantošana sekojoša rakstu masīva parādīšanai: ($raksti definīcijas vietā varēja būt mysql_get_assoc() no atlasītiem MySQL rezultātiem) <code><font color="#000000"> <font color="#0000CC"><? $raksti</font><font color="#006600">=array( array(</font><font color="#CC0000">'virsraksts'</font><font color="#006600">=></font><font color="#CC0000">'Ekonomiskā krīze Valmierā'</font><font color="#006600">, </font><font color="#CC0000">'teksts'</font><font color="#006600">=></font><font color="#CC0000">'Šodien Valmierā cenas stāvus gaisā'</font><font color="#006600">), array(</font><font color="#CC0000">'virsraksts'</font><font color="#006600">=></font><font color="#CC0000">'Apsveicam!'</font><font color="#006600">, </font><font color="#CC0000">'teksts'</font><font color="#006600">=></font><font color="#CC0000">'Apsveicam Pēteri Rūjienā deviņdesmitajos šūpuļsvētkos!'</font><font color="#006600">), array(</font><font color="#CC0000">'virsraksts'</font><font color="#006600">=></font><font color="#CC0000">'Pāvilostā dzelzceļnieku streiks'</font><font color="#006600">, </font><font color="#CC0000">'teksts'</font><font color="#006600">=></font><font color="#CC0000">'Pāvilostas dzelzceļnieku arodbiedrība pieteikusi streiku' </font><font color="#006600">)); require_once(</font><font color="#CC0000">'myshape.class.php'</font><font color="#006600">); </font><font color="#0000CC">$lapa </font><font color="#006600">= new </font><font color="#0000CC">MyShape</font><font color="#006600">(</font><font color="#CC0000">'home/www/sabloni/'</font><font color="#006600">); </font><font color="#0000CC">$lapa</font><font color="#006600">-></font><font color="#0000CC">new_shape</font><font color="#006600">(array( </font><font color="#CC0000">'pamatsablons'</font><font color="#006600">=></font><font color="#CC0000">'pamats.tpl'</font><font color="#006600">, </font><font color="#CC0000">'viena_raksta_sablons'</font><font color="#006600">=></font><font color="#CC0000">'raksts.tpl' </font><font color="#006600">)); </font><font color="#0000CC">$lapa</font><font color="#006600">-></font><font color="#0000CC">insert_values</font><font color="#006600">(</font><font color="#CC0000">'pamatsablons'</font><font color="#006600">,array( </font><font color="#CC0000">'lapas_virsraksts'</font><font color="#006600">=></font><font color="#CC0000">'Novadu ziņas'</font><font color="#006600">, </font><font color="#CC0000">'saturs'</font><font color="#006600">=></font><font color="#0000CC">$lapa</font><font color="#006600">-></font><font color="#0000CC">make_list</font><font color="#006600">(</font><font color="#CC0000">'viena_raksta_sablons'</font><font color="#006600">,</font><font color="#0000CC">$raksti</font><font color="#006600">) )); </font><font color="#0000CC">$lapa</font><font color="#006600">-></font><font color="#0000CC">end_parse</font><font color="#006600">(</font><font color="#CC0000">'pamatsablons'</font><font color="#006600">); echo </font><font color="#0000CC">$lapa</font><font color="#006600">-></font><font color="#0000CC">get_shape</font><font color="#006600">(</font><font color="#CC0000">'pamatsablons'</font><font color="#006600">); </font><font color="#0000CC">?></font> </font> </code> Koda izpildes rezultātā vajadzētu iegūt HTML failu: <code><font color="#000000"> <html> <head> <title>Novadu ziņas</title> </head> <body> <div style="padding: 10px; font-size: 90%;"> <b>Ekonomiskā krīze Valmierā</b><br /> Šodien Valmierā cenas stāvus gaisā </div> <div style="padding: 10px; font-size: 90%;"> <b>Apsveicam!</b><br /> Apsveicam Pēteri Rūjienā deviņdesmitajos šūpuļsvētkos! </div> <div style="padding: 10px; font-size: 90%;"> <b>Pāvilostā dzelzceļnieku streiks</b><br /> Pāvilostas dzelzceļnieku arodbiedrība pieteikusi streiku </div> </body> </html></font> </code> Un tas ir viss. Dizaineriem dodam šablonus, paši ķeramies pie kodiem.
  8. Ja pietrūkst pacietības un zināšanu, lai uzstādītu Apache, PHP un MySQL, Windows lietotāji var izmantot gatavus .exe failus, kas visu šo uzstāda un nokonfigurē lietošanas kārtībā. Pats sāku ar PHPDEV no http://www.firepages.com.au
×
×
  • Create New...