IBEX Posted December 22, 2008 Report Share Posted December 22, 2008 1. Man nekada saprashana nau, ka varetu uzskatities, tada lieta, ka ir lapa /index.php?id=video&cat=16&video_id=17 un ja pienjemsim uzraksta video_id=999, tada nau, tad vinsh aizlec uz video sakuma lapu.. 2. kur iespeja ir iemacities par post? nu tik vienkashi ka visu tur pamata limeni uzrakstit varu, bet ja, tur ir empty lauks, vai cik tur notiektie burti, to es gribetu iemacities.. ir kkur pamaciba?.. 3. pienjemsim kategorija 21 [/index.php?id=video&cat=21] un taja kategorija neka nau, tad ka to ar kodu paradit? Link to comment Share on other sites More sharing options...
nevidimka Posted December 22, 2008 Report Share Posted December 22, 2008 Man sis pats jautajums sakara ar GET f-ju .. Ka panakt lai pie info.php?id=154 parada cilveka informaciju, bet pie plika info.php atversanas parada "Kaut kas seit nav ta ka vajag .." .. ? Link to comment Share on other sites More sharing options...
Jackal Posted December 22, 2008 Report Share Posted December 22, 2008 (edited) Nu apmēram tā var pārbaudīt vai datubāzē ir pieprasītais ieraksts un ja nav tad redirektēt uz video sākumlapu $video_id = $_GET['video_id']; $query = mysql_query("SELECT * FROM tabula WHERE id = '$video_id'"); if(mysql_num_rows($query) > 0){ //parādam ierakstu } else { header("Location: index.php?id=video"); // Aiz "Location:" jāraksta saite uz video sākumlapu } Vēl jau vajadzētu pārbaudīt arī $_GET['video_id'], laikam ar is_nummeric varēja Edited December 22, 2008 by Jackal Link to comment Share on other sites More sharing options...
andrisp Posted December 22, 2008 Report Share Posted December 22, 2008 if (isset($_GET['id']) && $_GET['id'] eksistee db) { raadam attieciigo info } else { echo 'nav atrasts' vai header('Location: uz kurieni paaradreseet, ja nav atrasts') } Link to comment Share on other sites More sharing options...
nevidimka Posted December 22, 2008 Report Share Posted December 22, 2008 Man problema ir ta ka definejot $var = $_GET['id'], bridi kad sis mainigais netiek no linka padots - met erroru ka kaut kads neatpazistams index .. Tb index.php jau nesatur to $_GET['id'] .. tad man vinu iznak ka jadefine ieksa taja isset'aa ? Link to comment Share on other sites More sharing options...
andrisp Posted December 22, 2008 Report Share Posted December 22, 2008 $id = null; if (isset($_GET['id'])) { $id = (int) $_GET['id']; } // vai $id = isset($_GET['id']) ? (int) $_GET['id'] : null; Link to comment Share on other sites More sharing options...
Klez Posted December 22, 2008 Report Share Posted December 22, 2008 (edited) $_GET['sadala'] - buus nodefineetas sadaljas. (video,bildes,jaunumi [ar tekstu]) $_GET['id'] - var buut tikai cipari (apziimees objekta id datu baazee [bildei, video, jauniemiem]) $_GET['sadala'] varam arii nepaarbaudiit vai paarbaudiit vai ir tikai burti un veidot konstrukciju ar switch switch($_GET['sadala']){ case 'jaunumi': include("jaunumi.php"); break; case 'video': include("veido_sadala.php"); break; default: include("sakums.php"); } un veido_sadala.php $_GET['id'] = parbaudaam_id($_GET['id']); function parbaudaam_id($id) { if (nav_cipari($id)) return false; if (!paarbaudaam_vai_datubaazee_ir_taads_id($id)) return false; return $id; } fcija paarbaudaam_vai_datubaazee_ir_taads_id() atgrieziis true ja buus taads ieraksts un false ja nebuus .. Edited December 22, 2008 by Klez Link to comment Share on other sites More sharing options...
IBEX Posted December 23, 2008 Author Report Share Posted December 23, 2008 <?php if(isset($_GET['images_id']) == 'images_id' AND $_GET['images_id']) { echo'pati bilde'; } else { echo'vinjam kkas nepatik'; } if(isset($_GET['cat']) == 'cat' AND $_GET['cat']) { echo'izveleta ketegorija'; } else { echo'vinjam kkas nepatik'; } if (isset($_GET['id']) AND $_GET['id'] == "images") { echo'kategorijas'; } else { echo'vinjam kkas nepatik'; } ?> varetu, palugt, salikt else lai neraditots visas 3 shis lapas 1 lapa.. loti ludzu :) Link to comment Share on other sites More sharing options...
andrisp Posted December 23, 2008 Report Share Posted December 23, 2008 Kas tā par muļķīgu salīdzināšanu ? isset($_GET['cat']) == 'cat' Tāpēc jau arī tā ir. php.net/isset Link to comment Share on other sites More sharing options...
IBEX Posted December 23, 2008 Author Report Share Posted December 23, 2008 ka tad sanak rakstit? if (isset($_GET['id'])) ej un kko saporti no tiem kodiem :D Link to comment Share on other sites More sharing options...
andrisp Posted December 23, 2008 Report Share Posted December 23, 2008 Nu ja. Link to comment Share on other sites More sharing options...
p4F Posted December 23, 2008 Report Share Posted December 23, 2008 echo isset($_GET['id']); paskaties ko izvadīs ;) Link to comment Share on other sites More sharing options...
IBEX Posted December 23, 2008 Author Report Share Posted December 23, 2008 (edited) <?php if(isset($_GET['images_id'])) { echo'pati bilde'; } else { echo'vinjam kkas nepatik'; } if(isset($_GET['cat'])) { echo'izveleta ketegorija'; } else { echo'vinjam kkas nepatik'; } if (isset($_GET['id'])) { echo'kategorijas'; } else { echo'vinjam kkas nepatik'; } ?> Tas apaksha taa, kr4 radas visi 3 isseti viena lapa, kaut katram vajadzetu but pa savai lapai.. --------- Kr4 /index.php?id=images lapa radas, vinjam kkas nepatikvinjam kkas nepatikkategorijas , talak /index.php?id=images&cat=1 radas vinjam kkas nepatikizveleta ketegorijakategorijas , bet kad /index.php?id=images&cat=1&images_id-2 radas vinjam kkas nepatikizveleta ketegorijakategorijas ... echo man liekas, ka neies cauri.. andrisp, vai tiesham nau else starp jaliek? vai kkas cits nepareizi?.. Edited December 23, 2008 by IBEX Link to comment Share on other sites More sharing options...
Recommended Posts