"Heute basteln wir ein Listenfeld"
Zitat:
Original geschrieben von LordFuture
Für interessierte hier trotzdem nochmal der endlich richtig funktionierende Code:
|
Sehr umständlich. Schon mal was von DISTINCT gehört?
PHP-Code:
# Connect
if ($conn = @mysql_connect($SQLserver , $SQLuser, $SQLpasswort))
{
if (! @mysql_select_db ($SQLdbname)) die ('Abbruch: SQL Server nicht erreichbar!');
}
else
{
die ('Abbruch: SQL Server nicht erreichbar!');
}
# Connect erfolgreich, DB selektiert
$newcat = array();
if ($res = mysql_query('SELECT DISTINCT category FROM gallery'))
{
while ($row = mysql_fetch_assoc($res)) $newcat[] = $row['category'];
}
@mysql_free_result($res);
mysql_close();
$entz = count ($newcat);
# und weiter mit Deinem Script
// Template initialisieren
$tpl = new IntegratedTemplateExtension($m5 . "/templates/");
$tpl -> loadTemplatefile("gchoose.tpl");
// Do homä ein paar allgemeine ITX-Variablen die wir jetzt setzen
$tpl -> setVariable("tmarg","10");
$tpl -> setVariable("lmarg","20");
// So, zu guter letzt noch des Drop-Down-Menü mit den einträgen füllen
$tpl -> setCurrentBlock("colblock");
for($d=0; $d<$entz; $d++)
{
$tpl -> setVariable("gco_value", $newcat[$d]);
$tpl -> setVariable("gco_title", $newcat[$d]);
$tpl -> parseCurrentBlock();
}
$tpl -> show();
?>