Hello, newbie, here. Need help with adding the following to my site. Thanks a bunch in advance.
I already have two php databases and a site that draws info from these databases:
Member: Member ID with registration date
Message: Message ID with corresponding message
What I would like to do is show a particular message based on how many days have elapsed since registration date.
For example, 1 day after registration, display the message for Message ID=1.
100 days after registration, display the message for Message ID=100.
What code do I need to display this? Thanks a bunch!
need help with simple coding
Moderator: General Moderators
need help with simple coding
Last edited by realsole on Fri Jul 22, 2011 12:41 pm, edited 1 time in total.
- social_experiment
- DevNet Master
- Posts: 2793
- Joined: Sun Feb 15, 2009 11:08 am
- Location: .za
Re: need help with simple coding
You would have to extract the information from the database using a query that matches what you want to findrealsole wrote:What I would like to do is show a particular text based on how many days have elapsed since registration date.
For example, 1 day after registration, display the text for Text ID=1.
100 days after registration, display the text for Text ID=100.
Code: Select all
<?php
$query = "SELECT something FROM table WHERE text = '" . mysql_real_escape_string($particularText) . "' ";
$sql = mysql_query($query);
?>“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
Re: need help with simple coding
This is the script I'm working with:
<?php
$sql=mysql_query("select msg_id,message from tbl_messages where msg_id='5'");
while($row=mysql_fetch_array($sql))
{
$id=$row['msg_id'];
$message=$row['message'];
?>
<div class="block" id="<?php echo $message;?>">
<center>Today's Message</center>
</div>
<?php
}
?>
This would be the script for day 5.
What I don't know how to do is replace the 5 with the difference between current date and the registration date.
$reg_date = $row['member_reg_date'];
from tbl_members
I would appreciate your help. Thanks.
<?php
$sql=mysql_query("select msg_id,message from tbl_messages where msg_id='5'");
while($row=mysql_fetch_array($sql))
{
$id=$row['msg_id'];
$message=$row['message'];
?>
<div class="block" id="<?php echo $message;?>">
<center>Today's Message</center>
</div>
<?php
}
?>
This would be the script for day 5.
What I don't know how to do is replace the 5 with the difference between current date and the registration date.
$reg_date = $row['member_reg_date'];
from tbl_members
I would appreciate your help. Thanks.
- social_experiment
- DevNet Master
- Posts: 2793
- Joined: Sun Feb 15, 2009 11:08 am
- Location: .za
Re: need help with simple coding
What determines which registration date is selected; a specific user id or do you select all registration dates?realsole wrote:What I don't know how to do is replace the 5 with the difference between current date and the registration date.
What is the format of the date retrieved?
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
Re: need help with simple coding
The registration date is established by member ID, on the date the member registers. This data resides in the member table, tbl_members.
The registration date is unique to each member.
I wish to have each member see a progression of messages that change as the number of days from registration changes. This means each member, after he/she logs in, sees their unique message based on how many days it has been since registration.
Thanks in advance.
The registration date is unique to each member.
I wish to have each member see a progression of messages that change as the number of days from registration changes. This means each member, after he/she logs in, sees their unique message based on how many days it has been since registration.
Thanks in advance.
- social_experiment
- DevNet Master
- Posts: 2793
- Joined: Sun Feb 15, 2009 11:08 am
- Location: .za
Re: need help with simple coding
The query to select the regsitration date could look like thisrealsole wrote:The registration date is established by member ID, on the date the member registers. This data resides in the member table, tbl_members.
Code: Select all
<?php
$query = "SELECT registration_date FROM tbl_members WHERE id = '" . $memberID . "' ";
?>“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering