Hi, I've designed a voting system in PHP that when a user clucks on the vote button it echo a message and a link to view the result. I want to move this message and the link to a popup window

ryantroop commented: +1 for making users cluck to vote! :-D +9

Just a thought , opening a modal window is one option the other would be the content of it to be inside the “page” and to scroll , to change that part of the “page” and to scroll to that with an X (close) option to close it. (also not very descriptive title for this thread)

Here is my php code

<?php

$con = mysqli_connect("localhost","root","","database");
$query = "SELECT * FROM voting";
$result = mysqli_query($con,$query)

?>

<?php
$servername  = "localhost";
$username = "root";
$password = "";
$dbname = "database";

if(isset($_POST['nana']))
{
  $vote_nana = "update voting set nana = nana +1";
  $run_nana = mysqli_query($con,$vote_nana);

  if($run_nana)
  {
    echo " <script>$('thank you for voting for gidoo').modal('show')</script>";

    echo "<h2 style='text-align:center'><a style='text-decoration:none' href='phpfile.php?results'</a>View Results</h2>";
      } 
}

 if(isset($_POST['akwasi']))
{
  $vote_akwasi = "update voting set akwasi = akwasi +1";
  $run_akwasi = mysqli_query($con,$vote_akwasi);

  if($run_akwasi)
  {
    echo " <script>$('thank you for voting for akwasi').modal('show')</script>";

    echo "<h2 style='text-align:center'><a style='text-decoration:none' href='index.php?results'</a>View Results</h2>";
  }
}

if(isset($_POST['ama']))
{
  $vote_ama = "update voting set ama = ama +1";
  $run_ama = mysqli_query($con,$vote_ama);

  if($run_ama)
  {
   echo " <script>$('thank you for voting for ama').modal('show')</script>";

    echo "<h2 style='text-align:center'><a style='text-decoration:none' href='phpfile.php?results'</a>View Results</h2>";
  }
}

if(isset($_POST['akosua']))
{
  $vote_akosua = "update voting set akosua = akosua +1";
  $run_akosua = mysqli_query($con,$vote_akosua);

  if($run_akosua)
  {
    echo "<h2 align='center'> Thanks for voting for akosua!</h2>";

    echo "<h2 style='text-align:center;'><a style='text-decoration:none' href='phpfile.php?results'</a>View Results</h2>";
  }
}

//NEW SECTION STARTED
if(isset($_GET['results']))
{
  $get_votes = "select * from voting";
  $run_votes = mysqli_query($con, $get_votes);
  $row_votes = mysqli_fetch_array($run_votes);

        $nana = $row_votes['nana'];
        $akwasi = $row_votes['akwasi'];
        $ama = $row_votes['ama'];
        $akosua = $row_votes['akosua'];

$count = $nana+$akwasi+$ama+$akosua+$yaa+$fosua+$frimpong+$frank;;

$per_nana = round($nana * 100/$count) . "%";
$per_akwasi = round($akwasi * 100/$count) . "%";
$per_ama = round($ama * 100/$count) . "%";
$per_akosua = round($akosua * 100/$count) . "%";

     echo "
        <div style = 'padding:10px; text-align: center>
           <center>
                  <h3>Results Updated</h3>
                  <p style = 'background: black; padding: 10px; color: white; width: 500px;'> 
                     <b>nana : </b> $nana ($per_nana)
                  </p>

                   <p style = 'background: black; padding: 10px; color: white; width: 500px;'> 
                     <b>akwasi : </b> $akwasi ($per_akwasi)
                  </p>

                   <p style = 'background: black; padding: 10px; color: white; width: 500px;'> 
                     <b>ama : </b> $ama ($per_ama)
                  </p>

                   <p style = 'background: black; padding: 10px; color: white; width: 500px;'> 
                     <b>akosua : </b> $akosua ($per_akosua)
                  </p>
             </center>
</div>
";
}

?>

and i want all the echo to be displayed in this popup

 <button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal"><i class="fa fa-thumbs-up"></i>Vote</button>

<!-- Modal -->
  <div class="modal fade" id="myModal" role="dialog">
    <div class="modal-dialog modal-sm">
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal">&times;</button>
        </div>
        <div class="modal-body" id="vote_details">
          <p>display result hear.</p>
        </div>
        <div class="modal-footer"> 
          <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        </div>
      </div>
    </div>
  </div>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.