send data from php to javascript using jquery -
send data from php to javascript using jquery -
i'm trying implement vertical timeline, don't know how info in right form db using php.
the code add together events following:
$(function() { $("#element").timeline({ data: [ {time: new date(), color: '#555', css: 'success', content: 'jquery.timeline demo event 1'}, {time: new date(), color: '#00ff00', css: 'success', content: 'jquery.timeline demo event 2'}, {time: new date(), color: '#000', css: 'success', content: 'jquery.timeline demo event 3'}, {time: new date(), color: '#000', css: 'success', content: 'jquery.timeline demo event 4'} ] });
i set get.php , can info db in way:
<?php $servername = "localhost"; $username = ""; $password = ""; $dbname = ""; // create connection $conn = new mysqli($servername, $username, $password, $dbname); // check connection if ($conn->connect_error) { die("connection failed: " . $conn->connect_error); } $sql = "select name, text, date table"; $result = $conn->query($sql); if ($result->num_rows > 0) { // output info of each row while($row = $result->fetch_assoc()) { echo "id: " . $row["name"]. " - name: " . $row["text"]. " " . $row["date"]. "<br>"; } } else { echo "0 results"; } $conn->close(); ?>
how set retrieved contents within event handler?
$(function() { $("#element").timeline({ data: [ {time: date_event_1, color: color_event_1, css: 'success', content: content_event_1}, ... ... ] });
thanks in advance.
javascript php jquery html
Comments
Post a Comment