• We just launched and are currently in beta. Join us as we build and grow the community.

PHP - Marquee Scrolling Link With MySQLi

diplo obama

Pattern Matching Engineer
D Rep
0
0
0
Rep
0
D Vouches
0
0
0
Vouches
0
Posts
55
Likes
35
Bits
2 MONTHS
2 2 MONTHS OF SERVICE
LEVEL 1 300 XP
In this tutorial we will create a Marquee Scrolling Link With MySQLi. PHP is a server-side scripting language designed primarily for web development. Using PHP, you can let your user directly interact with the script and easily to learned its syntax. It is mostly used by a newly coders for its user friendly environment. So Let's do the coding...

Before we get started:

First you have to download & install XAMPP or any local server that run PHP scripts. Here's the link for XAMPP server https://www.apachefriends.org/index.html.

And this is the link for the jquery that i used in this tutorial https://jquery.com/.

Lastly, this is the link for the bootstrap that i used for the layout design https://getbootstrap.com/.

Creating Database

Open your database web server then create a database name in it db_marquee, after that click Import then locate the database file inside the folder of the application then click ok.
2018-08-01_10_51_14-localhost_127.0.0.1_db_marquee_phpmyadmin_4.7.0.png

Creating the database connection

Open your any kind of text editor(notepad++, etc..). Then just copy/paste the code below then name it conn.php.
  1. <?php
  2. $conn

    =

    new

    mysqli(

    'localhost'

    ,

    'root'

    ,

    ''

    ,

    'db_marquee'

    )

    ;

  3. if

    (

    !

    $conn

    )

    {
  4. die

    (

    "Error: Failed to connect to database!"

    )

    ;
  5. }
  6. ?>

Creating The Interface

This is where we will create a simple form for our application. To create the forms simply copy and write it into your text editor, then save it as shown below.
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8" name="viewport" content="width=device-width, initial-scale=1" />
  5. <link rel="stylesheet" type="text/css" href="css/bootstrap.css"/>
  6. </head>
  7. <body>
  8. <nav class="navbar navbar-default">
  9. <div class="container-fluid">
  10. <a class="navbar-brand" href="https://sourcecodester.com">Sourcecodester</a>
  11. </div>
  12. </nav>
  13. <div class="col-md-3"></div>
  14. <div class="col-md-6 well">
  15. <h3 class="text-primary">PHP - Marquee Scrolling Link With MySQLi</h3>
  16. <hr style="border-top:1px dotted #ccc;"/>
  17. <button class="btn btn-primary" data-toggle="modal" data-target="#form_modal">Add Link Source</button>
  18. <br /><br />
  19. <div class="alert alert-warning">Link List</div>
  20. <div style="margin-top:30px;">
  21. <marquee direction="down" scrolldelay="150" onmouseout="this.start()" onmouseover="this.stop()">
  22. <?php
  23. require

    'conn.php'

    ;

  24. $query

    =

    $conn

    ->

    query

    (

    "SELECT * FROM `link`"

    )

    ;
  25. while

    (

    $fetch

    =

    $query

    ->

    fetch_array

    (

    )

    )

    {
  26. ?>
  27. <a href="<?php

    echo

    $fetch

    [

    'link_url'

    ]

    ?>

    " style="font-size:20px; padding:10px;" scrolldelay=""><?php

    echo

    $fetch

    [

    'link_title'

    ]

    ?>

    </a><br /><br />
  28. <?php
  29. }
  30. ?>

  31. </marquee>
  32. </div>
  33. </div>

  34. <div class="modal fade" id="form_modal" tabindex="-1" role="dialog" aria-hidden="true">
  35. <div class="modal-dialog" role="document">
  36. <form action="save_query.php" method="POST" enctype="multipart/form-data">
  37. <div class="modal-content">
  38. <div class="modal-body">
  39. <div class="col-md-2"></div>
  40. <div class="col-md-8">
  41. <div class="form-group">
  42. <label>Link Title</label>
  43. <input class="form-control" type="text" name="link" required="required" />
  44. </div>
  45. <div class="form-group">
  46. <label>Link URL</label>
  47. <input class="form-control" type="url" name="url" required="required"/>
  48. </div>
  49. </div>
  50. </div>
  51. <div style="clear:both;"></div>
  52. <div class="modal-footer">
  53. <button type="button" class="btn btn-danger" data-dismiss="modal"><span class="glyphicon glyphicon-remove"></span> Close</button>
  54. <button name="save" class="btn btn-primary"><span class="glyphicon glyphicon-save"></span> Save</button>
  55. </div>
  56. </div>
  57. </form>
  58. </div>
  59. </div>
  60. </body>
  61. <script src="js/jquery-3.2.1.min.js"></script>
  62. <script src="js/bootstrap.js"></script>
  63. </html>

Creating PHP Query

This code contains the php query of the application. This code will store the url links to the database server and later will be retrieve as a marquee data To do that just copy and write this block of codes inside the text editor, then save it as save_query.php.
  1. <?php
  2. require_once

    'conn.php'

    ;

  3. if

    (

    ISSET

    (

    $_POST

    [

    'save'

    ]

    )

    )

    {
  4. $link

    =

    $_POST

    [

    'link'

    ]

    ;
  5. $url

    =

    $_POST

    [

    'url'

    ]

    ;

  6. $conn

    ->

    query

    (

    "INSERT INTO `link` VALUES('', '$link

    ', '$url

    ')"

    )

    ;

  7. header

    (

    'location: index.php'

    )

    ;
  8. }
  9. ?>

There you have it we successfully created Marquee Scrolling Link With MySQLi. I hope that this simple tutorial help you to what you are looking for. For more updates and tutorials just kindly visit this site. Enjoy Coding!


Download
You must upgrade your account or reply in the thread to view hidden text.
 

452,292

323,526

323,535

Top