Jump to content

Updating a query on one page, from another?


hodgey87

Recommended Posts

Hey Guys,

 

Ive been searching for a while, but havent really come up with any answers.

 

At the minute i have a page where i can add a new topic to a database, but i want to be able to update the query on another page if that makes sense  :-\

 

So as an example say i have this below thats just been inserted into the database with an ID of 2.

 

<?php

// Details
$id = $_POST['id'];
$title = $_POST['title'];
$detail = $_POST['detail'];

mysql_connect("localhost", "web148", "123") or die(mysql_error());
mysql_select_db("web148") or die(mysql_error());

mysql_query("SET names 'utf8'");
mysql_query("INSERT into sunnyargues(ID, title, body) VALUES ('2', ''超级马里奥意大利再遭种族歧视', '当被问及在友谊赛上的不友好一幕会不会重演时,曼奇尼说,“有这种可能性。” “我当然不希望这样的事情发生,但是谁也不能保证。”'");
echo "<h1>Article Updated!</h1>";

?>

 

On the sunny argues page i currently have, where it only selects ID 1:

 

<?php

mysql_connect("localhost", "web148", "123") or die(mysql_error());
mysql_select_db("web148") or die(mysql_error());
mysql_query("SET names 'utf8'");
$result = mysql_query("SELECT body FROM sunnyargues WHERE ID='1'");
$row = mysql_fetch_array( $result );
echo nl2br($row['body']);
?>

 

Is there a way i can update this query with the new ID of the 2nd article once its been inserted into the database.

 

I hope that makes sense  :P

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.