Menu:

View Harold Carey's profile on LinkedIn

This weeks Quotes:

If you're going to create, create a lot. Creativity is not like playing the slot machines, where failure to win means you go home broke. With creativity, if you don't win, you're usually no worse off than if you hadn't played
Scott Adams

Invest yourself in everything you do. There is fun in being serious.
Wynton Marsalis


Hello... I'm Harold Carey Jr. I have helped numerous Internet-only and bricks-and-mortar businesses to succeed in their offices and online for over 20 years, as well as helping larger businesses to effectively use the web to reduce costs and save both time and money.

 

PHP Tutor Date and Time

02/06/12
Mon, February 6th
Monday, February 6th 2012
1:51 PM
Mon, 06 Feb 2012 13:51:01 -0600
1:51:01 PM Mon, February 6th 2012

 

PHP MySQL Tutor

Connecting to a MySQL Database and getting data.

Connected successfully

1:51:01 PM Mon, February 6th 2012
Id First Name Last Name Phone
3 Carmine Dioxide 555-1234
4 Luke Warm 555-6584
5 Rusty Steele 555-6852
6 Wilma Butfit 555-5842
7 Art Majors 555-9854
8 Philip Harmonic 555-5681
9 Bjorn Liar 555-6582
10 Hope Anna Prayer 555-6584
11 Lauren Order 555-3584
12 Bill Shredder 555-9874
13 Neil Down 555-5874

The php Code

<?php
$dbhost = "localhost";
$dbuser = "username";
$dbpass = "password";
$dbname = "hccarey_test";
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
if(! $conn )
{
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully <br><br>';

mysql_select_db($dbname);
$query = "SELECT * FROM members";
$result = mysql_query($query);
?>
<table border="1">
<tr>
<td><strong>Id</strong></td>
<td><strong>First Name</strong></td>
<td><strong>Last Name</strong></td>
<td><strong>Phone</strong></td>
</tr>
<?php do { ?>
<tr>
<td><?php echo $row ['id']; ?></td>
<td><?php echo $row ['firstname']; ?></td>
<td><?php echo $row ['lastname']; ?></td>
<td><?php echo $row ['phone']; ?></td>
</tr>
<?php } while($row = mysql_fetch_array($result, MYSQL_ASSOC)); ?>
</table>

<p>
<?php mysql_close($conn);?>


Date and time
<?php
$b = time ();
print date("m/d/y",$b) . "<br>";
print date("D, F jS",$b) . "<br>";
print date("l, F jS Y",$b) . "<br>";
print date("g:i A",$b) . "<br>";
print date("r",$b) . "<br>";
print date("g:i:s A D, F jS Y",$b) . "<br>";
?>

Monday 06th 2012f February 2012 01:51:01 PM

PHP include file
<?php include("menu1.php"); ?>