 |
Account Login
|
 |
 |
Latest Articles
|
 |
 |
IRC Channel
|
 |
 |
Associates
|
 |
 |
Associates
|
 |
|
 |
 |
|
 |
02-03-2008, 10:39 AM
|
#1 (permalink)
|
|
The Prestige
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
|
Poll System, page blank. :/
PHP Code:
<?php
session_start();
require 'config.php';
?>
<html>
<head>
<title>Poll System</title>
<style>
div.container {
background:#eee;
border:1px solid grey;
padding:.20em;
margin:auto;
display:inline;
}
div.title {
font-family:arial;
font-weight:bold;
color:red;
padding:.10em;
border:1px solid grey;
font-size:15px;
display:block;
}
div.amount {
font-weight:bold;
font-size:15px;
font-family:Helvetica;
color:black;
padding:.10em;
border-left:1px solid grey;
border-bottom:1px solid grey;
display:block;
}
div.option {
font-weight:bolder;
font-size:15px;
font-family:helvetica;
color:black;
display:block;
}
div.bar {
background: url('bar.png') repeat-x;
display:inline;
height:7px;
width:<?php
number_format(ceil($row['amount']));
?>;
}
</style>
</head>
<body>
<?php
$id = $_GET['id'];
$img = '';
if ( isset($id) && !isset($query) )
{
$query = mysql_query("SELECT * FROM `polls` WHERE `id`='$id' LIMIT 5");
while ($row = mysql_fetch_array($query) or die(mysql_error()))
{
if (mysql_num_rows($id)!=0)
{
if (isset($row['options']) || !empty($row['options']))
{
if ($row['title'])
{
print '<div class="title">'.$row['title']."</div><br />";
}
if ($row['options'])
{
for ($i=1;$i<=$row['options'];$i++)
{
$o = $row['options'];
echo '<div class="option">'.$o[$i].'</div>';
}
}
if (strlen($row['amount'])>=1)
{
echo '<div class="amount">'.number_format($row['amount']).'</div><br />';
}
elseif (strlen($row['amount'])==0)
{
echo 'No one has voted yet!';
}
if ($id)
{
$id = $row['id'];
}
}
}
}
}
?>
</body>
</html>
Heres the sql:
sql Code:
CREATE TABLE `polls` ( `id` int(10) NOT NULL AUTO_INCREMENT PRIMARY KEY, `title` varchar(20) NOT NULL, `options` varchar(2000) NOT NULL, `amount` varchar(36665) NOT NULL, )ENGINE=INNODB
None of it outputs anything. -_- I suck at making MySQL Applications. BAH!
__________________
VillageIdiot can have my babbies ;d
|
|
|
|
02-03-2008, 11:06 AM
|
#2 (permalink)
|
|
The Prestige
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
|
Orc.. it's fine that you're looking for support for your codes, but you don't have to PM me everytime you create a new thread.. I'm sure people will find their way to the thread anyways 
|
|
|
|
02-03-2008, 12:10 PM
|
#3 (permalink)
|
|
The Prestige
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
|
Quote:
Originally Posted by Tanax
Orc.. it's fine that you're looking for support for your codes, but you don't have to PM me everytime you create a new thread.. I'm sure people will find their way to the thread anyways 
|
You really gave me hope when looking. v_v
__________________
VillageIdiot can have my babbies ;d
|
|
|
|
02-03-2008, 01:00 PM
|
#4 (permalink)
|
|
The Frequenter
Join Date: Nov 2007
Location: Netherlands
Posts: 460
Thanks: 49
|
sql Code:
CREATE TABLE `polls` ( `id` int(10) NOT NULL AUTO_INCREMENT PRIMARY KEY, `title` varchar(20) NOT NULL, `options` varchar(2000) NOT NULL, `amount` varchar(36665) NOT NULL, )ENGINE=INNODB
First off, this is honestly no way to make a poll. Your title should be varchar(255), options should be a longtext and as for amount, I seriously don't know what you want with this one.
Do not be scared of making more tables. A poll can easily take up 2 or more database tables. First the cats, then the poll itself, the options and the votes and so on. Maybe even a configurationtable for the options.
I would first have to know what is in your database and how it is composed. I do not think this is the right approach. You keep checking if there is data but the poll can't exist without data, so the checks are useless. Make sure you do not use the $_GET['id']. Or only when it's directly linked to. That'll be OK.
I think your first step it to take it from the ground up again and make sure every time you echo something making sure the script is working.
Quote:
Originally Posted by Tanax
Orc.. it's fine that you're looking for support for your codes, but you don't have to PM me everytime you create a new thread.. I'm sure people will find their way to the thread anyways 
|
When you make a post like that, you could've easily helped him out.
__________________
"Life is a bitch, take that bitch on a ride"
|
|
|
|
The Following User Says Thank You to ReSpawN For This Useful Post:
|
|
02-03-2008, 01:04 PM
|
#5 (permalink)
|
|
The Prestige
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
|
Quote:
Originally Posted by ReSpawN
sql Code:
CREATE TABLE `polls` ( `id` int(10) NOT NULL AUTO_INCREMENT PRIMARY KEY, `title` varchar(20) NOT NULL, `options` varchar(2000) NOT NULL, `amount` varchar(36665) NOT NULL, )ENGINE=INNODB
First off, this is honestly no way to make a poll. Your title should be varchar(255), options should be a longtext and as for amount, I seriously don't know what you want with this one.
Do not be scared of making more tables. A poll can easily take up 2 or more database tables. First the cats, then the poll itself, the options and the votes and so on. Maybe even a configurationtable for the options.
I would first have to know what is in your database and how it is composed. I do not think this is the right approach. You keep checking if there is data but the poll can't exist without data, so the checks are useless. Make sure you do not use the $_GET['id']. Or only when it's directly linked to. That'll be OK.
I think your first step it to take it from the ground up again and make sure every time you echo something making sure the script is working.
When you make a post like that, you could've easily helped him out.
|
Thanks a lot! :D I will remake it.. :] And remember what you said. I'm just a newbie at MySQL, when I'm making these applications, it really just messed with me and my code. You know. :D
__________________
VillageIdiot can have my babbies ;d
|
|
|
|
02-03-2008, 03:42 PM
|
#6 (permalink)
|
|
The Prestige
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
|
Quote:
Originally Posted by ReSpawN
When you make a post like that, you could've easily helped him out.
|
No, because firstly, I've never made a poll before so I have no clue.
And secondly, I think it's the wrong way to go to PM everyone on the forum to get attention to their thread. It's a forum, so everyone will read it eventually anyways!
Lastly, I was really in a hurry to my tap lesson, so even if I could help him, I didn't have the time!
  
|
|
|
|
02-03-2008, 03:58 PM
|
#7 (permalink)
|
|
The Frequenter
Join Date: Dec 2007
Location: Bucharest, Romania
Posts: 438
Thanks: 3
|
I've built a poll system some time ago. Perhaps it could help you in some way... I've attached it if you need to document.
__________________
I have optimistic thoughts, even though sometimes (if not always) life's a bitch.
|
|
|
|
|
The Following User Says Thank You to xenon For This Useful Post:
|
|
02-03-2008, 05:40 PM
|
#8 (permalink)
|
|
The Frequenter
Join Date: Nov 2007
Location: Netherlands
Posts: 460
Thanks: 49
|
Quote:
Originally Posted by Tanax
No, because firstly, I've never made a poll before so I have no clue.
And secondly, I think it's the wrong way to go to PM everyone on the forum to get attention to their thread. It's a forum, so everyone will read it eventually anyways!
Lastly, I was really in a hurry to my tap lesson, so even if I could help him, I didn't have the time!
  
|
I meant no harm! Tap on mate. 
Orc, if it doesn't work out and IF you have MSN, you can add or email me on markernstproductions@gmaill.com or info@markernst.com.
Hopefully you'll work it out on your own, since that provides the best insight and experience.  Feel free to contact me non the less.
__________________
"Life is a bitch, take that bitch on a ride"
|
|
|
02-03-2008, 07:03 PM
|
#9 (permalink)
|
|
The Prestige
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
|
Quote:
Originally Posted by ReSpawN
I meant no harm! Tap on mate. 
Orc, if it doesn't work out and IF you have MSN, you can add or email me on markernstproductions@gmaill.com or info@markernst.com.
Hopefully you'll work it out on your own, since that provides the best insight and experience.  Feel free to contact me non the less.
|
I probably will figure it out on my own, when I'm faced with a challenge ( speciously in programming ), I work hard and try so many ways to beat it, if all else fails, and my mind goes blank, I ask for support. So far it happened in this thread considering, I didn't know what the crap was going on. :P
__________________
VillageIdiot can have my babbies ;d
|
|
|
|
02-03-2008, 07:49 PM
|
#10 (permalink)
|
|
The Frequenter
Join Date: Nov 2007
Location: Netherlands
Posts: 460
Thanks: 49
|
That's the spirit! Hopefully you'll post the result? If you're still kinda new to the mySQL scene, you could try expanding the poll script to learn new techniques.
__________________
"Life is a bitch, take that bitch on a ride"
|
|
|
02-03-2008, 08:02 PM
|
#11 (permalink)
|
|
The Prestige
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
|
Quote:
Originally Posted by ReSpawN
That's the spirit! Hopefully you'll post the result? If you're still kinda new to the mySQL scene, you could try expanding the poll script to learn new techniques.
|
Well I've been looking at the MySQL reference manuel non stop. :P
__________________
VillageIdiot can have my babbies ;d
|
|
|
|
02-04-2008, 03:48 PM
|
#12 (permalink)
|
|
The Acquainted
Join Date: Jan 2008
Posts: 136
Thanks: 4
|
I would try to expand this script by including an admin panel: allows you to use DELETE * FROM etc :)
|
|
|
|
02-04-2008, 04:38 PM
|
#13 (permalink)
|
|
The Frequenter
Join Date: Nov 2007
Location: Netherlands
Posts: 460
Thanks: 49
|
Quote:
Originally Posted by Gareth
I would try to expand this script by including an admin panel: allows you to use DELETE * FROM etc :)
|
A shorter version of what I already was suggesting mate. 
__________________
"Life is a bitch, take that bitch on a ride"
|
|
|
02-04-2008, 04:47 PM
|
#14 (permalink)
|
|
The Prestige
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
|
Not yet please, allow me to make what I need first.
__________________
VillageIdiot can have my babbies ;d
|
|
|
|
02-04-2008, 05:56 PM
|
#15 (permalink)
|
|
Wizard
Join Date: Sep 2007
Posts: 1,299
Thanks: 17
|
Just a note on varchar, the max length if 255 so don't put any values above it. For larger text, use the text type.
|
|
|
|
|
The Following User Says Thank You to Village Idiot For This Useful Post:
|
|
02-04-2008, 06:31 PM
|
#16 (permalink)
|
|
The Prestige
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
|
Quote:
Originally Posted by Village Idiot
Just a note on varchar, the max length if 255 so don't put any values above it. For larger text, use the text type.
|
don't you mean longtext?
__________________
VillageIdiot can have my babbies ;d
|
|
|
|
02-04-2008, 07:15 PM
|
#17 (permalink)
|
|
The Frequenter
Join Date: Dec 2007
Location: Bucharest, Romania
Posts: 438
Thanks: 3
|
No, he meant text. Check out the differences between MySQL data types here:
MySQL Field Types
__________________
I have optimistic thoughts, even though sometimes (if not always) life's a bitch.
|
|
|
|
02-05-2008, 06:59 AM
|
#18 (permalink)
|
|
The Prestige
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
|
Quote:
Originally Posted by Village Idiot
Just a note on varchar, the max length if 255 so don't put any values above it. For larger text, use the text type.
|
Quote:
Originally Posted by xenon
No, he meant text. Check out the differences between MySQL data types here:
MySQL Field Types
|
And LongText is suppose to be longer some how than Text :P
__________________
VillageIdiot can have my babbies ;d
|
|
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|