[TYPO3-UG Dutch] php vraag

Frans Saris franssaris at gmail.com
Mon Nov 19 08:47:50 CET 2007


Hoi Leen,

zelf zou ik het als volgt doen:

$query =
$GLOBALS['TYPO3_DB']->exec_SELECTquery('*','tx_companyoffers_category','
pid >0');
while($res = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($query)){
       $options[$res['uid']] = '<option value="'.$res['uid'].'">
'.$res['title'].'</option>';
}
return implode('',$options);

of als dit alles is wat de functie moet doen:

$query = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*','tx_companyoffers_category','
pid >0');
$options = '';
while($res = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($query)){
       $options .= '<option value="'.$res['uid'].'">
'.$res['title'].'</option>';
}
return $options;



gr. Frans

Op 18-11-07 heeft Leen Strijk<leenstrijk at tomaatnet.nl> het volgende geschreven:
> Leen Strijk schreef:
>
> Ik heb nu wel een oplossing maar ik vraag me af dit niet beter kan.
> Minder code??
> betere php functie??
> api functie??
>
> Dit is mijn oplossing:
> $query =
> $GLOBALS['TYPO3_DB']->exec_SELECTquery('*','tx_companyoffers_category','
> pid >0');
> while($res = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($query)){
>         $n = $res['uid'];
>         $row[$n]= '<option value="'.$res['uid'].'"> '.$res['title'].'</option>';
> $options= $options.$row[$n];
> }
> return $options;
>
> Graag de mening van een extensiebouwer
>
> Gr Leen
>
>
> > Hallo,
> >
> > Ik wil in een fe formulier die ik zelf aan het maken ben een selectbox
> > maken die de waardes uit de database haalt.
> >
> > met:
> > $query = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*','
> > tx_companyoffers_category', 'pid >0');
> >
> > while($res = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($query)){
> > echo $res['title'];
> > }
> >
> > Krijg ik ze wel getoond maar de uiteindelijke uitvoer moet een string
> > worden.
> >
> > Dus ik moet uiteindelijk return $content; hebben met als uitvoer:
> > <option value="id">title1</option>
> > <option value="id">title2</option>
> > <option value="id">title3</option>
> > <option value="id">title4</option>
> >
> > Kan iemand mij op weg helpen?
> >
>
> _______________________________________________
> TYPO3-UG-dutch mailing list
> TYPO3-UG-dutch at lists.netfielders.de
> http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-ug-dutch
>


More information about the TYPO3-UG-dutch mailing list