473,320 Members | 1,879 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

XML/PHP voting system, help required urgently :)

Hi there, I'm creating a PHP/XML-based voting system. There are 24 options for a user to vote from, and ideally I'd like the user to see a picture of each person they vote for. So far, I've managed to list all the names of people up for voting from a "poll.xml" file in my "poll.php" file which is what web users will go to in order to vote. It also correctly updates the tally in the XML file when a person is voted for. The only thing that doesn't work now is trying to get an image to display next to each person's name...any ideas? Or would I have to learn XSLT to do this? (I have none currently, just a plain XML file and PHP file).

Thanks for your time! Appropriate sections of each file are below :)

POLL.PHP
[PHP]function printVotingForm($pid) {
// get these variables in this scope
global $polls, $header_file, $footer_file;

// include header file
include($header_file);

// print poll title and form
echo "<h3 style=\"text-align: center\">" . $polls->poll[$pid]['title'] . "</h3>\n";
echo "<form action=\"" . $_SERVER['PHP_SELF'] . "\" method=\"post\">\n";
echo "<fieldset>\n";
echo "<input type=\"hidden\" name=\"pid\" value=\"$pid\" />\n";
echo "<ul style=\"list-style-type: none\">\n";

// count number of answers
$no_answers = count($polls->poll[$pid]->answers->answer);

// print each answer as a checkbox
if ($polls->poll[$pid]->multipleanswers == "yes") {
for ($i = 0; $i < $no_answers; $i++) {
echo "<li><input type=\"checkbox\" name=\"vote[]\" value=\"" . $polls->poll[$pid]->answers->answer[$i]->name . "\" />" . $polls->poll[$pid]->answers->answer[$i]->name . "</li>\n";
}
}

// print each answer as a radio button
else {
for ($i = 0; $i < $no_answers; $i++) {
echo "<li><input type=\"radio\" name=\"vote\" value=\"" . $polls->poll[$pid]->answers->answer[$i]->name . "\" />" . $polls->poll[$pid]->answers->answer[$i]->name . "</li>\n";
}
}

echo "</ul>\n";
echo "<p style=\"text-align: center\"><input type=\"submit\" value=\"Vote\" /> or <a href=\"" . $_SERVER['PHP_SELF'] . "?pid=$pid&amp;view_results=1\">View Results</a></p>\n";
echo "</fieldset>\n";
echo "</form>\n";

// include footer file
include($footer_file);
}

}

[/PHP]


POLL.XML
[PHP]<?xml version="1.0"?>
<polls>
<poll title="Who do you think should win the vote this year?">
<answers>
<answer>
<name>Michael</name>
<tally>0</tally>
<image>src_here.gif</image>
</answer>
<answer>
<name>Sophie</name>
<tally>0</tally>
</answer>
</answers>
</poll>
</polls>[/PHP]
Nov 18 '08 #1
1 3160
Dormilich
8,658 Expert Mod 8TB
one way could be to store the image name along with the person's name in the xml file and then build an <img> from the $polls object around that, similar to the name.

you do not have to learn xslt for that, but it can come in handy for lots of persons. (plus it directly outputs (x)html, so you don't need to convert xml->php->html)

regards
Nov 18 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: TNGgroup | last post by:
Hey, I'm looking for a voting system to use on my website, could anyone point me in to the right direction, Thx
8
by: TNGgroup | last post by:
Hey, I'm looking for a voting system to use on my website, could anyone point me in to the right direction, Thx
2
by: txie2004 | last post by:
I'm looking for a open source PHP voting system. I found many open source and commercial php survey/vote programs on hotscripts.com, such as phpsurveyor, phpESP. They all work the same way, admin...
2
by: white lightning | last post by:
Hi all, I'm not sure if I am posting this in the right forum. Anyway, I'll try. The company where I work is going to have a new online sales / marketing system developed in asp.net (not quite...
0
reddyprasanth
by: reddyprasanth | last post by:
Hi All, I am Doing a project to design an Electronic Voting System. All The Modules are finished and its working fine. Now i want to implement Finger print Sensor For the voting system.I am...
9
by: deaconj999 | last post by:
Hi All, I am using this unbound to add the frequency to a date entered =IIf(="HIGH - annual",+365,IIf(="MED - 3 yearly",+1095,IIf(="LOW - 5 yearly",+1825,IIf(="N/ A",Date())))) but would...
4
by: 4nicefriend | last post by:
Hi, I want to know more about C++. So Please tell me where i get all the details about c++. Any site can provide me online tutorial for c++.If yes, please tell me.
3
by: kcddoorman | last post by:
I have developed a nice database system that controls almost all aspects of one manufacturing department. I am using microsoft Access as the database (Jet?) and I use forms to enter data. The front...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.