Jump to content

Just need help..


Mod-Jay

Recommended Posts

Error:

No error, Having Trouble Making My Blod Editer.. Do what You can Please..

 

Code:

<?php
if(isset($_GET['action']) && $_GET['action'] == 'edit') {
echo "
<hr><center><h1>Editing News $name</h1>
<form action='news.php?action=edit123' method='POST'>
Your News Name:<br>
<input id='name' type='text' name='name' autocomplete='off' maxlength='25'><br>Your News Description: <br>
<textarea name='descrr' id='descrr' rows='3' cols='60' maxlength='250'> </textarea><br>
<input type='submit' name='submit' value='Add News'>
</form></center><hr>
";
}
?>
<?php
if(isset($_GET['action']) && $_GET['action'] == 'edit123') {
  if( isset($_GET['id']) && is_numeric($_GET['id']))
  {
    $id = (int) $_GET['id'];
    mysql_query("UPDATE blog SET name=name WHERE descr=$descrr") or die(mysql_error());
    echo "News: $name Updated";
  }
   else
  {
     echo "Name is Empty";
  }
}
?>

 

LOL @ Thorpe, Yea i do. I Need to Make Edit123 update the One Selected, And "Editing News $name" Have the One Selected, Thanks in Advanced. Once I have the Things i asked for . Im Good.

Link to comment
Share on other sites

I just put together a quick simple code.. It might not be secure or anything, but it works I think. You might need to edit it a little.

You'll prob have to edit the part that is like

news.php?action=edit&id=<?php echo $list_b['id'];?>

On line 16.

<?php
if($_GET['action'] == 'edit') {
$id="{$_GET['id']}";

if ($list_q = mysql_query("SELECT * FROM blog WHERE ID='$id'")) {
  if (mysql_num_rows($list_q)) {
    while($list_b=mysql_fetch_array($list_q)) 
    {

	if(empty($C_Error) and !empty($_POST['Submit'])) {

	mysql_query("UPDATE toplist SET name='". realEscape($_POST['name']) ."', descr='". realEscape($_POST['descr']) ."' WHERE id=$id") or die(mysql_error());
	echo 'News Updated';
}
?>
<form action="news.php?action=edit&id=<?php echo $list_b['id'];?>" method="post">
<strong>Name:</strong>
<input type="text" class="textbox" name="name" maxlength="25" size="25" value="<?php echo $list_b['name'];?>" />
<strong>Content:</strong>
<textarea name="descr" rows="10" cols="50%" maxlength="10000"><?php echo $list_b['descr'];?></textarea>
<input type="submit" class="button" name="Submit" value="Edit News" />
</form>
<?php
}}}}
?>
<?php
if($_GET['action'] == 'delete') {
$id="{$_GET['id']}";
mysql_query("Delete * from blog WHERE id=$id") or die(mysql_error());
echo 'News Deleted';
}
?>

 

State: Untested

Link to comment
Share on other sites

The following should be placed outside of the while loop.

if(empty($C_Error) and !empty($_POST['Submit'])) {

	mysql_query("UPDATE toplist SET name='". realEscape($_POST['name']) ."', descr='". realEscape($_POST['descr']) ."' WHERE id=$id") or die(mysql_error());
	echo 'News Updated';
}

Link to comment
Share on other sites

The following should be placed outside of the while loop.

if(empty($C_Error) and !empty($_POST['Submit'])) {

	mysql_query("UPDATE toplist SET name='". realEscape($_POST['name']) ."', descr='". realEscape($_POST['descr']) ."' WHERE id=$id") or die(mysql_error());
	echo 'News Updated';
}

Oops, thanks for that correction. I just wrote this up in like 2 mins, and was going fast.

Link to comment
Share on other sites

Error:

The edit is supposed to add the updated into the database, but it dont add... Help please

 

Code:

<?php
if(isset($_GET['action']) && $_GET['action'] == 'edit') {
$id="{$_GET['id']}";

if ($list_q = mysql_query("SELECT * FROM blog WHERE ID='$id'")) {
  if (mysql_num_rows($list_q)) {
    while($list_b=mysql_fetch_array($list_q)) 
    {
if(empty($C_Error) and !empty($_POST['Submit'])) {
mysql_query("UPDATE blog SET name='". realEscape($_POST['name']) ."', descr='". realEscape($_POST['descr']) ."' WHERE id=$id") or die(mysql_error());
echo 'News Updated';
}
?><hr><center>
<form action="news.php?action=edit&id=<?php echo $list_b['id'];?>" method="post">
Name:<br>
<input type="text" class="textbox" name="name" maxlength="25" size="25" value="<?php echo $list_b['name'];?>" /><br>
Content:<br>
<textarea name="descr" rows="5" cols="60" maxlength="10000"><?php echo $list_b['descr'];?></textarea><br>
<input type="submit" class="button" name="Submit" value="Edit News" />
</form></center>
<?php
}}}}
?>

Link to comment
Share on other sites

 

Error:

No error, IT dont loop, Idk why.. help please

 

Code:

<?php

$rr = mysql_query("SELECT * FROM news");
while($r = mysql_fetch_array($rr))
{
$name1=$r["name"];
$desr=$r["desr"];
$link1=$r["link"];
$date1=$r["date"];
$datem1=$r["datem"];
}
echo "
                            <div class='cs_article'>
                            	
                                <div class='left'>
                                    <h2>$name1</h2>
                                    <p>$desr</p>
                                    
                                    <div class='button'><a href='$link1'>Read more</a></div>
                               	</div>
                                <div class='right'>
							<h1>$name1</h1>
							</div>
                                                                
                            </div>
";
?>

Link to comment
Share on other sites

Mod-Jay. You really need to step back a little and learn some basics. Coming to a board and asking for help with every simple little problem isn't going to get you anywhere fast.

 

Theres a good free book in my signature (Hudzilla) that should get you started.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.