| Including external CSS and javascript code igniter way. Conventional way to include external css and javascript is to use <link> and <script> tag. and we also use <meta> tags for including the meta characters in our files , all of this three tags are supported in code igniter , but while we are using a frame work why don't use it in it's way . So for including meta characters we use <meta> tag , but in cod igniter we can use meta() method to pass it So for including meta characters we use <meta> tag , but in cod igniter we can use meta() method to pass it . Here is the Example , <?php $metaKeyword = array ( 'name' =>'keywords', 'content' =>'css3, login, form, custom, input, submit, button, html5, placeholder', ); echo meta($metaKeyword); ?> The equivalent <meta> tag code is <meta name="keywords" content="css3, login, form, custom, input, submit, button, html5, placeholder" /> Here in code igniter inside the meta method we pass the associative array , which holds the name and contents . Next Example is to include the External CSS an java script file for this code igniter provide us the link_tag() method , Here is the Example <?php $styleAttributes = array( 'href'=>base_url().'css/style.css', 'rel' =>'stylesheet', 'text'=>'text/css', ); echo link_tag($styleAttributes); ?> This is similar to the HTML tag <link rel="stylesheet" href="css/style.css" /> [*]Plase remember to add the html helper in your autoload['helper'] array in your autoload.php file which is present in the config folder . |
1 Comment
In my previous post i share how to insert data in mysql using php . now the second step of this project is to fetch the data form the data base , for this i created a input box which take database name input and show the data's in the table (one can change my code to get the particular value from the table by using "WHERE" clause in mysql). my html page look like this I also put the javascript validation to the code .
Step-1 : create the connection Step-2: select the database step-3:store the sql query in a variable step-4:pass the variable to the mysql_query() function step-5 : then use the while loop and mysql_fetch_array() function to get the database values . As my previous post , in this post the application or the example is bit more particle like modern day websites uses . with the power of HTML5 one can easily validate the forms without the javascricpt (no need to use the regular expression for e-mail validation ) . HTML 5 provides new input type = "email" this input type search for the '@' character in the email field and if it is not in the field it will shows the alert to the use , similarly i use input type ="number" and input type = "url" for the number and url inputs . Here is my registration page The above page is also validate with the java script code , which check the user inputs and alert the user if no or wrong input is provided . After that create a data base name and a table inside the database . Here is the Example image As shown above i created a database name storedatabase , and inside the storedatabase a table named registrationdata is created with six fields . Namely firstName , lastName , password , email , phone Number and message to store the respective values from the html registration page . After fill up the form details the database looks like this . download the code :
Before start up the code development , just spend few moments to chose IDE or Text Editor , what to chose and why ?
Well it is well known to every one to run PHP script one needs a server , most popular is Apache . And also one doing database application she / he needs a database server mostly MySQL . So , instead of installing individually one can install a package named as XAMPP or WAMP . Put your code in htdocs directory in case you are using XAMPP and if you are using WAMP then put it in the www directory , that' s simple . Now the main question arise what should i use , a text Editor or a IDE (Integrated Development Environment ) . First take a look at the text Editors There are several text editors are available in the web , to download and start code with them , some of them are :- Sublime Text 2,Komodo edit, notepad ++ and several others . My personal fav is sublime Text 2 ,in case of the text editors all of them have auto complete option , code highlighter , code indentation , better code reading view spell checking. So here you just need to create a new file ,give its extension and all set to start , that's good and simple . But when you are developing a project , this text editors is lacking far behind than the IDE's . Because to read a several number of code you need to scroll all the way to the end , middle , or where ever you want to move . i.e. in the editors to read a particular function in a particular class is bit time taking , no panels to represents the created class or the created functions inside the class . Here comes the role of the IDE . IDE for The Pro Development I recommend to use and learn at least One IDE , with your programming skill , so with this you are not only learning the programming language you are getting familier with the IDE .
My fav IDE is eclipse , One IDE for several coding , just download it and add the development packages . So set up the eclipse IDE for PHP development ,
For More information regarding adding PDT please click , this link will redirect you to eclipse PDT installation step by step process . Advantages The main advantage of the Eclipse IDE over the text editors is its outline window , in this window (in the right side ) one can clearly get the information about the created classes , variables , and also the function under the classes , lets have a look .
|
AuthorHi This is Dipayan . want to work as php Developer .Please call me for an interview in your organization . ArchivesCategories |