Thursday, 31 January 2019

PHP : Connect PHP with mysql SUCCESS


<!-- use this if want to include connection from saperate file

 <?php
 //include 'dbh.php';
 
?> -->

<!-- php below is the copy from dbh.php. Use php include if you want to saperate connector with index file -->
<?php

$servername = "localhost";
$username = "root";
$password = "";
$dbname = "ajax";

$conn = mysqli_connect($servername, $username, $password,$dbname);

?>


<!DOCTYPE html>
<html>
<head>
 <title>Jquery Ajax</title>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
 //jquery code here
</script>
</head>
<body>


<div id="comment">
 
 <!-- coding here -->

 <?php
$sql = "SELECT * FROM comments LIMIT 3"; //change LIMIT number to show up how many data to echo
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0){
 while ($row = mysqli_fetch_assoc($result)) {
  echo "<p>";
  echo $row['author'];
  echo "<br/>";
  echo $row['message'];
  echo "<br/>";
  echo "</p>";
 }

   

  } else {
   echo "Tak ada comments!";

  }

 ?>

</div>


<button>Show comment</button>

</body>
</html>
...

change to this to display latest or newer data from mysql

$sql = "SELECT * FROM comments order by id DESC LIMIT 4"

in this case data select latest by id. If there are date row on mysql change into that string.

MYSQL : SQL command

create table comments (
id int(11) mot null auto_increment primary key,
author text not null,
message text not null
)


// this will create database row and column


insert into comments (author, message) values ('hafiz', 'The Google Hosted Libraries is a stable, reliable, high-speed, globally available content distribution network for the most popular, open-source JavaScript libraries.
Google works directly with the key stakeholders for each library effort and accepts the latest versions as they are released.');

insert into comments (author, message) values ('muhaza', 'The Google Hosted Libraries is a stable, reliable, high-speed, globally available content distribution network for the most popular, open-source JavaScript libraries.as they are released.');

//this how to add value as author and message


Sunday, 13 January 2019

Blogger : Basic Template

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html>
<html b:version='2' class='v2' expr:dir='data:blog.languageDirection' xmlns='http://www.w3.org/1999/xhtml' xmlns:b='http://www.google.com/2005/gml/b' xmlns:data='http://www.google.com/2005/gml/data' xmlns:expr='http://www.google.com/2005/gml/expr'>
<head>
  <meta content='IE=EmulateIE7' http-equiv='X-UA-Compatible'/>
  <b:if cond='data:blog.isMobile'>
    <meta content='width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0' name='viewport'/>
  <b:else/>
    <meta content='width=1100' name='viewport'/>
  </b:if>
  <b:include data='blog' name='all-head-content'/>
  <title><data:blog.pageTitle/></title>
  <b:skin>
  </b:skin>
</head>

<body>

  <b:section id='header' class='header' maxwidgets='1' showaddelement='yes'>
  </b:section>

  <b:section id='main' class="main" maxwidgets='' showaddelements='yes'>
    <b:widget id='Blog1' locked='false' title='Blog Posts' type='Blog'/>
  </b:section>

</body>


</html>

Monday, 7 January 2019

JQUERY : Bootstrap popup modal with timer

<div class="modal fade" id="overlay">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h4 class="modal-title">Modal title</h4>
      </div>
      <div class="modal-body">
        <p>Context here</p>
      </div>
    </div>
  </div>
</div>

// jquery

$('#overlay').modal('show');

setTimeout(function() {
    $('#overlay').modal('hide');
}, 5000);

email mailto: pretext

 <a href="mailto:designoutsourced.com+info@gmail.com?subject=Maklumat%20lanjut%20pakej&body=Hai,%20saya%20berminat%20tahu%20lebi...