gurpreet Posted December 15, 2008 Posted December 15, 2008 i have MCcodes. i was wondering how to add a link thing in to my header so that it says "have you voted today?", but ONLY if they havent voted. if they have this sign goes. i know it may be easy for some, but i suck at coding so please help. Quote
shaved92bravada Posted December 15, 2008 Posted December 15, 2008 Re: Voted Today? I did that on my game the easiest way I found to do it was add add another field in the users table called voted or something and then when they click the vote link it updates that field +1 and then depending on how many vote links you have ... in your header you could do something link if ($ir['voted'] < 5) { echo ' Have you voted today?? '; } That should work for what your wanting. Then in your day cron just make it trunicate (empty) the "voted" field so that it does that same thing the next day. Quote
AlabamaHit Posted December 15, 2008 Posted December 15, 2008 Re: Voted Today? couldnt you do it this way? $votes = sprintf("SELECT list FROM votes WHERE userid = '%u' ", ($ir['userid'])); $vote = mysql_query($votes); if(mysql_num_rows($vote) >2)//Change the 2 to however many there are. { echo "some message"; } that is not tested Quote
shaved92bravada Posted December 15, 2008 Posted December 15, 2008 Re: Voted Today? lol hell I dunno, thats way over my skills of programming as of yet lol. I am still wanting to learn the whole sprintf part. Once I do that I am going to go sprintf crazy on this damn messy v2 script lol. Took a look at it over at the normal learnin place but was too tired at the time to take it in and learn it. Quote
AlabamaHit Posted December 15, 2008 Posted December 15, 2008 Re: Voted Today? lol hell I dunno, thats way over my skills of programming as of yet lol. I am still wanting to learn the whole sprintf part. Once I do that I am going to go sprintf crazy on this damn messy v2 script lol. Took a look at it over at the normal learnin place but was too tired at the time to take it in and learn it. lol thats funny right there. without sprintf would be this... $vote = $db->query("SELECT list FROM votes WHERE userid = ".$ir['userid']." "); if(mysql_num_rows($vote) >2)//Change the 2 to however many there are. { echo "some message"; } what im not sure is goin to work is the query itself, it might nix up the userid Quote
shaved92bravada Posted December 15, 2008 Posted December 15, 2008 Re: Voted Today? ahhh now thats more like it lol. looks like it would work.... I didn't think of doing it that way ( 1000 watt light bulb flashes on ) I just might try that and see if I can get it to work. And I will conquor that damn sprintf one of these days, I know its better I just don't know the pros and cons of it quite yet. I have had my nose stuck in these damn templates for too long lol its about time to get my head out of the sand and get back to learning other things. Quote
AlabamaHit Posted December 15, 2008 Posted December 15, 2008 Re: Voted Today? you will get it...just takes pratice and reading, .....alot of reading, lol Quote
gurpreet Posted December 16, 2008 Author Posted December 16, 2008 Re: Voted Today? lol hell I dunno, thats way over my skills of programming as of yet lol. I am still wanting to learn the whole sprintf part. Once I do that I am going to go sprintf crazy on this damn messy v2 script lol. Took a look at it over at the normal learnin place but was too tired at the time to take it in and learn it. lol thats funny right there. without sprintf would be this... $vote = $db->query("SELECT list FROM votes WHERE userid = ".$ir['userid']." "); if(mysql_num_rows($vote) >2)//Change the 2 to however many there are. { echo "some message"; } what im not sure is goin to work is the query itself, it might nix up the userid So would this work? and i think i put in the header, right? Quote
AlabamaHit Posted December 16, 2008 Posted December 16, 2008 Re: Voted Today? use the sprintf one. Not the $db->query one.... I was jsut showing him that so he would see something familiar. Quote
gurpreet Posted December 16, 2008 Author Posted December 16, 2008 Re: Voted Today? $votes = sprintf("SELECT list FROM votes WHERE userid = '%u' ", ($ir['userid'])); $vote = mysql_query($votes); if(mysql_num_rows($vote) >2)//Change the 2 to however many there are. { echo "some message"; } with the >2 what does that mean? number of vote sites? Quote
AlabamaHit Posted December 16, 2008 Posted December 16, 2008 Re: Voted Today? change the 2 to the number of sites you have to vote on...... Also rember that was untested it might not even work.... Quote
POG1 Posted December 16, 2008 Posted December 16, 2008 Re: Voted Today? echo ($votes > 4) ? 'Vote':''; Quote
gurpreet Posted December 17, 2008 Author Posted December 17, 2008 Re: Voted Today? echo ($votes > 4) ? 'Vote':''; Doesn't work for me when I use: echo ($votes > 4) ? '<u>Vote</u>':''; Quote
POG1 Posted December 17, 2008 Posted December 17, 2008 Re: Voted Today? echo ($ir['voted'] > 4) ? '<u>Vote</u>':''; Quote
gurpreet Posted December 17, 2008 Author Posted December 17, 2008 Re: Voted Today? Parse error: syntax error, unexpected T_ECHO, expecting T_FUNCTION in /home/gurpreet/public_html/header.php on line 205 Which is the vote script line Quote
POG1 Posted December 17, 2008 Posted December 17, 2008 Re: Voted Today? that bit of code i posted will work, i tried it lol Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.