Klez Posted February 14, 2004 Report Share Posted February 14, 2004 <? $max = mysql_query("SELECT * FROM tabula WHERE text like '%$veriba%'"); $cik_atrod = mysql_num_rows($max); while ($atb = mysql_fetch_array($max)){ echo $atb['text']." id=".$atb['id']." !! <br>"; } mysql_free_result($max); ?> nu lieta taada. ieraxtus no DB daduuju. zinu arii skaitu cik ieraxtu ir atrasti. bet man vajag no atrastajiem ieraxtiem uz ekraana paraadiitu vienu tikai. kaads varbuut zin kaa to dabuut gatavu? :( Link to comment Share on other sites More sharing options...
sorehead Posted February 14, 2004 Report Share Posted February 14, 2004 ja vajag pirmo izvadiit, tad sita.. <? $max = mysql_query("SELECT * FROM tabula WHERE text like '%$veriba%'"); $cik_atrod = mysql_num_rows($max); $i=0; while ($atb = mysql_fetch_array($max) || $i < 1) { echo $atb['text']." id=".$atb['id']." !! <br>"; $i++; } mysql_free_result($max); ?> straadaa? Link to comment Share on other sites More sharing options...
Klez Posted February 14, 2004 Author Report Share Posted February 14, 2004 lieta jau taada ka man pirmo nevajag. Link to comment Share on other sites More sharing options...
sorehead Posted February 14, 2004 Report Share Posted February 14, 2004 kuru tad tev vajag ? Link to comment Share on other sites More sharing options...
Klez Posted February 14, 2004 Author Report Share Posted February 14, 2004 principaa man vajag lai taa: no DB ieguutos ieraxtus ielikt masiivaa un sanummureet vinjus. un tad ar random() paliidziibu izveeleeties vienu Link to comment Share on other sites More sharing options...
sorehead Posted February 14, 2004 Report Share Posted February 14, 2004 katu domaa, kur tiek atgriezts mysql rezultaats?:) Link to comment Share on other sites More sharing options...
Klez Posted February 14, 2004 Author Report Share Posted February 14, 2004 protams ka masiivaa. $max = mysql_query("SELECT * FROM tabula WHERE text like '%$veriba%'"); echo count($max) // izvadaas veertiiba 1 un tas arii viss. taalaak netieku :( Link to comment Share on other sites More sharing options...
sorehead Posted February 14, 2004 Report Share Posted February 14, 2004 labi, karoche taa.. <? $rs = mysql_query("SELECT id, text FROM tabula WHERE text like '%$veriba%'"); $amount = mysql_num_rows($rs); // izveidojam masiivu $rd_array = array(); while ($row = mysql_fetch_array($rs)) { $rd_array[] = $row['id'].";".$row['text']; } mysql_free_result($rs); // izvadam uz random vienu echo $rd_array[rand (0, $amount-1) ]; ?> vajadzeetu straadaat, kaut arii es netesteeju.. p.s. nosaucu cilveeciigi visus mainiigos, liidz ar to, njem kopee visu skriptu un pec tam testee. Link to comment Share on other sites More sharing options...
Klez Posted February 15, 2004 Author Report Share Posted February 15, 2004 tenx. nodereeja. viss straadaa kaa naakas :) :) :) Link to comment Share on other sites More sharing options...
Kaklz Posted February 15, 2004 Report Share Posted February 15, 2004 tenx. nodereeja. viss straadaa kaa naakas :) :) :) Citāts no http://j.esuntu.com/2004/02/11/mysql_un_php_sikumi_nr-2/ MySQL Lai no datubāzes uz dullo izvēlētos kādu ierakstu, nav jāraksta PHP skripts, kas noskaidro ierakstu skaitu un iespējamos id datubāzē – pietiek ar MySQL pieprasījumu: SELECT * FROM tabula ORDER BY RAND() LIMIT 1; Link to comment Share on other sites More sharing options...
sorehead Posted February 15, 2004 Report Share Posted February 15, 2004 var arii taa laikam.. Link to comment Share on other sites More sharing options...
Recommended Posts