Web Analytics Made Easy -
StatCounter Help w/ Auto-Generated Queried Voting Page - CodingForum

Announcement

Collapse
No announcement yet.

Help w/ Auto-Generated Queried Voting Page

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Help w/ Auto-Generated Queried Voting Page

    Here's a link to the site thus far:
    Mobile Site Testing

    I'm attempting to make a mobile version of our company website that focuses on a contest voting system that we currently have in place.

    Since it's going to be formatted for mobile devices, I want to change certain aspects from the websites voting system in order to translate it effectively.

    Here's the coding for 1 of the desktop browser voting pages:

    PHP Code:
    <!DOCTYPE html>
    <html lang="en">

    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width; initial-scale=1.0;" />
    <meta name="author" content="Brandon Moner" />
    <script type="text/javascript" type="text/javascript" src="js/jquery-1.6.1.min.js"></script>
    <link rel="stylesheet" type="text/css" href="../css/style.css" />
    <link href='http://fonts.googleapis.com/css?family=Droid+Serif:700italic' rel='stylesheet' type='text/css' />

    <title>Ruth Olson Photography</title>
    </head>

    <body>

    <header>
        <div class="top">
            <div class="contents">
                <h1><a href="index.php">Ruth Olson Photography</a></h1>
            </div>
        </div>
    </header>

    <div id="query">

    <?php

    include("../templates/mysql_connect.php");

     
    //FOR LETTER: A

    $query "SELECT * FROM seniors WHERE last_name LIKE 'A%' ORDER BY last_name ASC";
    $result = @mysql_query ($query);

    echo 
    '<table><tr>
      <td>
      <p><span class="style19"><u>-A-</u></span><br />'
    ;

    while (
    $row mysql_fetch_array ($result)){
            
            echo 
    "<a href=\"$row[pic_url]\" rel=\"lightbox[seniors]\" 
    title=\" &lt;form action =&quot;/sencha-tallyvote.php?sen_id=
    $row[sen_id]&quot; method=&quot;post&quot;&gt;

    $row[first_name] $row[last_name] - $row[school] <br />

     &nbsp; &nbsp; &lt;input name=&quot;submit&quot; align=&quot;right&quot; type=&quot;submit&quot; value=&quot;Vote&quot; &gt;  
     
     &lt;/form&gt; \">
    $row[last_name]$row[first_name]</a><br/>";
            
        }
    echo 
    '</p>';
    ?>

    <?php
     
    //FOR LETTER: B

    $query "SELECT * FROM seniors WHERE last_name LIKE 'B%' ORDER BY last_name ASC";
    $result = @mysql_query ($query);

    echo 
    '<td><p><span class="style19"><u>-B-</u></span><br />';

    while (
    $row mysql_fetch_array ($result)){
            
            echo 
    "<a href=\"$row[pic_url]\" rel=\"lightbox[seniors]\" 
    title=\" &lt;form action =&quot;/sencha-tallyvote.php?sen_id=
    $row[sen_id]&quot; method=&quot;post&quot;&gt;

    $row[first_name] $row[last_name] - $row[school]

     &nbsp; &nbsp; &lt;input name=&quot;submit&quot; type=&quot;submit&quot; value=&quot;Vote&quot; &gt;  
     
     &lt;/form&gt; \">
    $row[last_name]$row[first_name]</a><br/>";
            
        }
    echo 
    '</p></td>';
    ?>

    <?php
     
    //FOR LETTER: C

    $query "SELECT * FROM seniors WHERE last_name LIKE 'C%' ORDER BY last_name ASC";
    $result = @mysql_query ($query);

    echo 
    '<td><p><span class="style19"><u>-C-</u></span><br />';

    while (
    $row mysql_fetch_array ($result)){
            
            echo 
    "<a href=\"$row[pic_url]\" rel=\"lightbox[seniors]\" 
    title=\" &lt;form action =&quot;/sencha-tallyvote.php?sen_id=
    $row[sen_id]&quot; method=&quot;post&quot;&gt;

    $row[first_name] $row[last_name] - $row[school]

     &nbsp; &nbsp; &lt;input name=&quot;submit&quot; type=&quot;submit&quot; value=&quot;Vote&quot; &gt;  
     
     &lt;/form&gt; \">
    $row[last_name]$row[first_name]</a><br/>";
            
        }
    echo 
    '</p></td></tr>';
    ?>

    <?php
     
    //FOR LETTER: D

    $query "SELECT * FROM seniors WHERE last_name LIKE 'D%' ORDER BY last_name ASC";
    $result = @mysql_query ($query);

    echo 
    '<tr><td><p><span class="style19"><u>-D-</u></span><br />';

    while (
    $row mysql_fetch_array ($result)){
            
            echo 
    "<a href=\"$row[pic_url]\" rel=\"lightbox[seniors]\" 
    title=\" &lt;form action =&quot;/sencha-tallyvote.php?sen_id=
    $row[sen_id]&quot; method=&quot;post&quot;&gt;

    $row[first_name] $row[last_name] - $row[school]

     &nbsp; &nbsp; &lt;input name=&quot;submit&quot; type=&quot;submit&quot; value=&quot;Vote&quot; &gt;  
     
     &lt;/form&gt; \">
    $row[last_name]$row[first_name]</a><br/>";
            
        }
    echo 
    '</p></td>';
    ?>

    <?php
     
    //FOR LETTER: E

    $query "SELECT * FROM seniors WHERE last_name LIKE 'E%' ORDER BY last_name ASC";
    $result = @mysql_query ($query);

    echo 
    '<td><p><span class="style19"><u>-E-</u></span><br />';

    while (
    $row mysql_fetch_array ($result)){
            
            echo 
    "<a href=\"$row[pic_url]\" rel=\"lightbox[seniors]\" 
    title=\" &lt;form action =&quot;/sencha-tallyvote.php?sen_id=
    $row[sen_id]&quot; method=&quot;post&quot;&gt;

    $row[first_name] $row[last_name] - $row[school]

     &nbsp; &nbsp; &lt;input name=&quot;submit&quot; type=&quot;submit&quot; value=&quot;Vote&quot; &gt;  
     
     &lt;/form&gt; \">
    $row[last_name]$row[first_name]</a><br/>";
            
        }
    echo 
    '</p></td>';
    ?>

    <?php
     
    //FOR LETTER: F

    $query "SELECT * FROM seniors WHERE last_name LIKE 'F%' ORDER BY last_name ASC";
    $result = @mysql_query ($query);

    echo 
    '<td><p><span class="style19"><u>-F-</u></span><br />';

    while (
    $row mysql_fetch_array ($result)){
            
            echo 
    "<a href=\"$row[pic_url]\" rel=\"lightbox[seniors]\" 
    title=\" &lt;form action =&quot;/sencha-tallyvote.php?sen_id=
    $row[sen_id]&quot; method=&quot;post&quot;&gt;

    $row[first_name] $row[last_name] - $row[school]

     &nbsp; &nbsp; &lt;input name=&quot;submit&quot; type=&quot;submit&quot; value=&quot;Vote&quot; &gt;  
     
     &lt;/form&gt; \">
    $row[last_name]$row[first_name]</a><br/>";
            
        }
    echo 
    '</p></td></tr>';
    ?>

    </table>

    </div>
    </body>
    </html>
    And here's the condensed coding for 1 of the mobile device browser voting pages:

    PHP Code:
    <!DOCTYPE html>
    <html lang="en">

    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width; initial-scale=1.0;" />
    <meta name="author" content="Brandon Moner" />
    <script type="text/javascript" type="text/javascript" src="js/jquery-1.6.1.min.js"></script>
    <script type="text/javascript" src="js/prototype.js"></script>
    <script type="text/javascript" src="js/scriptaculous.js?load=effects,builder"></script>
    <script type="text/javascript" src="js/lightbox.js"></script>
    <script type="text/Javascript" src="js/script.js"></script>
    <link rel="stylesheet" type="text/css" href="css/style.css" />

    <title>Ruth Olson Photography</title>
    </head>

    <body>

    <header>
        <div class="top">
            <div class="contents">
                <h1><a href="index.php">Ruth Olson Photography</a></h1>
            </div>
        </div>
    </header>

    <div id="query">

    <?php

    include("templates/mysql_connect.php");

     
    //FOR LETTERS: A-F

    $query "SELECT * FROM seniors WHERE last_name BETWEEN 'A%' and 'FZ%' ORDER BY last_name ASC";
    $result = @mysql_query ($query);

    echo
    '<div class="bigmenu" alt="Results A-F"><u>A-F</u></div><br />';

    while (
    $row mysql_fetch_array ($result)){
            
            echo 
    "<a href=\"$row[pic_url]\" rel=\"lightbox[seniors]\" 
    title=\" &lt;form action =&quot;/tally.php?sen_id=
    $row[sen_id]&quot; method=&quot;post&quot;&gt;

    $row[first_name] $row[last_name] - $row[school] <br />

     &nbsp; &nbsp; &lt;input name=&quot;submit&quot; align=&quot;right&quot; type=&quot;submit&quot; value=&quot;Vote&quot; &gt;  
     
     &lt;/form&gt; \">
    $row[last_name]$row[first_name]</a><br/>";
            
        }
    echo 
    '</p>';
    ?>

    </div>

    <footer class="contents">
        <p>&copy; Copyright 2003 - <?php echo date("Y"?> Ruth Olson Photography</p>
    </footer>

    </body>

    </html>
    Since I won't be using any Lightbox technology with this mobile version of the site, I need to find a way for the name, photo and school information of an individual to be fed into a template voting page...and this is where I need help.
    Last edited by Psionicsin; Aug 17, 2011, 02:59 PM.

  • #2
    We currently have a page that takes the information of a person fed into it and displays:

    1. The name of the individual.
    2. How many votes they have.

    Here's the coding:

    PHP Code:
    <!DOCTYPE html>
    <html lang="en">

    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width; initial-scale=1.0;" />
    <meta name="author" content="Brandon Moner" />
    <script type="text/javascript" type="text/javascript" src="js/jquery-1.6.1.min.js"></script>
    <link rel="stylesheet" type="text/css" href="css/style.css" />

    <title>Ruth Olson Photography</title>
    </head>

    <body>

    <header>
        <div class="top">
            <div class="contents">
                <h1><a href="index.php">Ruth Olson Photography</a></h1>
            </div>
        </div>
    </header>

    <?php
    require_once('templates/mysql_connect.php');

    /////////////
    function escape_data ($data)
    {
        global 
    $dbc;
        
        if(
    ini_get('magic_quotes_gpc'))
        
    $data stripslashes($data);
        
        return 
    mysql_real_escape_string($data$dbc);    
    }
    ////////////

    $ip=$_SERVER['REMOTE_ADDR'];

    $queryIP "SELECT INET_NTOA('ip') FROM ips WHERE ip=INET_ATON('$ip')";
    $resultIP mysql_query ($queryIP);
    $existIP mysql_num_rows($resultIP);


    if (isset(
    $_COOKIE['vote']) || $existIP 0)
    {
        
    $message "<b>You have already voted in this year's Senior Challenge!</b> <p>To view the rankings of the current Senior Challenge contestants, <a href=\"/voteresults.php\">click here</a></p>";
    }
    else
    {
        
    //Get Senior info
        
    $query "SELECT * FROM seniors WHERE sen_id=$_GET[sen_id]";
        
    $result mysql_query ($query);
        
    $row mysql_fetch_array ($result);

        
    //Tally vote
        
    $votes $row['votes'] + 1;
        
    $queryTally "UPDATE seniors SET votes='$votes' WHERE sen_id=$_GET[sen_id] LIMIT 1";
        
    $resultTally mysql_query ($queryTally);
        
        if(isset(
    $resultTally))
        {
            
    $message "<b>Your vote has been registered!</b>  <p>Thank you for participating in the 2012 Senior Challenge.  To view the rankings of the current Senior Challenge contestants, <a href=\"/top10.php\">click here</a></p>";
            
            
    //Set cookie + ip
        
    setcookie ("vote""yes"time()+15552000);
        
    $queryInsertIP "INSERT INTO ips (ip, person) VALUES(INET_ATON('$ip'), '$row[last_name]')";
        
    $resultInsertIP mysql_query ($queryInsertIP);

        }
        else
        {
            
    $message "<b>Error:  Vote was not counted!</b>  <p>You have encountered an error, and your vote was NOT tallied.  Please, <a href=\"/contact.html\">contact us</a> to tally your vote.</p>";
        }
    }

    ?>

    <?php 
    $page_title 
    'Ruth Olson Photography - Vote Result';
    $query "SELECT * FROM seniors WHERE sen_id=$_GET[sen_id]";
    $result mysql_query ($query);
    $row mysql_fetch_array ($result);

    ?>

    <h3><?php echo $row['first_name'], " "$row['last_name'], " has <font style=\"color:#FF0000\">
    $row[votes]</font> votes";?></h3>

    <?php echo "<p>"$message"</p>"?>

    <br />

    <footer class="contents">
        <p>&copy; Copyright 2003 - <?php echo date("Y"?> Ruth Olson Photography</p>
    </footer>

    </body>

    </html>
    How can I duplicate and restructure this file in order to suit my needs for displaying the individuals name, school, photo and a voting button?
    Last edited by Psionicsin; Aug 17, 2011, 03:02 PM.

    Comment


    • #3
      So, first things first, I need to create 5 pages (A-F, G-L, M-R, S-X, Y-Z) that query last names falling within a specific range...any ideas?
      Last edited by Psionicsin; Aug 17, 2011, 03:03 PM.

      Comment


      • #4
        I was able to transform...
        PHP Code:
        $query "SELECT * FROM seniors WHERE last_name LIKE 'A%' ORDER BY last_name ASC"
        ...into this...
        PHP Code:
        $query "SELECT * FROM seniors WHERE last_name BETWEEN 'A%' and 'FZ%' ORDER BY last_name ASC"
        Adding a Z after the ending letter seems to have helped include everything inbetween up until results FZ.

        _________________________________________________________________________

        Now, onto the hard stuff...

        How can I make it so that once a name is clicked, an automatically generated page (based on a template page) will appear with the person's photo, school info and vote button? THIS is something that I'm not totally sure of and need EXTREME help with.
        Last edited by Psionicsin; Aug 17, 2011, 03:05 PM.

        Comment


        • #5
          Hmm...am I not asking a question right, or did I do something wrong? Or is this just really a stumper lol?

          Comment

          Working...
          X
          😀
          🥰
          🤢
          😎
          😡
          👍
          👎