anon_php Posted July 27, 2016 Share Posted July 27, 2016 I am creating a scheduling webpage where users can schedule meetings in a calendar, and have just gotten to writing the backend. The front end is basically complete, and I have created a database for it, but I am not sure how/where my HTML and PHP should interact. Currently, I have an html file (my index) and 3 javascript files that help with some dynamic features on my page. I know the code I need to INSERT, RETRIEVE, UPDATE, and DELETE from my database using PHP, but I am not sure WHERE this should go? Should I have a separate php file with functions I call from my HTML file? For example, if I want to update a table with a meeting time and meeting description, should I make a function in a database.php file: function updateMeeting(meetingTime, meetingDescription) { ..... } and call database.updateMeeting(meetingTimeData, meetingDescriptionData); from my HTML file? Or should I put all my HTML information into a php file and just intersperse snippets of php to manipulate the database? Basically: Where do I put the php code to work with my database for my webpage? I understand I am a beginner and may have some false assumptions even in my question, so please bear with me! Thank you Quote Link to comment https://forums.phpfreaks.com/topic/301663-beginning-web-designer-seeking-help-on-some-htmlphp-fundamentals/ Share on other sites More sharing options...
lovephp Posted July 27, 2016 Share Posted July 27, 2016 post something you tried then we help u how to do it Quote Link to comment https://forums.phpfreaks.com/topic/301663-beginning-web-designer-seeking-help-on-some-htmlphp-fundamentals/#findComment-1535195 Share on other sites More sharing options...
NotionCommotion Posted July 28, 2016 Share Posted July 28, 2016 Create a file called index.php. In it, include something like: $task=empty($_GET['task'])?'display':$_GET['task']; switch($task) { case 'display': /* Get data from your database. Pass the data to your view. Use a proper template system for your view such as http://twig.sensiolabs.org/ to render a template. Your template should include links to your JS files. */ break; case 'update_something': //do something break; default: //Do the same as display Quote Link to comment https://forums.phpfreaks.com/topic/301663-beginning-web-designer-seeking-help-on-some-htmlphp-fundamentals/#findComment-1535203 Share on other sites More sharing options...
lovephp Posted July 28, 2016 Share Posted July 28, 2016 (edited) and what is the issue you are facing exactly with those codes? inside the case whichever way you wish you can insert update or delete data from db. be it through calling a function or straight away but make sure u define id related to your post. Edited July 28, 2016 by lovephp Quote Link to comment https://forums.phpfreaks.com/topic/301663-beginning-web-designer-seeking-help-on-some-htmlphp-fundamentals/#findComment-1535210 Share on other sites More sharing options...
ginerjm Posted July 28, 2016 Share Posted July 28, 2016 I call from my HTML file?When you refer to a "html file" what exactly do you mean? Is it a file with a name ending in .html? Or is it a file that only has HTML code in it? Either way - unless you have configured your server to parse HTML extensions no code in that file can "call" anything. Quote Link to comment https://forums.phpfreaks.com/topic/301663-beginning-web-designer-seeking-help-on-some-htmlphp-fundamentals/#findComment-1535229 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.