Jump to content


Photo

News-Edit Issues


  • Please log in to reply
2 replies to this topic

#1 Guteman

Guteman
  • Members
  • PipPipPip
  • Advanced Member
  • 39 posts
  • LocationWisconsin

Posted 08 March 2006 - 08:12 PM

Alright guys, here is my issue. I cannot get [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]<a href='edit.php?cmd=edit&id=$id'>[/quote] to work properly. Specificly the $id part. Its not seeing the id in the news through the sql. I know the rest of this works because I can enter an id number after the link and it works. So its gotta be that variable. Can you please help me out?


[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]<?

include("config.php");


//If cmd has not been initialized
if(!isset($cmd))
{
//display all the news
$result = mysql_query("select * from news order by id");

//run the while loop that grabs all the news scripts
while($r=mysql_fetch_array($result))
{
//grab the title and the ID of the news
$title=$r["title"];//take out the title
$id=$r["id"];//take out the id

//make the title a link
echo "<a href='edit.php?cmd=edit&id=$id'>$title - Edit</a>";
echo "<br>";
}
}
?>
<?
if($_GET["cmd"]=="edit" || $_POST["cmd"]=="edit")
{
if (!isset($_POST["submit"]))
{
$id = $_GET["id"];
$sql = "SELECT * FROM news WHERE id=$id";
$result = mysql_query($sql);
$myrow = mysql_fetch_array($result);
?>

<form action="edit.php" method="post">
<input type=hidden name="id" value="<?php echo $myrow["id"] ?>">

Title:<INPUT TYPE="TEXT" NAME="title" VALUE="<?php echo $myrow["title"] ?>" SIZE=30><br>
Message:<TEXTAREA NAME="message" ROWS=10 COLS=30><? echo $myrow["message"] ?></TEXTAREA><br>
Who:<INPUT TYPE="TEXT" NAME="who" VALUE="<?php echo $myrow["who"] ?>" SIZE=30><br>

<input type="hidden" name="cmd" value="edit">

<input type="submit" name="submit" value="submit">

</form>

<? } ?>
<?
if ($_POST["$submit"])
{
$title = $_POST["title"];
$message = $_POST["message"];
$who = $_POST["who"];

$sql = "UPDATE news SET title='$title',message='$message',who='$who' WHERE id=$id";
//replace news with your table name above
$result = mysql_query($sql);
echo "Thank you! Information updated.";
}
}
?>[/quote]

#2 keeB

keeB
  • Staff Alumni
  • Advanced Member
  • 1,078 posts
  • LocationCalifornia

Posted 08 March 2006 - 08:45 PM

[!--quoteo(post=352957:date=Mar 8 2006, 08:12 PM:name=Guteman)--][div class=\'quotetop\']QUOTE(Guteman @ Mar 8 2006, 08:12 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
Alright guys, here is my issue. I cannot get to work properly. Specificly the $id part. Its not seeing the id in the news through the sql. I know the rest of this works because I can enter an id number after the link and it works. So its gotta be that variable. Can you please help me out?
[/quote]

echo "<a href=\"edit.php?cmd=edit&id=$id\">$title - Edit</a>";

the single quotes weren't evaluating $id.

Come visit my site to see my latest projects
http://nick.stinemates.org/wordpress/


#3 Guteman

Guteman
  • Members
  • PipPipPip
  • Advanced Member
  • 39 posts
  • LocationWisconsin

Posted 08 March 2006 - 09:07 PM

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]echo "<a href=\"edit.php?cmd=edit&id=$id\">$title - Edit</a>";[/quote]

Still doesnt seem to work. Same problem




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users