bullbreed Posted February 5, 2010 Share Posted February 5, 2010 Im trying to learn php my developing a CMS (I know, what a mad man I hear you say) I have a page where you can add the data for your webpage but now I want to edit the info. So I created a page that calls all the pages up in to a table on x-screen with an edit link at the end. I want to edit the Home page. Here is the table on screen; Page Name-----------------Action Home--------------------------Edit (Link) About US-----------------------Edit (Link) When you click on the Edit (Link) for the Home page you go to this Url - editpage.php?p=Home I want the form fields on this page to be populated with the info from the database related to the Home page. What value do I put in to the form fields to call the info related to the Url ?p=Home. So lets say its the page name form field I want to edit. I want it to do something like Echo the value from the page_name column in the database relative to the Home page in the URL. I hope I make sense Regards Link to comment https://forums.phpfreaks.com/topic/191051-populate-form-fields-from-database/ Share on other sites More sharing options...
Ty44ler Posted February 5, 2010 Share Posted February 5, 2010 You would first run a query for whatever you wanted to pull from the database and set it to a variable. Example: $result = mysql_query("SELECT * FROM table WHERE pagename = 'home'"); while ($row = mysql_fetch_array($result)) { $fieldyouwant=$row["fieldyouwant"]; } Then to call it in your form you just echo it out. <input type="text" value="<? echo $fieldyouwant; ?>" name="fieldname" /> Link to comment https://forums.phpfreaks.com/topic/191051-populate-form-fields-from-database/#findComment-1007420 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.