Saturday, September 18, 2010

MYSQL Connection In PHP

$connect = mysql_connect("localhost","username","passowrd");
if (!$connect)
  {
  die('not conneced: ' . mysql_error());
  }
?>

Arrays In PHP

$fruits[0]="mango";
$fruits[1]="orange";
$fruits[2]="banana";
$fruits[3]="pineapple";
echo $fruits[0] . " and " . $fruits[1] . " are fruits.";
?>

While Loop In PHP

$i=1;
while($i<=5)
  {
  echo "The number is " . $i . "
";
  $i++;
  }
?>

Functions In PHP

function writeName()
{
echo "Kai Jim Refsnes";
}

echo "My name is ";
writeName();
?>

For Loop In PHP

for ($i=1; $i<=5; $i++)
  {
  echo "The number is " . $i . "
";
  }
?>