Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Daten auslesen

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Language: German
View previous topic :: View next topic  
Author Message
Sternenstaub
Smarty Rookie


Joined: 19 Jan 2005
Posts: 5

PostPosted: Fri Feb 11, 2005 8:14 am    Post subject: Daten auslesen Reply with quote

Guten Morgen,

ich habe ein kleines Problem, will Daten auslesen lassen aus einem Gästebuch.

[php:1:81ecf58182]
<?php
SESSION_start();
include_once("libTemplate.php");
include "config.php";
$_SESSION['user_id'];

$sql = "SELECT user_id, send_id, titel, inhalt, datum FROM `gaestebuch` where user_id= '".$_GET['user_id']."'";
$res = mysql_query($sql) OR die("Fehler in der Abfrage: ".mysql_error());

while ($data = mysql_fetch_assoc($res)){

$user_id = $data['user_id'];
$send_id = $data['send_id'];
$titel = $data['titel'];
$inhalt = $data['inhalt'];
$datum = $data['datum'];

$sql2 = "SELECT nickname, email FROM `login`, `userprofil` WHERE `login`.user_id = '".$send_id."' AND `userprofil`.user_id = '".$send_id."'";
$res2 = mysql_query($sql2) OR die("Fehler in der Abfrage: ".mysql_error());
$data2 = mysql_fetch_assoc($res2);

$email = $data2['email'];
$nickname = $data2['nickname'];


$guest_data =array();
$guest_data['datum'] = $datum;
$guest_data['nickname'] = $nickname;
$guest_data['email'] = $email;
$guest_data['titel'] = $titel;
$guest_data['inhalt'] = $inhalt;
$guest_data['datum'] = $datum;
$guest_data['user_id'] = $_GET['user_id'];
$guest_data['www'] = $www;

$libTemplate->assign("guest_data",$guest_data);
}
$libTemplate->display("guestbook.tpl");
?>
[/php:1:81ecf58182]
Es wurden für das Mitglied 2 Einträge eingetragen, mir wird aber immer nur 1 Datensatz angezeigt. Kann mir jemand helfen?

Lieben Gruß
Tina
Back to top
View user's profile Send private message
doc_12
Smarty Rookie


Joined: 04 Jan 2005
Posts: 13

PostPosted: Fri Feb 11, 2005 8:56 am    Post subject: Reply with quote

Hallo

Das muss ausserhalb der while die Variable zuweisen.
Und als 2 dim array Übergeben.
zb.
Code:
while
 $guest_data[0]['datum'] =  $datum;

und dann ausserhalb der while
Code:
$libTemplate->assign("guest_data",$guest_data);


Oder du machst ein fetch auf eine Zeilen
$arrLines[] = $smarty->fetch('row.tpl');

und dann zum schluss einen assign auf das eigentliche Template.
(nach while)
assign("ergebniss",$arrLines)

Es kann auch sein das du innerhalb der TPL direkt mit den Ergebnis von MYSQL erbeiten kannst . assign ( "res", $res );
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Language: German All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP