News Script... bräuchte dringend hilfe

Status
Nicht offen für weitere Antworten.

chrisbergr

Erfahrenes Mitglied
Hi, ich nochmal :)
Mein zweites Problem ist, dass ich ein newsscript erstellen will.. soweit sogut, als vorlage habe ich dazu mein GB script verwendet..
Ich hab jetzt ein problem, wenn ich auf dr übersichtsseite auf den titel klicke, soll mir nur das eine posting angezeigt werden.
gut, kann mir einer helfen, wie ich das lösen kann?
in der adressleiste sollte dann sowas wie read.php?id=5 stehen und mir auch nur das posting mit der id 5 angezeigt werden.. wie soll ich das realisieren?
hier noch die quellcodes der beiden seiten (jaja, ich weiss, is noch net fertig, also ändert sich das mit dem Formular noch, bekommt auch noch ne extra seite und anstelle $webseite wird da mal $titel stehen"
egal, hoffe jemand versteht mich und kann mir helfen :)

index.php:
PHP:
<?php
include "inc/confic.inc.php";
	
if ($submit) {
$day = date("d");
$month = date("m");
$year = date("Y");

$date = "$day"."."."$month"."."."$year";

//echo $date;
	
    $sql = "INSERT INTO $dbTable (name,email,website,date,comment) VALUES ('".addslashes($name)."','".addslashes($email)."','".addslashes($website)."','".addslashes($date)."','".addslashes($comment)."')";
    $result = mysql_query($sql);
    
    //echo $sql;
    
    }
?>
<p><img src="gfx/icons/posticonnew.gif" width="14" height="10">Write.News</p>
<form name="form1" method="post" action="<? PHP_SELF ?>">
  <div align="center">
    <table width="219" border="0" cellpadding="0" cellspacing="0">
      <tr> 
        <td width="219" height="22" valign="top"> <input name="name" type="text" value="name" size="35" maxlength="50"> 
        </td>
      </tr>
      <tr> 
        <td height="22" valign="top"> <input name="email" type="text" value="email" size="35" maxlength="50"> 
        </td>
        </tr>
      <tr> 
        <td height="22" valign="top"> <input name="website" type="text" value="http://" size="35" maxlength="50"> 
        </td>
        </tr>
      <tr> 
        <td height="10" valign="top"> <textarea name="comment" cols="30" rows="5">comment</textarea> 
        </td>
      </tr>
      <tr> 
        <td height="10"> <input type="submit" name="submit" value="[  submit  ]"> 
          <input type="reset" name="Reset" value="[  clear  ]"> </td>
      </tr>
    </table>
</div>
</form>
<p><img src="gfx/icons/posticonnew.gif" width="14" height="10">Index.News</p>
<p> 
  <?php
 		$result = mysql_db_query ("$dbname","select * from $dbTable ORDER BY id DESC");
		while ($row = mysql_fetch_array ($result)) 
		{
		
				
 			$id =$row["id"]; 		
 			$name =$row["name"];
   			$email =$row["email"];
			$website =$row["website"];
    		$date =$row[date];
   			$comment =nl2br(htmlentities(stripslashes($row[comment])));
			$admin =nl2br(htmlentities(stripslashes($row[admin])));
   			

echo"<p><img src=\"gfx/icons/lastpost.gif\" width=\"14\" height=\"10\">[<a href=\"$PHP_SELF?op=show&page=test/read\" alt=\"$website\">$website</a>] $id</p>";
}
?>
</p>

read.php:
PHP:
<?php
include "inc/confic.inc.php";
?>

<p><img src="gfx/icons/posticonnew.gif" width="14" height="10">Read.News</p>
<p> 
  <?php
 		$result = mysql_db_query ("$dbname","select * from $dbTable ORDER BY id DESC");
		while ($row = mysql_fetch_array ($result)) 
		{
		
				
 		
 			$name =$row["name"];
   			$email =$row["email"];
			$website =$row["website"];
    		$date =$row[date];
   			$comment =nl2br(htmlentities(stripslashes($row[comment])));
			$admin =nl2br(htmlentities(stripslashes($row[admin])));
   			


echo"<p><img src=\"gfx/icons/lastpost.gif\" width=\"14\" height=\"10\">[$date] [<a href=\"mailto:$email\" id=\"comment\">$name</a>] <br><b><font color=\"000000\">$website</font></b> <br>$comment</p><p id=\"comment\">$admin</p>";
}
?>
</p>
 
zu deinem "read.php?id=5"

PHP:
<?php
include "inc/confic.inc.php";
?>

<p><img src="gfx/icons/posticonnew.gif" width="14" height="10">Read.News</p>
<p> 
 <?php
         $result = mysql_db_query ("$dbname","select * from $dbTable where id = '$id' ORDER BY id DESC");
        while ($row = mysql_fetch_array ($result)) 
        {
        
                
         
             $name =$row["name"];
               $email =$row["email"];
            $website =$row["website"];
            $date =$row[date];
               $comment =nl2br(htmlentities(stripslashes($row[comment])));
            $admin =nl2br(htmlentities(stripslashes($row[admin])));
               


echo"<p><img src=\"gfx/icons/lastpost.gif\" width=\"14\" height=\"10\">[$date] [<a href=\"mailto:$email\" id=\"comment\">$name</a>] <br><b><font color=\"000000\">$website</font></b> <br>$comment</p><p id=\"comment\">$admin</p>";
}
?>
</p>
 
hmm, eine sache bräuchte ich noch dringend, und zwar es ist doch mit sicherheit möglich, jedes dieser postings zu editieren.. wie kann ich das anstellen? also dass die daten in nem formularfeld wieder ausgegeben werden, ist ja kein problem.. obwohl, ich muss das ja irgendwie mit der id machen.. auf alle fälle, wie funzt es, dass dan auch genau dieser beitrag wieder überschrieben wird?
 
wie du schon erkannt hast geht alles über die id

$result = mysql_db_query("$dbname","select * from $dbTable where id = '$id'");
$row = mysql_fetch_array($result);

dann zeigste den inhalt wieder an:

echo "<form>";
echo webseite<input type=text nmae=webseite value=',$row['webseite'],"'><br>";

... usw ....

dann der update

mysql_db_query("$dbname","update $dbTable set webseite='$webseeit,email='$email' ...usw where id = '$id');
 
ok, das hört sich jetzt schon mal gut an, nur bei der umsetzung habe ich probleme...
ich habe eine edit.php erstellt und der quellcode sieht so aus:
PHP:
<?php
include "inc/confic.inc.php";
	
if ($submit) {
$day = date("d");
$month = date("m");
$year = date("Y");

$date = "$day"."."."$month"."."."$year";

//echo $date;
	
$result = mysql_db_query("$dbname","select * from $dbTable where id = '$id'");
$row = mysql_fetch_array($result);
    
//echo $result;
    
    }
?>
<p><img src="gfx/icons/posticonnew.gif" width="14" height="10">Write.News</p>
<form name="form1" method="post" action="<? PHP_SELF ?>?op=show&page=test/write">
  <div align="center">
    <table width="219" border="0" cellpadding="0" cellspacing="0">
      <tr> 
        <td width="219" height="22" valign="top"> 
          <? echo name<input type=text name=name value=',$row['name'],"' size=35 maxlength=50>"; ?>
        </td>
      </tr>
      <tr> 
        <td height="22" valign="top">
          <? echo email<input type=text name=email value=',$row['email'],"' size=35 maxlength=50>"; ?>
        </td>
        </tr>
      <tr> 
        <td height="22" valign="top"> 
          <? echo webseite<input type=text name=title value=',$row['title'],"' size=35 maxlength=50>"; ?>
        </td>
        </tr>
      <tr> 
        <td height="10" valign="top"> 
          <? echo comment<input type=text name=comment value=',$row['comment'],"' size=35 maxlength=50>"; ?>
        </td>
      </tr>
      <tr> 
        <td height="10"> <input type="submit" name="submit" value="[  submit  ]"> 
          <input type="reset" name="Reset" value="[  clear  ]"> </td>
      </tr>
    </table>
</div>
</form>
<p><a href="<? PHP_SELF ?>?op=show&page=test/index"><img src="gfx/icons/lastpost.gif" width="14" height="10" border="0">News.Index</a></p>
<? mysql_db_query("$dbname","update $dbTable set name='$name',email='$email',title='$title',comment='$comment' where id = '$id'); ?>
so, nur auf der seite kommt volgender fehler:
Parse error: parse error, expecting `','' or `';'' in /homepages/35/d29799962/htdocs/JeyJey/new/com/test/edit.php on line 26
was hab ich falsch gemacht, und wie kann ichs richtig machen?
 
PHP:
<?php

include "inc/confic.inc.php";

if (!$submit) {

$day = date("d");
$month = date("m");
$year = date("Y");

$date = "$day"."."."$month"."."."$year";

//echo $date;

$result = mysql_db_query("$dbname","select * from $dbTable where id = '$id'");

$row = mysql_fetch_array($result);

//echo $result;

?>
<p><img src="gfx/icons/posticonnew.gif" width="14" height="10">Write.News</p>

<form name="form1" method="post" action="<? PHP_SELF ?>?op=show&page=test/write">

  <div align="center">
    <table width="219" border="0" cellpadding="0" cellspacing="0">
      <tr> 
        <td width="219" height="22" valign="top"> 
          <? echo "name<input type=text name=name value='",$row['name'],"' size=35 maxlength=50>"; ?>

        </td>
      </tr>
      <tr> 
        <td height="22" valign="top">
          <? echo "email<input type=text name=email value='",$row['email'],"' size=35 maxlength=50>"; ?>
        </td>
        </tr>
      <tr> 
        <td height="22" valign="top"> 
          <? echo "webseite<input type=text name=title value='",$row['title'],"' size=35 maxlength=50>"; ?>
        </td>
        </tr>
      <tr> 
        <td height="10" valign="top"> 
          <? echo "comment<input type=text name=comment value='",$row['comment'],"' size=35 maxlength=50>"; ?>
        </td>
      </tr>
      <tr> 
        <td height="10"> <input type="submit" name="submit" value=submit> 
          <input type="reset" name="Reset" value="[  clear  ]"> </td>
      </tr>
    </table>
</div>
</form>
<p><a href="<? PHP_SELF ?>?op=show&page=test/index"><img src="gfx/icons/lastpost.gif" width="14" height="10" border="0">News.Index</a></p>
<? } else { mysql_db_query("$dbname","update $dbTable set name='$name',email='$email',title='$title',comment='$comment' where id = '$id');
echo "Update Ok<br>"; } ?>

hoffe ich habe alle fehler raus :)
 
Zuletzt bearbeitet:
Status
Nicht offen für weitere Antworten.
Zurück