при натискане на текст да излиза форма..

Post Reply
aquafresh
Много Редовен
Много Редовен
Posts: 1891
Joined: Sun Aug 03, 2008 11:02 am
Contact:

при натискане на текст да излиза форма..

Post by aquafresh » Fri Apr 10, 2009 7:24 pm

Примерно да пише "добави коментар" И като се цъкне на него да вади формата..
Ето това ми е файла

Code: Select all

<?php
include&#40;"config.php"&#41;;
$id = &#40;int&#41;$_GET&#91;'id'&#93;;
if&#40;isset&#40;$_POST&#91;'submit'&#93;&#41;&#41;&#123;
$date = date&#40;"d.m.Y , G.i часа"&#41;;
$sql = mysql_query&#40;"INSERT INTO comments &#40;id, article, author, comment, date&#41; VALUES &#40;NULL, '$id', '$_POST&#91;name&#93;', '$_POST&#91;comment&#93;', '$date'&#41;"&#41; or die&#40;mysql_error&#40;&#41;&#41;;
&#125;
else &#123;
echo "";
&#125;
?>
<h5><span style="color&#58;#666; font-style&#58;bold;">Коментари</span></h5>
<div>
<div class='inn'>
<?php
$query = mysql_query&#40;"SELECT * FROM `comments` WHERE `article`='$id' "&#41; or die&#40;mysql_error&#40;&#41;&#41;;
$n = mysql_num_rows&#40;$query&#41;;
if &#40; $n == '0' &#41;
&#123;
echo 'Няма коментари';
&#125;
while&#40;$raw = mysql_fetch_array&#40;$query&#41;&#41;&#123;
echo "
oт <b>$raw&#91;author&#93;</b> на $raw&#91;date&#93;<br>
<div style='padding&#58; 10px; background-color&#58; #EDDECB; border-top&#58;solid 1px #000;'>
$raw&#91;comment&#93; <br /></div>
";
&#125;
?>
 <br />
</div></div>
<form action="" method="post">
<table width="100%" border="0" align="center" cellpadding="3" cellspacing="1">
<tr>
<td>Име&#58;<br>
<input type="text" name="name" id="name"></td>
</tr>
<tr>
<td>Коментар&#58;<br>
<textarea name="comment" cols="50" rows="3" class="textinput" id="m"></textarea></td>
</tr>
<tr>
<td>
<input name="submit" type="submit" class="btn" id="submit" value="Изпрати">
<input name="button2" type="reset" class="btn" id="button2" value="Изчисти">
</td>
</tr>
</form>
</table>

camerb
Турист
Турист
Posts: 307
Joined: Sat Nov 10, 2007 2:55 pm

Post by camerb » Fri Apr 10, 2009 7:25 pm

Code: Select all

 <FORM>
<INPUT type="button" value="Коментари!" onClick="window.open&#40;'comments.php','mywindow','width=400,height=200,left=0,top=100,screenX=0,screenY=100'&#41;">
</FORM> 
comments.php ти е формата която си дал по горе.

aquafresh
Много Редовен
Много Редовен
Posts: 1891
Joined: Sun Aug 03, 2008 11:02 am
Contact:

Post by aquafresh » Fri Apr 10, 2009 7:27 pm

мне нямах предвид това.. не искам да ми вади друг проорец..
ио ио ио

camerb
Турист
Турист
Posts: 307
Joined: Sat Nov 10, 2007 2:55 pm

Post by camerb » Fri Apr 10, 2009 7:28 pm

Какъв прозорец,правиш си файл comments.php и слагаш кода който си дал по-горе.След това поставяш в сайта това където искаш да е и готово :)

User avatar
emagi
Шаман
Шаман
Posts: 6476
Joined: Fri Dec 07, 2007 3:24 pm
Answers: 1032

Post by emagi » Fri Apr 10, 2009 7:45 pm

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http&#58;//www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http&#58;//www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251" />
<title>Untitled Document</title>
<style type="text/css">
#forma &#123;
	display&#58;none;
&#125;
</style>
</head>

<body>
<?php
include&#40;"config.php"&#41;;
$id = &#40;int&#41;$_GET&#91;'id'&#93;;
if&#40;isset&#40;$_POST&#91;'submit'&#93;&#41;&#41;&#123;
$date = date&#40;"d.m.Y , G.i часа"&#41;;
$sql = mysql_query&#40;"INSERT INTO comments &#40;id, article, author, comment, date&#41; VALUES &#40;NULL, '$id', '$_POST&#91;name&#93;', '$_POST&#91;comment&#93;', '$date'&#41;"&#41; or die&#40;mysql_error&#40;&#41;&#41;;
&#125;
else &#123;
echo "";
&#125;
?>
<h5><span style="color&#58;#666; font-style&#58;bold;">Коментари</span></h5>
<div>
<div class='inn'>
<?php
$query = @mysql_query&#40;"SELECT * FROM `comments` WHERE `article`='$id' "&#41;;
$n = @mysql_num_rows&#40;$query&#41;;
if &#40; $n == '0' &#41;
&#123;
echo 'Няма коментари';
&#125;
while&#40;$raw =@mysql_fetch_array&#40;$query&#41;&#41;&#123;
echo "
oт <b>$raw&#91;author&#93;</b> на $raw&#91;date&#93;<br>
<div style='padding&#58; 10px; background-color&#58; #EDDECB; border-top&#58;solid 1px #000;'>
$raw&#91;comment&#93; <br /></div>
";
&#125;
?>
 <br />
</div></div>
<a href="#" onclick="document.getElementById&#40;'forma'&#41;.style.display='block'">Добави коментар</a><br />
<form action="" method="post" id="forma">
<table width="100%" border="0" align="center" cellpadding="3" cellspacing="1">
<tr>
<td>Име&#58;<br>
<input type="text" name="name" id="name"></td>
</tr>
<tr>
<td>Коментар&#58;<br>
<textarea name="comment" cols="50" rows="3" class="textinput" id="m"></textarea></td>
</tr>
<tr>
<td>
<input name="submit" type="submit" class="btn" id="submit" value="Изпрати">
<input name="button2" type="reset" class="btn" id="button2" value="Изчисти">
</td>
</tr>
</form>
</table>
</body>
</html>
Подтиснах извеждането на предупреждение на някои функции, махни отвсякъде знака @

aquafresh
Много Редовен
Много Редовен
Posts: 1891
Joined: Sun Aug 03, 2008 11:02 am
Contact:

Post by aquafresh » Fri Apr 10, 2009 7:47 pm

emagi, + :)
но закво да махам @ като работи без проблем?
ио ио ио

beta16
Нов
Нов
Posts: 79
Joined: Sun Apr 05, 2009 10:16 pm

Post by beta16 » Fri Apr 10, 2009 8:05 pm

emagi защо нищо не става като натисна добави коментар промених го с моята форма и всичко просто ми адва # горе в линка и край

User avatar
emagi
Шаман
Шаман
Posts: 6476
Joined: Fri Dec 07, 2007 3:24 pm
Answers: 1032

Post by emagi » Fri Apr 10, 2009 8:05 pm

aquafresh wrote:emagi, + :)
но закво да махам @ като работи без проблем?

То работи, но подтиска извеждането на WARNINGs

Post Reply