Clarkie Posted August 30, 2011 Share Posted August 30, 2011 Hey, I'm trying to work out how I can have a simple script that will work like this: Page 1 - Heading, Paragraph, Image read from database. Page 2 - Has text boxes allowing you to change heading, paragraph and image (url) with each edit using a different text box. (Admin panel) The database connection would be in a separate file. So far I've got the database connection sorted. <?php //Database Information $dbtype = "mysql"; $db_host = "localhost"; $db_user = ""; $db_pass = ""; $db_name = ""; $db_port = ""; $db_table_prefix = "userCake_"; ?> At the top of each of the other pages this is what I've got. <?php require_once("models/config.php"); ?> Let's say I give each bit stored in the database a page ID and an object ID. If the page selected is index.php how can we give it a page ID of 1 and give then include all the separate 'objects' throughout the page? Hopefully this makes sense? Cheers, Jack Quote Link to comment https://forums.phpfreaks.com/topic/246049-reading-and-writing-to-database-should-be-simple/ Share on other sites More sharing options...
the182guy Posted August 30, 2011 Share Posted August 30, 2011 Sounds like you need one script to display the page which shows the heading, image and paragraph. Have the script accept a pageID in the querystring ($_GET). Then a separate page for the admin, which again takes a pageID and populates the textboxes ready to edit. Use the $_GET['pageID'] to select the record from the database. What about a table in the db with fields: id, heading, image, paragraph. Quote Link to comment https://forums.phpfreaks.com/topic/246049-reading-and-writing-to-database-should-be-simple/#findComment-1263648 Share on other sites More sharing options...
Clarkie Posted August 30, 2011 Author Share Posted August 30, 2011 In the database I'll have 1 table setup like this: page id | object id | data 1 | 1 | heading name 1 | 2 | paragraph text Etc. Will take a look at how to use $_GET tomorrow. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/246049-reading-and-writing-to-database-should-be-simple/#findComment-1263678 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.