View previous topic :: View next topic
Author
Message
mladen Joined: 07 Jan 2004 Posts: 43 Location: Dubrovnik
Posted: 31.01.2004 13:38 Post subject: problem php
Htio bi da iz baze odredjeni query izvucem u selectList obliku
sve sto nadje za odredjeni upit da slaze u <select>
problem mi je kod slaganja html-a tocno neznam kako bi islo.
znaci recimo :
spojio se na bazu ...
-------------------------
$query = "SELECT namef from korisnici";
$result = pg_exec($db, $query);
if (!$result) {printf ("ERROR nema podataka u bazi, ili ih nemogu povuci"); exit
;}
$numrows = pg_numrows($result);
$row=0;
printf ("<table border=1>\n");
printf ("<select name="selectList" class="form">\n");
do
{
$myrow = pg_fetch_row ($result, $row);
printf ("<option value="$myrow[0]"></option>\n");
$row++;
}
while ($row < $numrows);
printf ("</table>\n");
-----------------
znam da sam uhebao html kod 99% samo nisam siguran sta
jeli mi moze iko pomoci!
Hvala
_________________ "Revenge is best served cold"
www.holobit.net - linux freaks
http://balegari.bxteam.org - Clan pages
Back to top
maxy Joined: 07 Sep 2003 Posts: 894 Location: Zagreb
Posted: 31.01.2004 13:54 Post subject:
Code:
function dropdown()
{
$query = mysql_query("SELECT * FROM p4g_newscategories ORDER BY id DESC");
if(!$query) {
echo mysql_error();
die();
}
$input = "<select name = 'game' id = 'game' class = 'input'>
<option value = '0' selected>No category</option>";
$priljepi = "";
while($sql = mysql_fetch_array($query))
{
$priljepi.= "<option value = ".$sql['id'].">".$sql['name']."</option>";
}
$input.=$priljepi;
$input.="</select>";
return $input;
}
kopipejst iz nekog starog koda...
inace, $sql['id'] je ime autoinkrement retka, a sql['name'] je ono kaj se pojavi u dropdownu. sad, trebo bi iz ovog barem shvatit kak to radi..
ja imam funkciju te ako oces preko funkcije (ove) radit, onda je moras "execat" sa
Back to top
mladen Joined: 07 Jan 2004 Posts: 43 Location: Dubrovnik
Posted: 31.01.2004 13:58 Post subject:
tocno sto mi je trebalo .. baza je PGSQL .. ali same thing
Hvala puno !!!!!
_________________ "Revenge is best served cold"
www.holobit.net - linux freaks
http://balegari.bxteam.org - Clan pages
Back to top
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
Powered by phpBB © 2001, 2005 phpBB Group