TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   General (http://www.talkphp.com/general/)
-   -   Poll System, page blank. :/ (http://www.talkphp.com/general/2180-poll-system-page-blank.html)

Orc 02-03-2008 10:39 AM

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!

Tanax 02-03-2008 11:06 AM

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 :-P

Orc 02-03-2008 12:10 PM

Quote:

Originally Posted by Tanax (Post 10176)
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 :-P

You really gave me hope when looking. v_v

ReSpawN 02-03-2008 01:00 PM

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 (Post 10176)
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 :-P

When you make a post like that, you could've easily helped him out.

Orc 02-03-2008 01:04 PM

Quote:

Originally Posted by ReSpawN (Post 10181)
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

Tanax 02-03-2008 03:42 PM

Quote:

Originally Posted by ReSpawN (Post 10181)
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!

8-)8-):-D

xenon 02-03-2008 03:58 PM

1 Attachment(s)
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.

ReSpawN 02-03-2008 05:40 PM

Quote:

Originally Posted by Tanax (Post 10187)
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!

8-)8-):-D

I meant no harm! Tap on mate. :-D8-)

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.

Orc 02-03-2008 07:03 PM

Quote:

Originally Posted by ReSpawN (Post 10189)
I meant no harm! Tap on mate. :-D8-)

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

ReSpawN 02-03-2008 07:49 PM

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.

Orc 02-03-2008 08:02 PM

Quote:

Originally Posted by ReSpawN (Post 10193)
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

Gareth 02-04-2008 03:48 PM

I would try to expand this script by including an admin panel: allows you to use DELETE * FROM etc :)

ReSpawN 02-04-2008 04:38 PM

Quote:

Originally Posted by Gareth (Post 10224)
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. ;-)

Orc 02-04-2008 04:47 PM

Not yet please, allow me to make what I need first.

Village Idiot 02-04-2008 05:56 PM

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.

Orc 02-04-2008 06:31 PM

Quote:

Originally Posted by Village Idiot (Post 10240)
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?

xenon 02-04-2008 07:15 PM

No, he meant text. Check out the differences between MySQL data types here:

MySQL Field Types

Orc 02-05-2008 06:59 AM

Quote:

Originally Posted by Village Idiot (Post 10240)
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 (Post 10248)
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


All times are GMT. The time now is 07:43 PM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0