Also ich hab ein News script gebastelt und ich will die news die ich neu schreibe zu oberst kommen wie mache ich das?
Hier der code:
view.php
Der code zum eintragen:
Hier der code:
view.php
PHP:
<?php
// Zur DB Connecten //
$db = mysql_connect("","","");
mysql_select_db ();
// Die Tabelle //
$query = "SELECT * FROM cnews";
$result = mysql_query($query);
while ($news = mysql_fetch_row($result))
// Hier kommt die Ausgabe //
{
echo "<table width='25%' border='0'>
<tr>
<td height='22' width='32%'>
<div align='center'><font size='4'>$news[2]</font></div>
</td>
</tr>
<tr>
<td height='20' width='32%'>von <a href='mailto:nwaltert@hotmail.com'>$news[1]</a>
</td>
</tr>
<tr>
<td height='22' width='32%'> </td>
</tr>
<tr>
<td height='22' width='32%'>$news[3]</td>
</tr>
<tr>
<td height='22' width='32%'> </td>
</tr>
<tr>
<td height='22' width='32%'> </td>
</tr>
<tr>
<td height='22' width='32%'>Link: <a href='$news[4]'>$news[4]</a></td>
</tr>
<tr>
<td height='22' width='32%'> </td>
</tr>
<tr>
<td height='22' width='32%'> </td>
</tr>";
}
echo "</table>";
?>
Der code zum eintragen:
PHP:
<?php
if($passwort == "")
{
echo "Das Passwort stimmt!";
$db = mysql_connect("","","");
mysql_select_db ();
$query = "INSERT INTO cnews(name, titel, news, link)
VALUES('".$_POST['name']."','".$_POST['titel']."','".$_POST['news']."','".$_POST['link']."')";
$result = mysql_query($query);
echo "Die News wurde erfolgreich eingetragen!";
}
else
{
echo "Dein Passwort stimmt nicht!";
}
?>