psionicsin Posted August 17, 2011 Share Posted August 17, 2011 Here's a link to the mobile 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 See Desktop Voting Page. 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: <!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=\" <form action ="/sencha-tallyvote.php?sen_id=$row[sen_id]" method="post"> $row[first_name] $row[last_name] - $row[school] <br /> <input name="submit" align="right" type="submit" value="Vote" > </form> \">$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=\" <form action ="/sencha-tallyvote.php?sen_id=$row[sen_id]" method="post"> $row[first_name] $row[last_name] - $row[school] <input name="submit" type="submit" value="Vote" > </form> \">$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=\" <form action ="/sencha-tallyvote.php?sen_id=$row[sen_id]" method="post"> $row[first_name] $row[last_name] - $row[school] <input name="submit" type="submit" value="Vote" > </form> \">$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=\" <form action ="/sencha-tallyvote.php?sen_id=$row[sen_id]" method="post"> $row[first_name] $row[last_name] - $row[school] <input name="submit" type="submit" value="Vote" > </form> \">$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=\" <form action ="/sencha-tallyvote.php?sen_id=$row[sen_id]" method="post"> $row[first_name] $row[last_name] - $row[school] <input name="submit" type="submit" value="Vote" > </form> \">$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=\" <form action ="/sencha-tallyvote.php?sen_id=$row[sen_id]" method="post"> $row[first_name] $row[last_name] - $row[school] <input name="submit" type="submit" value="Vote" > </form> \">$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: <!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> <div class="container"> <div class="contents"> <h1>Contestants A-F</h1> </div> <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 '<a href="sencha.php" class="bigmenu"><img src="images/backarrow.png" alt="Back to Senior Challenge Home" class="arrowleft indexicon" /><u>Back</u></a><br />'; while ($row = mysql_fetch_array ($result)){ echo "<a href=\"$row[pic_url]\" rel=\"lightbox[seniors]\" title=\" <form action ="/tally.php?sen_id=$row[sen_id]" method="post"> $row[first_name] $row[last_name] - $row[school] <br /> <input name="submit" align="right" type="submit" value="Vote" > </form> \">$row[last_name], $row[first_name]</a><br/>"; } echo '</p>'; ?> </div> </div> <footer class="contents"> <p>© 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. 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: <!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>© 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? Quote Link to comment https://forums.phpfreaks.com/topic/245072-help-w-auto-generated-voting-page/ Share on other sites More sharing options...
psionicsin Posted August 17, 2011 Author Share Posted August 17, 2011 If I didn't ask something correctly, or provide enough info, please let me know so I can correct it. Quote Link to comment https://forums.phpfreaks.com/topic/245072-help-w-auto-generated-voting-page/#findComment-1258801 Share on other sites More sharing options...
jcbones Posted August 18, 2011 Share Posted August 18, 2011 There are a few problems that hinder you from getting replies. 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. You haven't provided any functions/templates, nor what is required for that template. 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? Since we don't have access to your template, we aren't real sure how to restructure it, to suit your needs. I can offer some advice though. Get the design of your mobile site finished, but put placeholders in it for where you want your data to show up. If you want an image somewhere, put {{IMAGE}}, or a name somewhere put {{NAME}}. This way you will get to see the design of the site, and get it like you want. Next. Now you can use PHP to get the data where you want the placeholders. In the last script you posted, everything that is returned from the database is contained in these few lines: <h3><?php echo $row['first_name'], " ", $row['last_name'], " has <font style=\"color:#FF0000\"> $row[votes]</font> votes";?></h3> Everything in $message is concerning database interactions, but is contained inside the script. Quote Link to comment https://forums.phpfreaks.com/topic/245072-help-w-auto-generated-voting-page/#findComment-1258858 Share on other sites More sharing options...
psionicsin Posted August 18, 2011 Author Share Posted August 18, 2011 There are a few problems that hinder you from getting replies. I'm sorry if I wasn't too clear as far as the template issue is concerned . And, btw, the look of the site is actually complete and you can see it by visiting that first link at the top of my post. We're going as barebones as possible right now until everything is 102% functioning. I don't have a template file. I was looking for guidance on how to create one to do what I need it to do. I'm VERY new to PHP coding. When I said template, I meant something along the lines of how the third block of code is structured. That code alone holds no actual data [which is why I call it a template], but data that was queried on the page before it gets fed through to that page to display the correct results of the person selected. I'm gonna Photoshop a quick mockup of what I'm talking about. Visuals always help when it comes to me explaining crazy things lol. Quote Link to comment https://forums.phpfreaks.com/topic/245072-help-w-auto-generated-voting-page/#findComment-1258871 Share on other sites More sharing options...
psionicsin Posted August 18, 2011 Author Share Posted August 18, 2011 Ok...hopefully this visual helps. And I'm not 100% on the terms so don't be mad lol. Also, MySQL DB is already set up. It'd go like this (steps 1-3 are already done): [*]Formt he home page, they'll click on Senior Challenge. [*]From this menu, they'll click on whatever grouping for the persons name. [*]The list of poeple who's last names fall into the grouping will be queried from DB and list themselves. [*]When a name is clicked, a page will be generated with the person's name, school name, photo (already listed in the MySQL DB), and a vote now button that will place a vote for that perosn. But I need to somehow restructure this code to display the names (as it already does), but then have the id, school name and photo path stored when the name is clicked so that data can be displayed on the other page. This is the code form the desktop version that has a Lightbox plugin that activates when a name is clicked. But instead of a Lightbox with all of that...I want it to generate a page with the info as shown. <?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 '<a href="sencha.php" class="bigmenu"><img src="images/backarrow.png" alt="Back to Senior Challenge Home" class="arrowleft indexicon" /><u>Back</u></a><br />'; while ($row = mysql_fetch_array ($result)){ echo "<a href=\"$row[pic_url]\" rel=\"lightbox[seniors]\" title=\" <form action ="/tally.php?sen_id=$row[sen_id]" method="post"> $row[first_name] $row[last_name] - $row[school] <br /> <input name="submit" align="right" type="submit" value="Vote" > </form> \">$row[last_name], $row[first_name]</a><br/>"; } echo '</p>'; ?> [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/245072-help-w-auto-generated-voting-page/#findComment-1258877 Share on other sites More sharing options...
jcbones Posted August 18, 2011 Share Posted August 18, 2011 Do you see how this query gets it's info? BTW, it is very in-secure, I would suggest looking into sanitation and validation of client provided data. (another topic). $query = "SELECT * FROM seniors WHERE sen_id=$_GET[sen_id]"; //query gets it's info from the _GET array (URL). How all of this info is past between pages, is in the URL you have a "?sen_id=2". Where 2 is the row number (name) you are looking for from the database. So, these pages actually only send 1 bit of info between them, in order to get ALL of the info you wish to see. The above code, with the lightbox removed. echo "<form action ="/tally.php?sen_id=$row[sen_id]" method="post"> $row[first_name] $row[last_name] - $row[school] <br /> <input name="submit" align="right" type="submit" value="Vote" > </form><br/>"; I think that is it. Quote Link to comment https://forums.phpfreaks.com/topic/245072-help-w-auto-generated-voting-page/#findComment-1259196 Share on other sites More sharing options...
psionicsin Posted August 19, 2011 Author Share Posted August 19, 2011 I replaced lines from what you gave me, and it ended up being a mess. Not exactly sure if that was right. All kinds of errors popped out left and right lol. Quote Link to comment https://forums.phpfreaks.com/topic/245072-help-w-auto-generated-voting-page/#findComment-1259204 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.