473,783 Members | 2,546 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XML/PHP voting system, help required urgently :)

1 New Member
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]->multipleanswer s == "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 3187
Dormilich
8,658 Recognized Expert Moderator Expert
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
1741
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
2757
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
3008
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 construct a survey, and users vote. I'm looking for a voting system with out-of-box feature, which makes user register himself and create a rating of certain product, and visitors can vote. Just like epinions.com. Is there anything like that...
2
1206
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 sure yet if the development is being done in Vbscript or C#). I come from PHP background and I need to know about a bit of hosting requirements for asp.net. We are thinking of hosting in-house. I think the database is
0
1548
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 using Thinnig,Miniature Algorithms.Can any one help me regarding how to implement it Using Rs232 Port. Can any one help me regarding how to Code for RS-232 interface in Vb.net.I am currently using VS2005. Thanks In Advance
9
3051
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 rather it take into account the leap year, I am using the medium date format in my database, I would rather not mess about
4
1210
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
1577
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 end is done all in data access pages hosted on an IIS 5.0 server. This allows all of the sales people to look at their orders. Everything works great, the sales people love it and my job is pretty easy. The problem is that our General Manager loves it...
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10315
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10083
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9946
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8968
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7494
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6737
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2877
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.