Multiple rows in mysql

  • gisele
  • Expert
  • Expert
  • User avatar
  • Joined: Nov 11, 2004
  • Posts: 579
  • Loc: Nimes (France)
  • Status: Offline

Post July 6th, 2006, 9:19 am

Well first there's no use a parameter to pass in delete comment function.

$database->DeleteComment("del"); (in the call)

function DeleteProfileComment($del){ (in the class)

you can do this

$database->DeleteComment("del"); )

function DeleteProfileComment($del){ ()

Because $_GET is a superglobal and can be accesses from any where and any context.

just do this :

PHP Code: [ Download ] [ Select ]
 
$q = "DELETE FROM ".TBL_COMMENTS." WHERE ID_FIELD = ".$_GET["del"]." LIMIT 1";  
 
 
  1.  
  2. $q = "DELETE FROM ".TBL_COMMENTS." WHERE ID_FIELD = ".$_GET["del"]." LIMIT 1";  
  3.  
  4.  

and no parameter for the function , that'll be enough.

Anyway that's not the problem that can work.

In fact the problem seems to be in the comment deleting link .

You use $data["id_comment"] but that was just a generic example, in fact you told be that you had an ID system for the comment but I've got no idea of how you get it just before that's why I put $data["id_comment"] as an example.
I assumed that you retrieved in the same query that retrieves the comments informations.
You should do so anyway, and change my example $data[« id_comment »] by the right value something like $req_user_postusername['something'] (something =>name of the id field)

Ask any question ;-)
____________________
My web site[/url] oh sh..!
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post July 6th, 2006, 9:19 am

Post July 6th, 2006, 9:34 am

you have lost me. i am confused on what you are saying. from the code that i put on here can you give me the code to put in?
Thanks,
Josh --DemonMaestro
www.GothicGreenWire.com
  • gisele
  • Expert
  • Expert
  • User avatar
  • Joined: Nov 11, 2004
  • Posts: 579
  • Loc: Nimes (France)
  • Status: Offline

Post July 6th, 2006, 1:40 pm

here, see I replaced $data["id_comment"] in that part by $req_user_postusername['comment_id'].
But all is left to do, is replace comment_id by the real name of the ID field in the comment table. In fact I've got no idea of the name you gave to it in the database.
SO the right value will be in that link so that the right value will be passed $_GET["del"]
PHP Code: [ Download ] [ Select ]
 
//...  
 
if(isset($_GET["del"]))  
 
$database->DeleteComment("del");
 
 ?> <?php  
 
          while($req_user_postusername = mysql_fetch_array($rs_pointer))  
 
          {  
 
echo "<table width='100%' border='1' cellpadding='1' cellspacing='1' class=main>
 
 <tr><td width='24%' align='center' valign='middle' bordercolor='#000000'><div align='center'><span class='main'><a href='userinfo.php?user=".$req_user_postusername['username']."'>".$req_user_postusername['username']."</a><br />
 
   <br /><a href='comment.php?user=".$req_user_postusername['username']."'>Reply to post!</a><br><a href=\"".$_SERVER["PHP_SELF"]."?del=".$req_user_postusername['comment_id']."\">Delete Comment</a></span></div></td><td width='74%' bordercolor='#000000'><table width='100%' border='0'><tr><td align='right'>".$req_user_postusername['date']."</span><span class='main'></td></tr><tr><td>".preg_replace('#(\n)#', "<br />", $req_user_postusername['comment'])."</td></tr></table></td></tr></table>
 
 
 
 
 
";
 
 
 
           }  
 
 
  1.  
  2. //...  
  3.  
  4. if(isset($_GET["del"]))  
  5.  
  6. $database->DeleteComment("del");
  7.  
  8.  ?> <?php  
  9.  
  10.           while($req_user_postusername = mysql_fetch_array($rs_pointer))  
  11.  
  12.           {  
  13.  
  14. echo "<table width='100%' border='1' cellpadding='1' cellspacing='1' class=main>
  15.  
  16.  <tr><td width='24%' align='center' valign='middle' bordercolor='#000000'><div align='center'><span class='main'><a href='userinfo.php?user=".$req_user_postusername['username']."'>".$req_user_postusername['username']."</a><br />
  17.  
  18.    <br /><a href='comment.php?user=".$req_user_postusername['username']."'>Reply to post!</a><br><a href=\"".$_SERVER["PHP_SELF"]."?del=".$req_user_postusername['comment_id']."\">Delete Comment</a></span></div></td><td width='74%' bordercolor='#000000'><table width='100%' border='0'><tr><td align='right'>".$req_user_postusername['date']."</span><span class='main'></td></tr><tr><td>".preg_replace('#(\n)#', "<br />", $req_user_postusername['comment'])."</td></tr></table></td></tr></table>
  19.  
  20.  
  21.  
  22.  
  23.  
  24. ";
  25.  
  26.  
  27.  
  28.            }  
  29.  
  30.  

Post July 6th, 2006, 2:00 pm

ok it will come up with the comment id number but when i click on delete it does nothing and comes up to http://www.gothicgreenwire.com/mycomments.php?del=114 and it says username not registured because it need to say http://www.gothicgreenwire.com/mycommen ... user=admin or what ever there username is.

here is the database php
PHP Code: [ Download ] [ Select ]
function DeleteProfileComment($del){
 
      $q = "DELETE FROM ".TBL_COMMENTS." WHERE id = ".$_GET[$del]." LIMIT 1";  
 
       return mysql_query($q, $this->connection);  
 
      }
  1. function DeleteProfileComment($del){
  2.  
  3.       $q = "DELETE FROM ".TBL_COMMENTS." WHERE id = ".$_GET[$del]." LIMIT 1";  
  4.  
  5.        return mysql_query($q, $this->connection);  
  6.  
  7.       }


here is the mycomments php
PHP Code: [ Download ] [ Select ]
<?php //...  
 
if(isset($_GET["del"]))  
 
$database->DeleteComment("del");  
 
 ?> <?php  
 
          while($req_user_postusername = mysql_fetch_array($rs_pointer))  
 
          {  
 
echo "<table width='100%' border='1' cellpadding='1' cellspacing='1' class=main>  
 
 <tr><td width='24%' align='center' valign='middle' bordercolor='#000000'><div align='center'><span class='main'><a href='userinfo.php?user=".$req_user_postusername['username']."'>".$req_user_postusername['username']."</a><br />  
 
   <br /><a href='comment.php?user=".$req_user_postusername['username']."'>Reply to post!</a><br><a href=\"".$_SERVER["PHP_SELF"]."?del=".$req_user_postusername['id']."\">Delete Comment</a></span></div></td><td width='74%' bordercolor='#000000'><table width='100%' border='0'><tr><td align='right'>".$req_user_postusername['date']."</span><span class='main'></td></tr><tr><td>".preg_replace('#(\n)#', "<br />", $req_user_postusername['comment'])."</td></tr></table></td></tr></table>  
 
 
 
 
 
";  
 
 
 
           } ?>
  1. <?php //...  
  2.  
  3. if(isset($_GET["del"]))  
  4.  
  5. $database->DeleteComment("del");  
  6.  
  7.  ?> <?php  
  8.  
  9.           while($req_user_postusername = mysql_fetch_array($rs_pointer))  
  10.  
  11.           {  
  12.  
  13. echo "<table width='100%' border='1' cellpadding='1' cellspacing='1' class=main>  
  14.  
  15.  <tr><td width='24%' align='center' valign='middle' bordercolor='#000000'><div align='center'><span class='main'><a href='userinfo.php?user=".$req_user_postusername['username']."'>".$req_user_postusername['username']."</a><br />  
  16.  
  17.    <br /><a href='comment.php?user=".$req_user_postusername['username']."'>Reply to post!</a><br><a href=\"".$_SERVER["PHP_SELF"]."?del=".$req_user_postusername['id']."\">Delete Comment</a></span></div></td><td width='74%' bordercolor='#000000'><table width='100%' border='0'><tr><td align='right'>".$req_user_postusername['date']."</span><span class='main'></td></tr><tr><td>".preg_replace('#(\n)#', "<br />", $req_user_postusername['comment'])."</td></tr></table></td></tr></table>  
  18.  
  19.  
  20.  
  21.  
  22.  
  23. ";  
  24.  
  25.  
  26.  
  27.            } ?>
  • gisele
  • Expert
  • Expert
  • User avatar
  • Joined: Nov 11, 2004
  • Posts: 579
  • Loc: Nimes (France)
  • Status: Offline

Post July 6th, 2006, 2:19 pm

So no problem just add also this parameter in the target url :
PHP Code: [ Download ] [ Select ]
 
//...  
 
if(isset($_GET["del"]))  
 
$database->DeleteComment("del");
 
 ?> <?php  
 
          while($req_user_postusername = mysql_fetch_array($rs_pointer))  
 
          {  
 
echo "<table width='100%' border='1' cellpadding='1' cellspacing='1' class=main>
 
 <tr><td width='24%' align='center' valign='middle' bordercolor='#000000'><div align='center'><span class='main'><a href='userinfo.php?user=".$req_user_postusername['username']."'>".$req_user_postusername['username']."</a><br />
 
   <br /><a href='comment.php?user=".$req_user_postusername['username']."'>Reply to post!</a><br><a href=\"".$_SERVER["PHP_SELF"]."?user=".$req_user_postusername['username']."&amp;del=".$req_user_postusername['comment_id']."\">Delete Comment</a></span></div></td><td width='74%' bordercolor='#000000'><table width='100%' border='0'><tr><td align='right'>".$req_user_postusername['date']."</span><span class='main'></td></tr><tr><td>".preg_replace('#(\n)#', "<br />", $req_user_postusername['comment'])."</td></tr></table></td></tr></table>
 
 
 
 
 
";
 
 
 
           }  
 
 
  1.  
  2. //...  
  3.  
  4. if(isset($_GET["del"]))  
  5.  
  6. $database->DeleteComment("del");
  7.  
  8.  ?> <?php  
  9.  
  10.           while($req_user_postusername = mysql_fetch_array($rs_pointer))  
  11.  
  12.           {  
  13.  
  14. echo "<table width='100%' border='1' cellpadding='1' cellspacing='1' class=main>
  15.  
  16.  <tr><td width='24%' align='center' valign='middle' bordercolor='#000000'><div align='center'><span class='main'><a href='userinfo.php?user=".$req_user_postusername['username']."'>".$req_user_postusername['username']."</a><br />
  17.  
  18.    <br /><a href='comment.php?user=".$req_user_postusername['username']."'>Reply to post!</a><br><a href=\"".$_SERVER["PHP_SELF"]."?user=".$req_user_postusername['username']."&amp;del=".$req_user_postusername['comment_id']."\">Delete Comment</a></span></div></td><td width='74%' bordercolor='#000000'><table width='100%' border='0'><tr><td align='right'>".$req_user_postusername['date']."</span><span class='main'></td></tr><tr><td>".preg_replace('#(\n)#', "<br />", $req_user_postusername['comment'])."</td></tr></table></td></tr></table>
  19.  
  20.  
  21.  
  22.  
  23.  
  24. ";
  25.  
  26.  
  27.  
  28.            }  
  29.  
  30.  
____________________
My web site[/url] oh sh..!

Post July 6th, 2006, 2:46 pm

still did not work. why wont you take a look on there http://www.gothicgreenwire.com
Thanks,
Josh --DemonMaestro
www.GothicGreenWire.com
  • gisele
  • Expert
  • Expert
  • User avatar
  • Joined: Nov 11, 2004
  • Posts: 579
  • Loc: Nimes (France)
  • Status: Offline

Post July 6th, 2006, 3:04 pm

argh!
sorry it couldn't work,
I did not take you last script with $req_user_postusername['id'] :-)
I cannot test since can't login

try this :

PHP Code: [ Download ] [ Select ]
 
//...    
 
if(isset($_GET["del"]))    
 
$database->DeleteComment("del");  
 
 ?> <?php    
 
          while($req_user_postusername = mysql_fetch_array($rs_pointer))    
 
          {    
 
echo "<table width='100%' border='1' cellpadding='1' cellspacing='1' class=main>  
 
 <tr><td width='24%' align='center' valign='middle' bordercolor='#000000'><div align='center'><span class='main'><a href='userinfo.php?user=".$req_user_postusername['username']."'>".$req_user_postusername['username']."</a><br />  
 
   <br /><a href='comment.php?user=".$req_user_postusername['username']."'>Reply to post!</a><br><a href=\"".$_SERVER["PHP_SELF"]."?user=".$req_user_postusername['username']."&amp;del=".$req_user_postusername['id']."\">Delete Comment</a></span></div></td><td width='74%' bordercolor='#000000'><table width='100%' border='0'><tr><td align='right'>".$req_user_postusername['date']."</span><span class='main'></td></tr><tr><td>".preg_replace('#(\n)#', "<br />", $req_user_postusername['comment'])."</td></tr></table></td></tr></table>  
 
 
 
 
 
";  
 
 
 
           }
 
 
  1.  
  2. //...    
  3.  
  4. if(isset($_GET["del"]))    
  5.  
  6. $database->DeleteComment("del");  
  7.  
  8.  ?> <?php    
  9.  
  10.           while($req_user_postusername = mysql_fetch_array($rs_pointer))    
  11.  
  12.           {    
  13.  
  14. echo "<table width='100%' border='1' cellpadding='1' cellspacing='1' class=main>  
  15.  
  16.  <tr><td width='24%' align='center' valign='middle' bordercolor='#000000'><div align='center'><span class='main'><a href='userinfo.php?user=".$req_user_postusername['username']."'>".$req_user_postusername['username']."</a><br />  
  17.  
  18.    <br /><a href='comment.php?user=".$req_user_postusername['username']."'>Reply to post!</a><br><a href=\"".$_SERVER["PHP_SELF"]."?user=".$req_user_postusername['username']."&amp;del=".$req_user_postusername['id']."\">Delete Comment</a></span></div></td><td width='74%' bordercolor='#000000'><table width='100%' border='0'><tr><td align='right'>".$req_user_postusername['date']."</span><span class='main'></td></tr><tr><td>".preg_replace('#(\n)#', "<br />", $req_user_postusername['comment'])."</td></tr></table></td></tr></table>  
  19.  
  20.  
  21.  
  22.  
  23.  
  24. ";  
  25.  
  26.  
  27.  
  28.            }
  29.  
  30.  


by the way, you should put the user name in the url,
once it'll work you should think about session in PHP.
  • gisele
  • Expert
  • Expert
  • User avatar
  • Joined: Nov 11, 2004
  • Posts: 579
  • Loc: Nimes (France)
  • Status: Offline

Post July 6th, 2006, 3:12 pm

It's geting late here, I go to bed, I'll check this thread tomorow morning :-)

Post July 6th, 2006, 4:07 pm

here is the new code i added where you have to be loged in also but i still cant figure out why its not working.

PHP Code: [ Download ] [ Select ]
<?php //...  
 
if(isset($_GET["del"]))  
 
$database->DeleteComment("del");  
 
 ?> <?php  
 
          while($req_user_postusername = mysql_fetch_array($rs_pointer))  
 
          {  
 
echo "<table width='100%' border='1' cellpadding='1' cellspacing='1' class=main>  
 
 <tr><td width='24%' align='center' valign='middle' bordercolor='#000000'><div align='center'><span class='main'><a href='userinfo.php?user=".$req_user_postusername['username']."'>".$req_user_postusername['username']."</a><br />  
 
   <br /><a href='comment.php?user=".$req_user_postusername['username']."'>Reply to post!</a><br>";
 
   if($session->logged_in){ echo"<a href=\"".$_SERVER["PHP_SELF"]."?user=".$req_user_postusername['username']."&amp;del=".$req_user_postusername['comment_id']."\">Delete Comment</a>";}
 
   echo "</span></div></td><td width='74%' bordercolor='#000000'><table width='100%' border='0'><tr><td align='right'>".$req_user_postusername['date']."</span><span class='main'></td></tr><tr><td>".preg_replace('#(\n)#', "<br />", $req_user_postusername['comment'])."</td></tr></table></td></tr></table>";  
 
 
 
           } ?>
  1. <?php //...  
  2.  
  3. if(isset($_GET["del"]))  
  4.  
  5. $database->DeleteComment("del");  
  6.  
  7.  ?> <?php  
  8.  
  9.           while($req_user_postusername = mysql_fetch_array($rs_pointer))  
  10.  
  11.           {  
  12.  
  13. echo "<table width='100%' border='1' cellpadding='1' cellspacing='1' class=main>  
  14.  
  15.  <tr><td width='24%' align='center' valign='middle' bordercolor='#000000'><div align='center'><span class='main'><a href='userinfo.php?user=".$req_user_postusername['username']."'>".$req_user_postusername['username']."</a><br />  
  16.  
  17.    <br /><a href='comment.php?user=".$req_user_postusername['username']."'>Reply to post!</a><br>";
  18.  
  19.    if($session->logged_in){ echo"<a href=\"".$_SERVER["PHP_SELF"]."?user=".$req_user_postusername['username']."&amp;del=".$req_user_postusername['comment_id']."\">Delete Comment</a>";}
  20.  
  21.    echo "</span></div></td><td width='74%' bordercolor='#000000'><table width='100%' border='0'><tr><td align='right'>".$req_user_postusername['date']."</span><span class='main'></td></tr><tr><td>".preg_replace('#(\n)#', "<br />", $req_user_postusername['comment'])."</td></tr></table></td></tr></table>";  
  22.  
  23.  
  24.  
  25.            } ?>
  • gisele
  • Expert
  • Expert
  • User avatar
  • Joined: Nov 11, 2004
  • Posts: 579
  • Loc: Nimes (France)
  • Status: Offline

Post July 6th, 2006, 11:51 pm

noooooo !

The new code you added isn't the last corrected one ! :-)
in fact this code is wrong because it kept "del=".$data["id_comment"]." instead in "del=".$req_user_postusername["id"]."

So the right code is :

PHP Code: [ Download ] [ Select ]
 
//...    
 
if(isset($_GET["del"]))    
 
$database->DeleteComment("del");    
 
 ?> <?php    
 
          while($req_user_postusername = mysql_fetch_array($rs_pointer))    
 
          {    
 
echo "<table width='100%' border='1' cellpadding='1' cellspacing='1' class=main>    
 
 <tr><td width='24%' align='center' valign='middle' bordercolor='#000000'><div align='center'><span class='main'><a href='userinfo.php?user=".$req_user_postusername['username']."'>".$req_user_postusername['username']."</a><br />    
 
   <br /><a href='comment.php?user=".$req_user_postusername['username']."'>Reply to post!</a><br><a href=\"".$_SERVER["PHP_SELF"]."?user=".$req_user_postusername['username']."&amp;del=".$req_user_postusername['id']."\">Delete Comment</a></span></div></td><td width='74%' bordercolor='#000000'><table width='100%' border='0'><tr><td align='right'>".$req_user_postusername['date']."</span><span class='main'></td></tr><tr><td>".preg_replace('#(\n)#', "<br />", $req_user_postusername['comment'])."</td></tr></table></td></tr></table>    
 
 
 
 
 
";    
 
 
 
           }
 
 
  1.  
  2. //...    
  3.  
  4. if(isset($_GET["del"]))    
  5.  
  6. $database->DeleteComment("del");    
  7.  
  8.  ?> <?php    
  9.  
  10.           while($req_user_postusername = mysql_fetch_array($rs_pointer))    
  11.  
  12.           {    
  13.  
  14. echo "<table width='100%' border='1' cellpadding='1' cellspacing='1' class=main>    
  15.  
  16.  <tr><td width='24%' align='center' valign='middle' bordercolor='#000000'><div align='center'><span class='main'><a href='userinfo.php?user=".$req_user_postusername['username']."'>".$req_user_postusername['username']."</a><br />    
  17.  
  18.    <br /><a href='comment.php?user=".$req_user_postusername['username']."'>Reply to post!</a><br><a href=\"".$_SERVER["PHP_SELF"]."?user=".$req_user_postusername['username']."&amp;del=".$req_user_postusername['id']."\">Delete Comment</a></span></div></td><td width='74%' bordercolor='#000000'><table width='100%' border='0'><tr><td align='right'>".$req_user_postusername['date']."</span><span class='main'></td></tr><tr><td>".preg_replace('#(\n)#', "<br />", $req_user_postusername['comment'])."</td></tr></table></td></tr></table>    
  19.  
  20.  
  21.  
  22.  
  23.  
  24. ";    
  25.  
  26.  
  27.  
  28.            }
  29.  
  30.  

Post July 7th, 2006, 12:06 am

actually i fixed it and i ment to post that but for some reason you have to click the link twice to get the comment to delete..

PHP Code: [ Download ] [ Select ]
<?php //...    
 
if(isset($_GET["del"]))
 
$database->DeleteProfileComment("del");  
 
   
 
          while($req_user_postusername = mysql_fetch_array($rs_pointer))    
 
          {    
 
echo "<table width='100%' border='1' cellpadding='1' cellspacing='1' class=main>  
 
 <tr><td width='24%' align='center' valign='middle' bordercolor='#000000'><div align='center'><span class='main'><a href='userinfo.php?user=".$req_user_postusername['username']."'>".$req_user_postusername['username']."</a><br />  
 
   <br /><a href='comment.php?user=".$req_user_postusername['username']."'>Reply to post!</a><br>";
 
    if($session->logged_in){ echo"<a href=\"".$_SERVER["PHP_SELF"]."?del=".$req_user_postusername['id']."\">Delete Comment</a>";}
 
    echo "</span></div></td><td width='74%' bordercolor='#000000'><table width='100%' border='0'><tr><td align='right'>".$req_user_postusername['date']."</span><span class='main'></td></tr><tr><td>".preg_replace('#(\n)#', "<br />", $req_user_postusername['comment'])."</td></tr></table></td></tr></table>";  
 
 
 
           } ?>  
  1. <?php //...    
  2.  
  3. if(isset($_GET["del"]))
  4.  
  5. $database->DeleteProfileComment("del");  
  6.  
  7.    
  8.  
  9.           while($req_user_postusername = mysql_fetch_array($rs_pointer))    
  10.  
  11.           {    
  12.  
  13. echo "<table width='100%' border='1' cellpadding='1' cellspacing='1' class=main>  
  14.  
  15.  <tr><td width='24%' align='center' valign='middle' bordercolor='#000000'><div align='center'><span class='main'><a href='userinfo.php?user=".$req_user_postusername['username']."'>".$req_user_postusername['username']."</a><br />  
  16.  
  17.    <br /><a href='comment.php?user=".$req_user_postusername['username']."'>Reply to post!</a><br>";
  18.  
  19.     if($session->logged_in){ echo"<a href=\"".$_SERVER["PHP_SELF"]."?del=".$req_user_postusername['id']."\">Delete Comment</a>";}
  20.  
  21.     echo "</span></div></td><td width='74%' bordercolor='#000000'><table width='100%' border='0'><tr><td align='right'>".$req_user_postusername['date']."</span><span class='main'></td></tr><tr><td>".preg_replace('#(\n)#', "<br />", $req_user_postusername['comment'])."</td></tr></table></td></tr></table>";  
  22.  
  23.  
  24.  
  25.            } ?>  
  • gisele
  • Expert
  • Expert
  • User avatar
  • Joined: Nov 11, 2004
  • Posts: 579
  • Loc: Nimes (France)
  • Status: Offline

Post July 7th, 2006, 1:26 am

No in fact that works but the delete function call is between the comment querying stuff and the comments displaying stuff.

SO when you retrived the comments, the delete hasn't been done yet.
And when you click for the second time, the delete stuff was done thow the delete comment is still displayed.

Well in fact I don't know if you get what I try to explain, but anyway you just have to move :

PHP Code: [ Download ] [ Select ]
 
if(isset($_GET["del"]))  
 
$database->DeleteProfileComment("del");
 
 
  1.  
  2. if(isset($_GET["del"]))  
  3.  
  4. $database->DeleteProfileComment("del");
  5.  
  6.  

just before
PHP Code: [ Download ] [ Select ]
 
$rs_pointer = $database->getUserComments($req_user);
 
 
  1.  
  2. $rs_pointer = $database->getUserComments($req_user);
  3.  
  4.  


so that the delete stuff is called before the query that retrieves the comments ;-)

did you get that?

Post July 7th, 2006, 10:11 am

it is befor it no?

PHP Code: [ Download ] [ Select ]
<?php //...    
 
if(isset($_GET["del"]))  
 
$database->DeleteProfileComment("del");    
 
   
 
          while($req_user_postusername = mysql_fetch_array($rs_pointer))    
 
          {    
 
echo "<table width='100%' border='1' cellpadding='1' cellspacing='1' class=main>    
 
 <tr><td width='24%' align='center' valign='middle' bordercolor='#000000'><div align='center'><span class='main'><a href='userinfo.php?user=".$req_user_postusername['username']."'>".$req_user_postusername['username']."</a><br />    
 
   <br /><a href='comment.php?user=".$req_user_postusername['username']."'>Reply to post!</a><br>";  
 
    if($session->logged_in){ echo"<a href=\"".$_SERVER["PHP_SELF"]."?del=".$req_user_postusername['id']."\">Delete Comment</a>";}  
 
    echo "</span></div></td><td width='74%' bordercolor='#000000'><table width='100%' border='0'><tr><td align='right'>".$req_user_postusername['date']."</span><span class='main'></td></tr><tr><td>".preg_replace('#(\n)#', "<br />", $req_user_postusername['comment'])."</td></tr></table></td></tr></table>";    
 
 
 
           } ?>
  1. <?php //...    
  2.  
  3. if(isset($_GET["del"]))  
  4.  
  5. $database->DeleteProfileComment("del");    
  6.  
  7.    
  8.  
  9.           while($req_user_postusername = mysql_fetch_array($rs_pointer))    
  10.  
  11.           {    
  12.  
  13. echo "<table width='100%' border='1' cellpadding='1' cellspacing='1' class=main>    
  14.  
  15.  <tr><td width='24%' align='center' valign='middle' bordercolor='#000000'><div align='center'><span class='main'><a href='userinfo.php?user=".$req_user_postusername['username']."'>".$req_user_postusername['username']."</a><br />    
  16.  
  17.    <br /><a href='comment.php?user=".$req_user_postusername['username']."'>Reply to post!</a><br>";  
  18.  
  19.     if($session->logged_in){ echo"<a href=\"".$_SERVER["PHP_SELF"]."?del=".$req_user_postusername['id']."\">Delete Comment</a>";}  
  20.  
  21.     echo "</span></div></td><td width='74%' bordercolor='#000000'><table width='100%' border='0'><tr><td align='right'>".$req_user_postusername['date']."</span><span class='main'></td></tr><tr><td>".preg_replace('#(\n)#', "<br />", $req_user_postusername['comment'])."</td></tr></table></td></tr></table>";    
  22.  
  23.  
  24.  
  25.            } ?>
  • gisele
  • Expert
  • Expert
  • User avatar
  • Joined: Nov 11, 2004
  • Posts: 579
  • Loc: Nimes (France)
  • Status: Offline

Post July 8th, 2006, 5:37 am

HI,

not at all, like it is, when you call the comment delete function, the query to retrieve the comments has been yet submitted with :
$rs_pointer = $database->getUserComments($req_user);

and while($req_user_postusername = mysql_fetch_array($rs_pointer)) ...etc. is nothing but a loop that browse the yet built up results set.

so this is like you should order the statments :


PHP Code: [ Download ] [ Select ]
 
//first comment delete stuff :
 
if(isset($_GET["del"]))  
 
   $database->DeleteProfileComment("del");
 
//then querying the comments in the database :  
 
$rs_pointer = $database->getUserComments($req_user);
 
 
  1.  
  2. //first comment delete stuff :
  3.  
  4. if(isset($_GET["del"]))  
  5.  
  6.    $database->DeleteProfileComment("del");
  7.  
  8. //then querying the comments in the database :  
  9.  
  10. $rs_pointer = $database->getUserComments($req_user);
  11.  
  12.  


and then you can do the displaying stuff ( links and comments )


If you're not sure, just show all the entire comment script and I'll do the changes.

Post July 8th, 2006, 6:49 am

so basically you are telling me to take out while($req_user_postusername = mysql_fetch_array($rs_pointer))?
Thanks,
Josh --DemonMaestro
www.GothicGreenWire.com
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post July 8th, 2006, 6:49 am

Post Information

  • Total Posts in this topic: 97 posts
  • Users browsing this forum: No registered users and 236 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 2010 Unmelted, LLC. Driven by phpBB © 2010 phpBB Group.