Jump to content

Transfer information from MySQL to new form??


JackW
 Share

Recommended Posts

I am setting up a new site, using PHP/MySQL that contains a database for user comments.The data base is set up and the form posts to the data base. I have a form that retrieves the information from the data base (this is similar to a private mail box). Up to this point everything works as required. The retrieved information contains the original posters user name (s) and comment (s) heading (s). What I need now is a form that will let a second user post to the same data base in reply to the first user. The second form needs to have the previous user name and comment heading filled in from the page they are viewing. I set it up so the first user name is a link to a new form and it post to the data base just like I want it to. But I have to type in the first users name and heading, how do I get the required user name and heading to be on that new form when it opens?

Link to comment
Share on other sites

If someone replies to a certain post, you probably want to get the information about that first post from the database and fill things in on the reply, am I understanding that correctly? All you need to know is what post they are replying to, and you can look the information up. Also, it's better not to save the same user name and heading in the reply, instead just save an ID number for whatever post it is in reply to, and then when you are displaying the new post you can also look up the information for the previous post and just display it on the page, but it will be better if you don't store the duplicate name and heading in the database.

Link to comment
Share on other sites

If someone replies to a certain post, you probably want to get the information about that first post from the database and fill things in on the reply, am I understanding that correctly?
Yes that is what I want to do.Your reply contains much good and useful information, you are right, and I appreciate the help.Now I have the post ID but how do I get it to the next page so I can look up the associated infromation. What I am trying to do is probably one of those duh things. If I wanted to do the same thing in an email form I would just add ?subject= Is there a way to pass information to the next page similar to that?
Link to comment
Share on other sites

yes... yourpage.php?variable=value for passing one variable and yourpage.php?variable1=value&variable2=value for passing multiple varaibles.You would then get the values in php like this

$var1 = $_POST['variable1'];$var2 = $_POST['variable2'];

Link to comment
Share on other sites

yes... yourpage.php?variable=value for passing one variable and yourpage.php?variable1=value&variable2=value for passing multiple varaibles.You would then get the values in php like this
$var1 = $_POST['variable1'];$var2 = $_POST['variable2'];

The light bulb has a slight glow. I may be starting to understand. I’ll try it this PM and let you know what happens.Thank you.
Link to comment
Share on other sites

yes... yourpage.php?variable=value for passing one variable and yourpage.php?variable1=value&variable2=value for passing multiple varaibles.You would then get the values in php like this
$var1 = $_POST['variable1'];$var2 = $_POST['variable2'];

Oops!
$var1 = $_GET['variable1'];$var2 = $_GET['variable2'];

Jack, the $_GET array stores everything passed through the URL, and the $_POST array stores everything submitted through a form.

Link to comment
Share on other sites

I think I have another duh question. Here is my code: :)Never mind I found the answer. It is at the bottom if someone else wants to know.// open data base@ $db = mysql_pconnect('someserver.net', 'somedatabase', ' My password');mysql_select_db('somedatabase1') or die( "Unable to select database");//fetch Row ID number$var1 = $_GET['variable1'];echo $var1;{$query= 'SELECT * FROM `sometable` WHERE `ID` LIKE ?? LIMIT 0, 5 ';$query_results=mysql_query($query);$match_results=mysql_num_rows($query_results);}for ($i=0; $i < $match_results; $i++){$row=mysql_fetch_array($query_results);echo ($row ['body'] ); }mysql_close($db);The variable I want is being transferred and it shows up at echo $var1 just fine. How do I get it to be where the ?? is in:$query= 'SELECT * FROM `sometable` WHERE `ID` LIKE ?? LIMIT 0, 5 ';Everything I have tried has presented me with an error message.If I replace the ?? with the ID number I do get the results I want.Never mind :) I found the answer.$query="SELECT * FROM `sometable` WHERE `ID`='$var1' LIMIT 0, 5";

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...