Jump to content

Simple Admin Panel


shujjah

Recommended Posts

Alright since the premade one wasnt working I decided to make my own a very basic comments admin panel here is the code

<html><head><title>Comments Admin Panel</title></head><body><?php$con = mysql_connect("localhost","root","");if (!$con)  {  die('Could not connect: ' . mysql_error());  }mysql_select_db("gamecms", $con);$result = mysql_query("SELECT newsId, subject FROM gamecms_news WHERE deleted='0' ORDER BY timestamp DESC");while($row = mysql_fetch_array($result))  {?><select name="newsId"><option value="<?php echo $row['newsId'] ?>"><?php echo $row['subject'] ?></option></select><?php  }mysql_close($con);?></body></html>

Now the code works but the problem is this is how it appears comment1.jpgwhereas I want to be a single dropdown menu like all the news in a single drop down menu not a separate one for each newsand after this for the comments to appear I guess I will use the Post option to send the value of newsid to the next page and will select the comments where newsid will be the posted news id right ?

Link to comment
Share on other sites

Alright thankfully it works, the panel deletes the comments and I have done it through 3 filescomments.php

<html><head><title>Comments Admin Panel</title></head><body><?php$con = mysql_connect("localhost","root","");if (!$con)  {  die('Could not connect: ' . mysql_error());  }mysql_select_db("gamecms", $con);$result = mysql_query("SELECT newsId, subject FROM gamecms_news WHERE deleted='0' ORDER BY timestamp DESC");?><form method="post" action="comments2.php"><select name="newsId"><?phpwhile($row = mysql_fetch_array($result))  {?><option value="<?php echo $row['newsId'] ?>"><?php echo $row['subject'] ?></option><?php  }?></select> <input type='submit' value='Select News'/></form><?phpmysql_close($con);?></body></html>

comments2.php

<html><head><title>Comments Admin Panel(Select Comment)</title></head><body><?php$id = $_POST['newsId'];$con = mysql_connect("localhost","root","");if (!$con)  {  die('Could not connect: ' . mysql_error());  }mysql_select_db("gamecms", $con);$result = mysql_query("SELECT commentId, comment, userName FROM gamecms_comment WHERE assetId = '$id' AND section ='news' AND deleted='0' ORDER BY timestamp DESC");?><form method="post" action="comments3.php"><select name="commentsId"><?phpwhile($row = mysql_fetch_array($result))  {?><option value="<?php echo $row['commentId'] ?>"><?php echo $row['userName'] .POSTED. $row['comment'] ?></option><?php  }?></select> <input type='submit' value='Select Comment'/></form><?phpmysql_close($con);?></body></html>

Now I want to add a few spaces between username and the comment currently I have put POSTED in between them but I want a few spaces between them so how to add thoseand this is the comments3.php

<html><head><title>Comments Admin Panel(Deleting Comment)</title></head><body><?php$id = $_POST['commentsId'];$con = mysql_connect("localhost","root","");if (!$con)  {  die('Could not connect: ' . mysql_error());  }mysql_select_db("gamecms", $con);mysql_query("DELETE FROM gamecms_comment WHERE commentId='$id'");echo "Comment successfully deleted";mysql_close($con);?></body></html>

And this is very very simple and is done through 3 files is there a way so that I can do all this with only 1 or 2 files otherwise if not then I am ok with this also.Best Regards,

Link to comment
Share on other sites

Now I want to add a few spaces between username and the comment currently I have put POSTED in between them but I want a few spaces between them so how to add those
..replace POSTED with a few spaces, am I missing something?
And this is very very simple and is done through 3 files is there a way so that I can do all this with only 1 or 2 files otherwise if not then I am ok with this also.
There's a post about how to process multiple forms with a page here:http://w3schools.invisionzone.com/index.ph...ost&p=96606
Link to comment
Share on other sites

<option value="<?php echo $row['commentId'] ?>"><?php echo $row['userName']			.		  $row['comment'] ?></option>

tried the above code doesnt work still no space and also tried   it gives a syntax error in that case

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...