lordbux Posted August 26, 2008 Share Posted August 26, 2008 hi friends i am a newbie to php and need a bit of help to create a small forum that can report and derive data from a mysql database ============================== i need 2 text boxes TEXTBOX1= Roll Number TEXTBOX2= Name and 2 buttons BUTTON1= Add BUTTON2= Show ================================ When BUTTON1 is clicked, the values in TEXTBOX1 & TEXTBOX2 Should be submitted to a table (any name) in database. When BUTTON2 is clicked after providing a value in TEXTBOX2 - TEXTBOX1 should show a NAME from the database where Roll=TEXTBOX2 from the database. here is the database details ================= dbname= tonks usrname= root password= behind Host= localhost ------------------------------------ plas give an example code that can do this thanks in advance Link to comment https://forums.phpfreaks.com/topic/121424-how-tocreate-a-forum-that-repost-to-database/ Share on other sites More sharing options...
trq Posted August 26, 2008 Share Posted August 26, 2008 Were not here to write code for you. Which is what we would essentually be doing if we posted an entire example. Id suggest you learn the basics, try to write this yourself, then post your code if you have a problem. Link to comment https://forums.phpfreaks.com/topic/121424-how-tocreate-a-forum-that-repost-to-database/#findComment-626139 Share on other sites More sharing options...
lordbux Posted August 27, 2008 Author Share Posted August 27, 2008 am sorry for making it feel like a request to reduce my work actually what i meant by example was all that i need an example for the sql query comand for inserting the data pls help me once again sorry Link to comment https://forums.phpfreaks.com/topic/121424-how-tocreate-a-forum-that-repost-to-database/#findComment-626728 Share on other sites More sharing options...
Fadion Posted August 27, 2008 Share Posted August 27, 2008 Basic example of a user post: <?php session_start(); if(isset($_POST['msg'])){ $msg = mysql_real_escape_string(htmlentities($_POST['msg'])); $user_id = $_SESSION['user']; $thread_id = mysql_real_escape_string($_GET['id']); $results = mysql_query("INSERT INTO posts (thread_id, message, user_id) VALUES ('$thread_id', '$msg', '$user_id')"); echo 'Your message was posted successfully'; } ?> Basic example of showing the thread: <?php $thread = mysql_real_escape_string($_GET['id']); $results = mysql_query("SELECT pos.message, us.username FROM posts pos INNER JOIN users us ON pos.user_id=us.id WHERE pos.thread_id=$thread") or die(); while($values = mysql_fetch_array($results)){ echo 'Username: ' . $values['username'] . '<br />'; echo 'Message: ' . $values['message'] . '<br /><br />'; } ?> That's the basic idea of what you're in. Link to comment https://forums.phpfreaks.com/topic/121424-how-tocreate-a-forum-that-repost-to-database/#findComment-626732 Share on other sites More sharing options...
lordbux Posted August 29, 2008 Author Share Posted August 29, 2008 thanks a lot guiltygear u saved me Link to comment https://forums.phpfreaks.com/topic/121424-how-tocreate-a-forum-that-repost-to-database/#findComment-628576 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.