0
Well I have a loop while
that shows all my posts on the page and for each post I have a input box
to comment on the post. I need a way to put it (input) out of the while but stay in all posts. How can I do this?
Code
$result_post = mysql_query("SELECT * FROM posts WHERE estabelecimento_id = $id_estabelecimento ORDER BY data DESC");
while ($row_posts = mysql_fetch_object($result_post)) {
$result_user_anex = mysql_query("SELECT * FROM users_social WHERE id = $row_posts->user_id");
$row_user_anex = mysql_fetch_object($result_user_anex);
?>
<section class="container" style="margin:15px 0px 0px 0px; border-top-left-radius: 2px; border-top-right-radius: 2px;">
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td valign="top">
<div style="float:left; margin:0px 0px 10px 0px;">
<img width="50" height="50" src="<?= $row_user_anex->user_foto ?>"/>
</div>
<h3 style="float:left; margin:15px 0px 0px 10px;"><?= utf8_encode($row_user_anex->fb_nome); ?></h3>
</td>
</tr>
</table>
<p><?= utf8_encode($row_posts->opiniao); ?></p>
<script>
FB.init({ appId: '1404139796547995', status: true, cookie: true, xfbml: true, oauth: true });
function post_fb<?= $row_posts->id_post; ?>() {
FB.login(function(response) {
if (response.authResponse) {
FB.ui({
method: 'feed',
message : "Vê este comentário sobre <?= $row_cat->titulo; ?> no @SabeOnde",
link : '<?= $row->link_site; ?>',
picture : 'http://sabeonde.pt/gtm/anexos/capa/<?= $row_capa->id_anexo; ?>.<?= $row_capa->tipo ?>',
name : '<?= $row_cat->titulo; ?> | SabeOnde',
from : '<?= $_SESSION['FBID'] ?>',
description : '<?= $row_posts->opiniao; ?>'
},
function(response) {
if (response && response.post_id) {
alert('Comentário Partilhado com sucesso!');
} else {
alert('Falha ao partilhar o comentário');
}
});
} else {
alert('User cancelled login or did not fully authorize.');
}
}, {scope: 'publish_actions, publish_stream'});
return false;
}
</script>
<div style="float:left; margin:0px 5px 10px 0px;"><a href="#">Gosto</a></div>
<div style="float:left; margin:0px 5px 10px 0px;"><a href="#" >Comentar</a></div>
<div style="float:left; margin:0px 5px 10px 0px;"><a href="#" onClick="post_fb<?= $row_posts->id_post; ?>()">Partilhar</a></div>
</section>
<input type="hidden" name="post_id" id="post_id" value="<?= $row_posts->id_post;?>"/>
<input type="hidden" name="user_id" id="user_id" value="<?= $_SESSION['user_id'] ?>"/>
<table border="0" bgcolor="#E9EAED" style="border-bottom-left-radius: 2px; border-bottom-right-radius: 2px;" width="100%" cellpadding="0" cellspacing="0">
<tr>
<td valign="top" width="10%">
<div style="padding:15px 5px 5px 20px;"><img width="33" height="33" src="<?= $_SESSION['user_foto'] ?>"/></div>
</td>
<td valign="top" width="90%">
<div style="padding:15px 20px 15px 5px;"><input type="text" style="width:100%; height:33px;" placeholder="Escreve um comentário..." id="comentario" name="comentario" value=""></div>
<input type="submit" class="submit" style="display:none;" value=" Submit Comment " />
</td>
</tr>
</table>
<?php
}
Could post the code you have so far?
– Rafael Withoeft
Already placed
– César Sousa
I tidied up your source code a bit, tried to improve it but what you requested has not yet been implemented.
– Rafael Withoeft
was this below the table that has the input box of comments
– César Sousa
i just want to find a way to take this table out of the while but repeat on all posts realized ?
– César Sousa
Yes, but your code was badly formatted, the way it is now is more readable; Only way I thought so far is you do a separate function and only pass the parameters to it; A class for example...
– Rafael Withoeft
of course thanks but you know how I can do that ?
– César Sousa
Let’s go continue this discussion in chat.
– Rafael Withoeft