Jump to content

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/245072-help-w-auto-generated-voting-page/
Share on other sites

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.

 


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  :shy:.

 

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.

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]

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.