Jump to content

rocky7

New Members
  • Posts

    1
  • Joined

  • Last visited

rocky7's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. This is my coding. It can run, but the only thing is, it will print out the last line of the data in the table. Why is that happening ? Because I have more than 100 data. <?php // set database server access variables: $host = "localhost"; $user = "root"; $pass = ""; $db = "master_inventory"; // open connection $connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!"); // select database mysql_select_db($db) or die ("Unable to select database!"); // create query $query = "SELECT * FROM laptop"; // execute query $result = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); // see if any rows were returned if (mysql_num_rows($result) > 0) { while($row = mysql_fetch_array($result)) { $Lap_PC_Name = $row['Lap_PC_Name']; $Lap_War_Expiry = $row['Lap_War_Expiry']; } $to = 'abc@xyz.com'; $subject = 'Testing sendmail'; $message = 'The licensed for the following PC will expired in less than one month. PC Name : '.$Lap_PC_Name. '.Date of expired is : ' .$Lap_War_Expiry; $headers = 'From: abc@xyz.com'; if (mail($to, $subject, $message, $headers)) { echo "Email sent."; } else { echo "Email sending failed."; } } ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.