Witam.
Mam problem z kodem php.
mam dwa pliki zapisane na stronie:
dane.php i ksiega.php
wrzucając oba na stronę mam tabelkę i wpisy z tym iż jedno nad drugim. Niżej na zdjęciach przedstawiam problem:
(IMG:
http://img43.imageshack.us/img43/4173/20110806222140.jpg)
<?php
define('WPISY', './wpisy.txt');
function dodajWpis($tytul, $autor, $www, $tresc)
{
// Ucinanie bialych znakow
// Kontrola danych
{
return false;
}
{
return false;
}
{
return false;
}
{
// Jesli adres nie zaczyna sie od http:// to dodaj to
if(strpos($www, 'http://') !== 0
) {
$www = 'http://'.$www;
}
}
// Dodawanie
);
return true;
} // end dodajWpis();
function pobierzWpisy()
{
$i = 1;
foreach($wpisy as $wpis)
{
'id' => $i,
'data' => date('d.m.Y, H:i', $wpis[2]), );
$i++;
}
return $rezultat;
} // end pobierzWpisy();
?>
plik dane.php
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="pl" lang="pl">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="style.css" />
<link rel="Shortcut icon" href="favicon.ico" />
<style type="text/css"></style>
<meta name="Robots" content="index, nofollow" />
<meta name="Author" content="Arni" />
<meta http-equiv="Refresh" content="600" />
<meta name="Description" content="Strona poswiecona grze Guild Wars 2" />
<meta name="Keywords" content="Guild Wars 2, GuildWars 2, Guild Wars2, GuildWars2, guild wars 2, guildwars2, guild wars2, guildwars 2, Guild, guild, Wars, wars, 2, Guild Wars, guild wars, GuildWars, guildwars," />
<title>Guild Wars 2</title>
<style type="text/css">
/* <![CDATA[ */
a { text-decoration: none }
a:hover { color: red }
/* ]]> */
</style>
</head>
<body vlink="#0000CC">
<!--księga go?ci-->
<a href="ksiega.html" style="position: fixed; margin: 500px 0px 0px 100px;"><img src="image/ksiegagosci.gif"></img>
<!--logo-->
<div id="logo"><a href="index.html"><img src="image/logo.png"></a></div>
<!---menu nawigacyjne-->
<div id="menu"> <a href="index.html" class="stronaglowna">
<a href="regulamin.html" class="regulamin">
<a href="forum.html" class="forum">
<a href="newsy.html" class="newsy">
<a href="gw2.html" class="gw2">
</a></div>
<!--tresc strony-->
<div class="ksiega">
<!---odczyt wpisu--->
<div class="ksiegatext">
<!---Je?li przekracza wymiary należy dodać scrypt java--->
<!---Treść--->
</div>
<!---wpisy--->
<div class="ksiegawpis">
<!---teść--->
<?php
require('./dane.php');
if($_SERVER['REQUEST_METHOD'] == 'POST')
{
// Dodawanie wpisu
if(dodajWpis($_POST['tytul'], $_POST['autor'], $_POST['www'], $_POST['tresc']))
{
echo '<p>Dziękujemy, wpis został dodany prawidłowo.</p>'; }
else
{
echo '<p>Proszę wypełnić prawidłowo formularz.</p>'; }
echo '<p><a href="ksiega.php">Powrót</a></p>'; }
else
{
// Wyświetlanie wpisów
$wpisy = pobierzWpisy();
foreach($wpisy as $wpis)
{
echo '<hr /><p><b>Tytuł: <i>'.$wpis['tytul'].'</i>; Autor: '.$wpis['autor'].'; Data: '.$wpis['data'];
{
echo '; <a href="'.$wpis['www'].'" target="_blank">Strona WWW</a>'; }
echo '<p>'.$wpis['tresc'].'</p>'; }
?><hr />
<form method="post" action="ksiega.php">
<table border="0" width="50%">
<tr>
<td>Tytuł</td>
<td><input type="text" name="tytul"/></td>
</tr>
<tr>
<td>Autor</td>
<td><input type="text" name="autor"/></td>
</tr>
<tr>
<td>WWW</td>
<td><input type="text" name="www"/></td>
</tr>
<tr>
<td>Treść</td>
<td><textarea name="tresc" rows="4" cols="50"></textarea></td>
</tr>
<tr>
<td></td>
<td><input type="submit" value="Dodaj"/></td>
</tr>
</table>
</form>
<?php
}
?>
</div>
</div>
</body>
</html>
ksiega.php
Gdy zmieniam php w ksiega.php, wpisy mam wyświetlane z lewej strony, ale wtedy nie ma tabelek dodających wpis, niżej obrazek:
(IMG:
http://img97.imageshack.us/img97/3043/20110806222023.jpg)
Tutaj dodaję plik po zmianie php.
Przepraszam że jeden pod drugim, nie zmieściło mi się wszystko w pierwszym poście.
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="pl" lang="pl">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="style.css" />
<link rel="Shortcut icon" href="favicon.ico" />
<style type="text/css"></style>
<meta name="Robots" content="index, nofollow" />
<meta name="Author" content="Arni" />
<meta http-equiv="Refresh" content="600" />
<meta name="Description" content="Strona poswiecona grze Guild Wars 2" />
<meta name="Keywords" content="Guild Wars 2, GuildWars 2, Guild Wars2, GuildWars2, guild wars 2, guildwars2, guild wars2, guildwars 2, Guild, guild, Wars, wars, 2, Guild Wars, guild wars, GuildWars, guildwars," />
<title>Guild Wars 2</title>
<style type="text/css">
/* <![CDATA[ */
a { text-decoration: none }
a:hover { color: red }
/* ]]> */
</style>
</head>
<body vlink="#0000CC">
<!--księga go?ci-->
<a href="ksiega.html" style="position: fixed; margin: 500px 0px 0px 100px;"><img src="image/ksiegagosci.gif"></img>
<!--logo-->
<div id="logo"><a href="index.html"><img src="image/logo.png"></a></div>
<!---menu nawigacyjne-->
<div id="menu"> <a href="index.html" class="stronaglowna">
<a href="regulamin.html" class="regulamin">
<a href="forum.html" class="forum">
<a href="newsy.html" class="newsy">
<a href="gw2.html" class="gw2">
</a></div>
<!--tresc strony-->
<div class="ksiega">
<!---odczyt wpisu--->
<div class="ksiegatext">
<!---Je?li przekracza wymiary należy dodać scrypt java--->
<!---Treść--->
<?php
// Wyświetlanie wpisów
require('./dane.php');
$wpisy = pobierzWpisy();
foreach($wpisy as $wpis)
{
echo '<hr /><p><b>Tytuł: <i>'.$wpis['tytul'].'</i>; Autor: '.$wpis['autor'].'; Data: '.$wpis['data'];
{
echo '; <a href="'.$wpis['www'].'" target="_blank">Strona WWW</a>'; }
echo '<p>'.$wpis['tresc'].'</p>'; }
?>
</div>
<!---wpisy--->
<div class="ksiegawpis">
<!---teść--->
<?php
require('./dane.php');
if($_SERVER['REQUEST_METHOD'] == 'POST')
{
// Dodawanie wpisu
if(dodajWpis($_POST['tytul'], $_POST['autor'], $_POST['www'], $_POST['tresc']))
{
echo '<p>Dziękujemy, wpis został dodany prawidłowo.</p>'; }
else
{
echo '<p>Proszę wypełnić prawidłowo formularz.</p>'; }
echo '<p><a href="ksiega.php">Powrót</a></p>'; }
else
{
?>
<hr />
<form method="post" action="ksiega.php">
<table border="0" width="50%">
<tr>
<td>Tytuł</td>
<td><input type="text" name="tytul"/></td>
</tr>
<tr>
<td>Autor</td>
<td><input type="text" name="autor"/></td>
</tr>
<tr>
<td>WWW</td>
<td><input type="text" name="www"/></td>
</tr>
<tr>
<td>Treść</td>
<td><textarea name="tresc" rows="4" cols="50"></textarea></td>
</tr>
<tr>
<td></td>
<td><input type="submit" value="Dodaj"/></td>
</tr>
</table>
</form>
<?php
}
?>
</div>
</div>
</body>
</html>
Rozwiązałem ten problem rozbijając plik dane.php na dwa pliki dodający wpisy i odczytujący.
Pozdrawiam