gollum1990
Neues Mitglied
Hallo,
I ch habe ein Problem, ich will ein Select Field das da alle User anzeigt(auswählt). Das ganze ist in ner While Schliefe so:
Da wird nur der erste User ausgeslesen das wars.
Es kommt auch keine Fehlermeldung auch nicht mit E_ALL
2.Problem Formular wird nicht richtig in Mysql gespeichert.
Ach hier mal das ganze:
I ch habe ein Problem, ich will ein Select Field das da alle User anzeigt(auswählt). Das ganze ist in ner While Schliefe so:
Code:
$sql = mysql_query("SELECT `username` FROM `login`");
while(............................(....))
{
[...]
echo '
<select name="username">
<option value="'.$row['username'].'">'.$row['username'].'
</select>'
Da wird nur der erste User ausgeslesen das wars.
Es kommt auch keine Fehlermeldung auch nicht mit E_ALL
2.Problem Formular wird nicht richtig in Mysql gespeichert.
Ach hier mal das ganze:
Code:
<?php
session_start();
?>
<html>
<head>
<title>Nachrichten Schicken und Empfangen</title>
<style type="text/css">
a:link { color: #CBA300; display: block; padding: 1px; }
a:visited { color: #CBA300; display: block; padding: 1px; }
a:hover { color: #ffffff; background-color: #565553; display: block; padding: 1px;}
a:active { color: #FFFFFF; display: block; padding: 1px; }
BODY{
color:black;
background-color: #FFFFFF;
font-family: Verdana;
font-size: 11px;
line-height: 19px;
}
td {
font-family: Verdana;
font-size: 11px;
line-height: 19px;
}
input, textarea, select {
font-family: Verdana;
font-size: 11px;
}
table {
border-width:1px;
border-style: solid;
border-color:#191970;
background-color: #DCDCDC;
}
.standard{
text-decoration:none;
font-size:11px;
font-family:verdana, arial, serif;
color:#000000;
background-color: #DCDCDC;
}
TABLE.standard {
text-decoration:none;
font-size:11px;
font-family:verdana, arial, serif;
color:#000000;
border-width:1px;
border-style:solid;
border-color:#000000;
}
TD.standard {
text-decoration:none;
font-size:11px;
font-family:verdana, arial, serif;
font-weight: bold;
color:#000000;
}
.headline{
font-size:14px;
font-family:verdana, arial, serif;
font-weight: bold;
color:#191970;
height : 20px;
}
input {
font-family:verdana, arial, serif;
font-size: 11px;
color:#000000;
background-color:#F1EBD5;
border-width:1px;
border-color:#000000;
width : 135px;
font-weight : normal;
}
</style>
</head>
<body>
<center>
<table border="0" cellpadding="0" cellspacing="0" width="600">
<tr>
<td>
[img]logo1.png[/img]
</td>
<td>
[url="nachrichten.php?action=senden"]Nachricht Senden[/url]
</td>
<td>
[url="nachrichten.php?action=ansehen"]Nachricht Ansehen[/url]
</td>
<td>
[url="main.php"]Zurück zur Hauptseite[/url]
</td>
</tr>
<tr>
<td>
[img]logo2.png[/img]
</td>
<td colspan="3">
<?php
if(isset($_SESSION['username']))
{
echo 'Hallo User: '.$_SESSION['username'].'
';
echo '[url="main.php?mode=logout"]Logout[/url]';
}
else
{
echo 'Sorry du bist nicht eingeloggt.';
}
?>
</td>
</tr>
<tr>
<td>
<?php
include 'connect.php';
if(isset($_SESSION['username']))
{
$lognetuser =$_SESSION['username'];
$sql4 = mysql_query("SELECT * FROM `nachrichten` WHERE `username` = '".$lognetuser."'") or die (mysql_error());
$sql2 = mysql_query("SELECT `username` FROM `login` LIMIT 100") or die (mysql_error());
while($rowenu = mysql_fetch_array($sql2))
{
while($rowen = mysql_fetch_array($sql4))
{
$action =$_GET['action'];
{
if($action == 'senden')
{
echo '<form action="nachrichten.php?action=senden2" method="post">';
echo '<table border="0" cellpadding="0" cellspacing="0" width="400">';
echo '<tr><td>Von: <input type="text" name="du" value="'.$_SESSION['username'].'" disabled></td></tr>';
echo '<tr><td>An: <select name="username"><option value="'.$rowenu['username.'].'">'.$rowenu['username'].'</select></td></tr>';
echo '<tr><td>Betreff: <input type="text" name="betreff"></td></tr>';
echo '<tr><td>Nachricht: <textarea width="400" height="400" name="nachricht"></textarea></td></tr>';
echo '<tr><td><input type="submit" value="Schicken">
</form></td></tr>';
echo '</table>';
}
elseif($action == 'senden2')
{
$post1 =$_POST['username'];
$post2 =$_POST['betreff'];
$post3 =$_POST['nachricht'];
$post4 =$_POST['du'];
if($post1 = '' OR $post2 = '' OR $post4 = '' OR $post4 = '')
{
echo 'Bitte alle Felder ausfüllen.';
}
else
{
$datum = time();
$eintrag = "INSERT INTO nachrichten(username, nachricht, betreff, von, datum) VALUES ('$post1', '$post3', '$post2', '$post4', '$datum');";
$eintragen = mysql_query($eintrag, $verbindung) or die (mysql_error());
if($eintragen == true)
{
echo 'Eintrag erfolgreich.';
}
else
{
echo 'Server Fehler versuchen sie es erneut, wenn dieses Problem weiter besteht bitte im Forum melden
unter [url="phpbb2"]Forum[/url].';
}
}
}
elseif($action == 'ansehen')
{
$dauer = $rowen['datum'];
echo '<table border="0" cellpadding="0" cellspacing="0" width="400">';
echo '<tr><td>Von: [b]'.$rowen['von'].'[/b]</td><td>Datum: [b]'; ?> <?= date("g:i:s", $dauer) ?> <?php echo '[/b]</td></tr>';
echo '<tr><td>Betreff: [b]'.$rowen['betreff'].'[/b]</td><td>Nachricht: [b]'.$rowen['nachricht'].'[/b]</td></tr></table>';
}
}
}
}
}
?>
</td>
</tr>
</table>
</body>
</html>