Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

php und mysql webinterface/zugriff auf ergebnis einer select abfrage

Empfohlene Antworten

Veröffentlicht

hi leute,

kann mir jmd von euch sagen, wie ich es bei php schaffe auf das ergebnis eines select statements zuzugreifen? ich benütze eine mysql datenbank.


$SQLQuery = "SELECT name, vorname FROM person";

$QueryResult = mysql_query($SQLQuery,$ConID);

while (mysql_fetch_array($QueryResult))
{
$tpl->set_var(array("NAME" => ($QueryResult,"name"),
"VORNAME" => ($QueryResult,"vorname"),
));

$tpl->parse("personenvar", "personen", true);
}
[/PHP]

ich arbeite außerdem mit templates.

ich weiss wie ich es mit einer odbc datenquelle machen muss, aber in mysql weiss ich nicht wie der aufruf aussehen muss.

mit einer odbc datenquelle sieht das ganze so aus:

[PHP]
$tpl->set_var(array("NAME" => odbc_result($QueryResult,"name"),
"VORNAME" =>odbc_result($QueryResult,"vorname"),
));

für jede hilfe dankbar korea1

erstze bei denem ersten codeschnipsel


while (mysql_fetch_array($QueryResult))
{
$tpl->set_var(array("NAME" => ($QueryResult,"name"),
"VORNAME" => ($QueryResult,"vorname"),
));

$tpl->parse("personenvar", "personen", true);
}
[/PHP]

durch

[PHP]
while ($row=mysql_fetch_assoc($QueryResult))
{
$tpl->set_var(array("NAME" => $row["name"],
"VORNAME" => $row["vorname"]),
));

$tpl->parse("personenvar", "personen", true);
}

gruss gurkenpapst

hi,

wenn ich das so versuche bekomme ich einen parse error.

ich benütze die template.inc von php.

noch ein vorschlag?

die struktur, is von meiner template.inc so vorgegeben.

s. erster beitrag

hi,

daran lags nicht, dass hatte ich schon entdeckt.

sonst noch ne idee?

danke

hi,

jetzt funktioniert es.


while($row = mysql_fetch_array($QueryResult))
{
$tpl->set_var(array(VORNAME => $row["vorname"],
NAME => $row["name"]
));
$tpl->parse("personvar","person",true);
}
[/PHP]

ich hatte bei dem parse versehentlich einen blank.

und das mysql_fetch_assoc mag er bei mir irgendwie nicht.

nochmal danke

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.