Posts

Showing posts with the label php

How to create a VCF card?

First you need to call your settings and generate a vcf. You can even create an image or create a button  rather than text to give more style on your website. Code:  <a href="vcard.settings.php">Download VCF Card</a>  Below is a sample file called vcard.settings.php require_once('./vcard.class.php'); //Path of your vcard class $vc = new vcard(); //Creating new vcard object $vc->filename = "Melanie Borja"; $vc->revision_date = ""; //If you leave this blank, the current timestamp will be used. $vc->class = "PUBLIC"; /* Contact's name data.*/ $vc->data['display_name'] = ""; $vc->data['first_name'] = "Melanie Kaethleen"; $vc->data['last_name'] = "Borja"; #$vc->data['additional_name'] = ""; //Middle name #$vc->data['name_prefix'] = "";  //Mr. Mrs. Dr. #$vc->data['name_suffix'] = ...

How to pass value from database to javascript?

PHP is a server-side script while javascript is a client-side script. Javascript cannot actively read variables from server. But from a page loads, PHP can pass variables to Javascript by writing to the page the Javascript is on. Example: Code: <?php $name = "Melanie"; ?> <script language="javascript" type="text/javascript"> var name = "<?php echo $name; ?>"; document.write(name); </script> Output: Melanie That is the simple way of passing value from php to javascript. And that example will be very useful on passing values from sql to php to javascript. Let's say that we have a database called portfolio,  with a table cycler has column of path and title. We can use code like this: Code: <?php //Connecting to database $connection = mysql_connect('localhost, 'password', 'username'); $sql = mysql_select_db('portfolio', $connection); //Getting table in databa...

Print vs Echo

echo() is a language construct, so you are not required to use parentheses with it. If you ever need to pass more than one parameter to echo(), the parameters must not be enclosed within parentheses. print() behaves as a Function, but is not actually a function. print is sometimes mistaken as a function by many programmers since it sets a return value, but it is also a language construct like echo. It simply outputs a string of data. And you are not required to use parentheses with it.