sofinho Posted May 21, 2008 Share Posted May 21, 2008 hello e.o I'm a web layout designer, creative and open minded to web design, i know much about html, flash, coding css and much more ... i know a little about PHP & MySql, let me exmplain what i know, well i can install and configure mysql, apache and php ... i can work good with web scripts which are already made ... but my question is that, lets say i have designed a layout in photoshop and sliced it and everything is done but i want to code it with php, mysql and apache .. how would i do that ? how do i add php functions to my website and how do i display pages like " news.php?id=1802 " because the site am planning to do will be updated every day ... so if some one could help it will be so greatfull. thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/106601-pro-weblayout-designer-need-help-with-php/ Share on other sites More sharing options...
MadTechie Posted May 21, 2008 Share Posted May 21, 2008 okay first thing.. PHP is server side scripting.. this means you can call a function like you would in JS, if you need to do that your need JS to interact with php via a get/post request (see AJAX) now to use the URL ie index.php?page=home you could do this <?php $page = (!empty($_GET['page']))?strtolower($_GET['page']):""; switch($page) { default: case "home": include "home.php"; break; case "contact": include "contact.php"; break; case "about": include "about.php"; break; } ?> what the above does is get the page from the URL ie home; then we convert to lowercase (makes life easier), then we could use alot of if's but i'm going to use switch, it then checks if page = home, contact or about, then includes that page ie home.php i could do this $page = (!empty($_GET['page']))?strtolower($_GET['page']):"home"; include "$page.php"; but that gives too much control away (secuirty risk) i hope that helps you get started Quote Link to comment https://forums.phpfreaks.com/topic/106601-pro-weblayout-designer-need-help-with-php/#findComment-546367 Share on other sites More sharing options...
sofinho Posted May 21, 2008 Author Share Posted May 21, 2008 chers mate, its a good start .. to be honest with you am still quiet confused .. okay, i have got the code you wrote but how will it benifit my site layout, how am i going to code my page with a design view ? let say this is one of my weblayouts: http://99designs.com/contests/7110/entries/468263.png how should i cod eit with php/mysql ? Quote Link to comment https://forums.phpfreaks.com/topic/106601-pro-weblayout-designer-need-help-with-php/#findComment-546377 Share on other sites More sharing options...
MadTechie Posted May 21, 2008 Share Posted May 21, 2008 well as i said php is server side, so your more likely to use it with forms heres a nice starting point http://www.w3schools.com/PHP/default.asp forms http://www.w3schools.com/PHP/php_forms.asp then read the PHP Database from that point to should get the good basic idea, just remember php is more for the use of data then look and feel of it, i would recommend that you get phpmyadmin aka PMA (a web based mysql tool), use PMA to create a database and a table with a few fields first name, last name etc, then build a basic form and with the same data name, last name etc, and get that data to be INSERTed into the table after that write another page to list all records and build up from their Quote Link to comment https://forums.phpfreaks.com/topic/106601-pro-weblayout-designer-need-help-with-php/#findComment-546385 Share on other sites More sharing options...
DyslexicDog Posted May 21, 2008 Share Posted May 21, 2008 hello e.o I'm a web layout designer, creative and open minded to web design, i know much about html, flash, coding css and much more ... i know a little about PHP & MySql, let me exmplain what i know, well i can install and configure mysql, apache and php ... i can work good with web scripts which are already made ... but my question is that, lets say i have designed a layout in photoshop and sliced it and everything is done but i want to code it with php, mysql and apache .. how would i do that ? how do i add php functions to my website and how do i display pages like " news.php?id=1802 " because the site am planning to do will be updated every day ... so if some one could help it will be so greatfull. thanks in advance The basic idea is to create a layout or template that your site is based on. For a site that's being updated every day it's much easier to pull that information from a database then it is to recreate news html page every day. Once you have the template, you use php to fill in the content. Say I have a blog, when I create a new post on that blog I would want to save that information to a database. The table in the database may be as simple as three columns or fields; ID to keep track of the blog posts, title so I know what I called my post, and then content the actual meat of the article. Now I would use php to get that information from the database. Web servers accept variables as part of the URL i.e. http://www.foo.com/index.php?bar=foobar When you visit a site as a client your request things. In the above URL I'm requesting the index.php page from the www server at foo.com, but in the URL I'm also passing a GET variable to the server. The PHP processor can read that GET variable from what's known as a super global variable <?php echo $_GET['bar']; ?> The above code would display only foobar for this example. $_GET is the superglobal, bar is the name of the array member, foobar is the value. So if I had a blog and I wanted to display a single article I might have my code check for the existence of $_GET variable. If that variable exists then I would extract the information from the database and display it in the content area of my website. i.e. http://www.foo.com/index.php?id=3 <?php //create an array to hold the database information $mysql_info = array ('hostname' => 'localhost', 'username' => 'user', 'password' => 'password', 'database' => 'database'); //connect to the database server $link_id =mysql_connect($mysql_info['hostname'], $mysql_info['username'], $mysql_info['password']) or die("couldn't connect to database"); //select the database mysql_select_db($mysql_info['database'],$link_id) or die("couldn't select database ". mysql_error($link_id)); //if get is set make sure it's a number if(isset($_GET['id']) && is_integer($_GET['id']){$id = $_GET['id'];} //create query to extract information from the database $sql = "SELECT id, headline, content FROM blog WHERE 'id'= $id"; $result = mysql_query($sql, $link_id); while($row = mysql_fetch_assoc($result)){ echo 'Headline: ' . $row['headline']; echo '<p> ' . $row['content']; } mysql_free_result($result); ?> The main point you should pick up early is, you need to read A LOT. The more you read the more you will understand. If you get stuck on something keep reading and come back to whatever you're stuck on later. Also don't forget you can always ask more questions. Quote Link to comment https://forums.phpfreaks.com/topic/106601-pro-weblayout-designer-need-help-with-php/#findComment-546404 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.