Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
My coding sucks, help please!
Old 01-07-2010, 04:04 AM My coding sucks, help please!
RobK's Avatar
Ultra Talker

Posts: 276
Name: Robert
Location: TianJin, China
Trades: 5
Hello there,

As the title mentioned my coding is pretty much non-existent but I am learning. I am more of a designer that is trying to migrate some of my skills into coding.

Anyways... I have a customer that wants wants a relationship site updated. Basically he wants a function where if someone rolls over the image of a couple then a box with text appears offering different daily advice. No problem.

I am just not certain how to load the daily advice everyday without having to actually change it everyday manually. Certainly there is a way, would PHP be the choice for this? What do you coders recommend?
__________________
Freelance Designer available for hire
Please login or register to view this content. Registration is FREE

If I posted something helpful, please add to my Talkupation. Thanks a bunch!
RobK is offline
Reply With Quote
View Public Profile Visit RobK's homepage!
 
 
Register now for full access!
Old 01-07-2010, 05:33 AM Re: My coding sucks, help please!
Stephen.'s Avatar
Average Talker

Posts: 22
Name: Stephen
Trades: 0
What method are you using, prewritten ones or are you going to write say 30 and show 1 per day?

If you're showing 30 (I chose 30 as then you can do 1 per day of the month and you date() and compare with the date with it to chose the correct one). Then just create a div box to show onmouseover and to hide onmouseout.

The code you will probably want would be along the lines of:

Code:
$message[1] = "First of the month, good time to meet someone new";
$message[2] = "The moons orbit shows your going to be single forever!!! Mwahahahaha (Unless you give me money!)";

$date = date("d");
echo $message[$date];
Write a message all the way up to however many days are in the month. I only recommended this way as you're new to php. But it's also incredibly simple to alter so it takes your messages from a database too.

Let us know if it helped!
Stephen. is offline
Reply With Quote
View Public Profile
 
Old 01-10-2010, 04:24 PM Re: My coding sucks, help please!
vectorialpx's Avatar
Extreme Talker

Posts: 249
Name: octavian
Location: Bucharest
Trades: 0
Or, the short way

$mes = 'first day message
second day message
and so on';
// write one per line
$arrai = explode("\n",$mes);
if(isset($arrai[date('d')-1])) echo $arrai[date('d')-1];
__________________
you can
Please login or register to view this content. Registration is FREE
vectorialpx is offline
Reply With Quote
View Public Profile Visit vectorialpx's homepage!
 
Old 01-10-2010, 07:05 PM Re: My coding sucks, help please!
Stephen.'s Avatar
Average Talker

Posts: 22
Name: Stephen
Trades: 0
... That's exactly the same as what I suggested ,except your using 1 string and the explode function, where as I left that out so he can see the days easier. It's also the same length and much easier for the beginner coder.
__________________
Did I help you? If so add to my Talkupation! =]
Stephen. is offline
Reply With Quote
View Public Profile
 
Old 01-11-2010, 09:42 AM Re: My coding sucks, help please!
LongTimeGI's Avatar
Junior Talker

Posts: 1
Name: Mot
Trades: 0
I recommend Stephen's suggestion, however, you could add a little more "randomness" to it by using a multi-dimensional array thereby giving you a few options for each day, which means, the user would see different messages on the same day. For example:

$message[1][1] = "First option for day 1";
$message[1][2] = "Second option for day 1";
$message[1][3] = "Third option for day 1";

$message[2][1] = "First option for day 2";
$message[2][2] = "Second option for day 2";
$message[2][3] = "Third option for day 2";


$date = date("d");
echo $message[$date][Math.floor(Math.random()*3)]

NOTE: I hardcoded the "3" in the random function to match the number of options you have for each day. Also, make sure that each day has the same number of options.
__________________
Mot
LongTimeGI is offline
Reply With Quote
View Public Profile
 
Old 01-14-2010, 03:34 PM Re: My coding sucks, help please!
vectorialpx's Avatar
Extreme Talker

Posts: 249
Name: octavian
Location: Bucharest
Trades: 0
Quote:
Originally Posted by Stephen. View Post
... That's exactly the same as what I suggested ,except your using 1 string and the explode function, where as I left that out so he can see the days easier. It's also the same length and much easier for the beginner coder.
Technically it's the same thing BUT in my code you can make a copy-paste from a document and let PHP take every line. In your code you must define arrays, so you must add every sentence
__________________
you can
Please login or register to view this content. Registration is FREE
vectorialpx is offline
Reply With Quote
View Public Profile Visit vectorialpx's homepage!
 
Old 01-14-2010, 04:31 PM Re: My coding sucks, help please!
Brian07002's Avatar
Defies a Status

Posts: 2,162
Name: ...
Location: ...
Trades: 0
Storing the information inside a database could also help in constructing this idea. You will be a lot better off using the db if your plan on having alot of advice to store in the db. As a side note, you don't need a db if you don't have much content, the db just makes it easier to handle alot more information. Mysql or MsSql are two db types you can look into.
__________________
Made2Own

Please login or register to view this content. Registration is FREE
Brian07002 is offline
Reply With Quote
View Public Profile
 
Old 01-14-2010, 06:58 PM Re: My coding sucks, help please!
Stephen.'s Avatar
Average Talker

Posts: 22
Name: Stephen
Trades: 0
Quote:
Originally Posted by vectorialpx View Post
Technically it's the same thing BUT in my code you can make a copy-paste from a document and let PHP take every line. In your code you must define arrays, so you must add every sentence
Yes, but with the title of this thread, saying his coding sucks, it's much simpler to use it without SQL as it's very simple for him then
__________________
Did I help you? If so add to my Talkupation! =]
Stephen. is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to My coding sucks, help please!
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.26769 seconds with 12 queries