new guy with stupid question

new guy with stupid question

am 20.01.2006 09:46:29 von Lonny

Hello,
I am new to the list.
I thought I would call my question stupid just to raise some eyebrows to
those who might like to flame me for not reading some basic php/mysql books.
Fact is - I have -
I have been working with some scripts where I can change them and expand on
them to suit my needs.
I really don't think my question is stupid.
It is just that time is of the essence and I am optimistic that I might make
some friends to help me with some quick answers to get my scripts running.

OK, sorry for the long winded info.
For today I will ask for a script that will gather emails from the email
field of a table in a database and send a news letter to those emails.
How do I compose the email formatted with html for a professional look and
send it to everyone in the database.

If I haven't got myself kicked of this list yet, here is another basic
question.

I want users to be able to select a date for their schedule.
I do not want them to have to follow the format of yyyy-mm-dd
I just want them to select a month from a pulldown, then a day, and then a
year. (I have all this set up all ready)
What is confusing me is the part where I need to think out of the box a bit
and combine there three selection into a date field.
Like $month + $day + $year
INSERT $month$day$year into $date; and come up with something that looks
like 2006-08-13
I hope you know what I am trying to do here.

Have I made any friends yet?
Lonny

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: new guy with stupid question

am 20.01.2006 10:07:56 von Aaron Koning

------=_Part_18366_568609.1137748076457
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

$date =3D $month."-".$day."-".$year;
$query =3D "INSERT INTO sometable (date) VALUES ('$date');";

Hope this works for you,
Aaron

On 1/20/06, Lonny wrote:
>
>
> Hello,
> I am new to the list.
> I thought I would call my question stupid just to raise some eyebrows to
> those who might like to flame me for not reading some basic php/mysql
> books.
> Fact is - I have -
> I have been working with some scripts where I can change them and expand
> on
> them to suit my needs.
> I really don't think my question is stupid.
> It is just that time is of the essence and I am optimistic that I might
> make
> some friends to help me with some quick answers to get my scripts running=
..
>
> OK, sorry for the long winded info.
> For today I will ask for a script that will gather emails from the email
> field of a table in a database and send a news letter to those emails.
> How do I compose the email formatted with html for a professional look an=
d
> send it to everyone in the database.
>
> If I haven't got myself kicked of this list yet, here is another basic
> question.
>
> I want users to be able to select a date for their schedule.
> I do not want them to have to follow the format of yyyy-mm-dd
> I just want them to select a month from a pulldown, then a day, and then =
a
> year. (I have all this set up all ready)
> What is confusing me is the part where I need to think out of the box a
> bit
> and combine there three selection into a date field.
> Like $month + $day + $year
> INSERT $month$day$year into $date; and come up with something that looks
> like 2006-08-13
> I hope you know what I am trying to do here.
>
> Have I made any friends yet?
> Lonny
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

------=_Part_18366_568609.1137748076457--

Re: new guy with stupid question

am 20.01.2006 10:13:16 von Balazs Hegedus

Hi,

Here's what I found googling around (with these keywords: html email php):

http://www.sitepoint.com/article/advanced-email-php

didn't read it through, but looks good imho (and there's more).
And my apologies but I really don't understand your second question. :)

Balazs

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: new guy with stupid question

am 20.01.2006 10:19:11 von jeffreyb

Lonny wrote:

>OK, sorry for the long winded info.
>For today I will ask for a script that will gather emails from the email
>field of a table in a database and send a news letter to those emails.
>How do I compose the email formatted with html for a professional look and
>send it to everyone in the database.
>
>If I haven't got myself kicked of this list yet, here is another basic
>question.
>
>I want users to be able to select a date for their schedule.
>I do not want them to have to follow the format of yyyy-mm-dd
>I just want them to select a month from a pulldown, then a day, and then a
>year. (I have all this set up all ready)
>What is confusing me is the part where I need to think out of the box a bit
>and combine there three selection into a date field.
>Like $month + $day + $year
>INSERT $month$day$year into $date; and come up with something that looks
>like 2006-08-13
>I hope you know what I am trying to do here.
>
>Have I made any friends yet?
>Lonny
>
>
>
Lonny:

Don't slag yourself off so much. That's what this list is for ;o)

First question...

$subject="Email subject line";
$body="Newsletter content";
$return_address="From: email@address.somewhere";

$query="SELECT $email_address FROM some_table";
$result=mysql_query($query) or die("Something went wrong, sweetheart: "
.. mysql_error());
while($row=mysql_fetch_array($result)){
extract($row);
mail($email,$subject,$body,$return_address);
}
Untested, but should work. And I know some of the people on the list
will say that the mysql_fetch_array() is not the best approach - but you
can fiddle with mysql_fetch_row() if you'd prefer. It would probably be
a bit more efficient.

As to HTML content for your newsletter, I would test first. Create a
newsletter, send it to yourself and, if possible a couple of other
people. Try various layouts until it looks right. But bear in mind that
different e-mail clients are not consistent with the display of html
content. So try as many different clients as you can, especially
Outlook, Lotus Notes (if there are a lot of busness users), Thunderbird,
Gmail, hotmail, etc.

For what it's worth, I do a popular and highly regarded newsletter
entirely in ASCII text. Of the over 2000 subscribers, only one person
every complained about the appearance - and his complaints were such
that it was clear he wasn't remotely interested in the actual content of
the newsletter.

For the last question, get the date info from your drop down menus, then
in php...

$date_for_db=$year."-".$month."-".$day;

....and insert $date_for_db into your table.

Good luck,

Jeffrey

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: new guy with stupid question

am 20.01.2006 10:30:14 von Balazs Hegedus

Hi,

Aaron helped me to understand the question so here's an add-in to his comme=
nt.


if ($_SERVER['REQUEST_METHOD'] ===3D 'GET') {//'GET' !== 'get'
//display form (using POST method)
}
elseif ($_SERVER['REQUEST_METHOD'] ===3D 'POST' &&
isset($_POST['_non-optional_fields_']) &&
is_numeric($_POST['_year_field_']) &&
is_numeric($_POST['_month_field_']) &&
is_numeric($_POST['_day_field_']) &&
checkdate($_POST['_month_field_'], $_POST['_day_field_'],
$_POST['_year_field_'])) {
//process the form
$date =3D $_POST['_year_field_'] . '-' . $_POST['_month_field_'] . '-' .
$_POST['_day_field_'];
$sqlInsertNewDate =3D "INSERT INTO table_name (date_field) VALUES ('" .
$date . "')";
}
else {
//some error message or redirection here
}

?>

from the MySQL manual:

MySQL version through 4.1 accept certain "illegal" values for dates,
such as '1999-11-31'. This is useful when you want to store a possibly
incorrect value specified by a user (for example, in a web form) in
the database for future processing. MySQL verifies only that the month
is in the range from 0 to 12 and that the day is in the range from 0
to 31.

that's why checkdate() is important.

Hope it helped.

Balazs

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

RE: new guy with stupid question

am 20.01.2006 12:10:50 von Lonny

-----Original Message-----
From: Lonny [mailto:lonny@lonny.com]
Sent: Friday, January 20, 2006 3:46 AM
To: php-db@lists.php.net
Subject: [PHP-DB] new guy with stupid question


Hello,
I am new to the list.
I thought I would call my question stupid just to raise some eyebrows to
those who might like to flame me for not reading some basic php/mysql books.
Fact is - I have -
I have been working with some scripts where I can change them and expand on
them to suit my needs.
I really don't think my question is stupid.
It is just that time is of the essence and I am optimistic that I might make
some friends to help me with some quick answers to get my scripts running.

OK, sorry for the long winded info.
For today I will ask for a script that will gather emails from the email
field of a table in a database and send a news letter to those emails.
How do I compose the email formatted with html for a professional look and
send it to everyone in the database.

If I haven't got myself kicked of this list yet, here is another basic
question.

I want users to be able to select a date for their schedule.
I do not want them to have to follow the format of yyyy-mm-dd
I just want them to select a month from a pulldown, then a day, and then a
year. (I have all this set up all ready)
What is confusing me is the part where I need to think out of the box a bit
and combine there three selection into a date field.
Like $month + $day + $year
INSERT $month$day$year into $date; and come up with something that looks
like 2006-08-13
I hope you know what I am trying to do here.

Have I made any friends yet?
Lonny

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: new guy with stupid question

am 21.01.2006 06:08:00 von Julien Bonastre

In reference to Jeffrey's comment about the performance of
mysql_fetch_row vs mysql_fetch_array, which I always have used the
_array implementation:

From the horses mouth:
Performance: An important thing to note is that using
mysql_fetch_array() is not significantly slower than using
mysql_fetch_row(), while it provides a significant added value

[source: www.php.net/manual/en/function.mysql-fetch-array.php ]


tata!

----- Original Message -----
From: "Jeffrey"
To:
Sent: Friday, January 20, 2006 7:19 PM
Subject: Re: [PHP-DB] new guy with stupid question


> Lonny wrote:
>
>>OK, sorry for the long winded info.
>>For today I will ask for a script that will gather emails from the
>>email
>>field of a table in a database and send a news letter to those emails.
>>How do I compose the email formatted with html for a professional look
>>and
>>send it to everyone in the database.
>>
>>If I haven't got myself kicked of this list yet, here is another basic
>>question.
>>
>>I want users to be able to select a date for their schedule.
>>I do not want them to have to follow the format of yyyy-mm-dd
>>I just want them to select a month from a pulldown, then a day, and
>>then a
>>year. (I have all this set up all ready)
>>What is confusing me is the part where I need to think out of the box
>>a bit
>>and combine there three selection into a date field.
>>Like $month + $day + $year
>>INSERT $month$day$year into $date; and come up with something that
>>looks
>>like 2006-08-13
>>I hope you know what I am trying to do here.
>>
>>Have I made any friends yet?
>>Lonny
>>
>>
> Lonny:
>
> Don't slag yourself off so much. That's what this list is for ;o)
>
> First question...
>
> $subject="Email subject line";
> $body="Newsletter content";
> $return_address="From: email@address.somewhere";
>
> $query="SELECT $email_address FROM some_table";
> $result=mysql_query($query) or die("Something went wrong, sweetheart:
> " . mysql_error());
> while($row=mysql_fetch_array($result)){
> extract($row);
> mail($email,$subject,$body,$return_address);
> }
> Untested, but should work. And I know some of the people on the list
> will say that the mysql_fetch_array() is not the best approach - but
> you can fiddle with mysql_fetch_row() if you'd prefer. It would
> probably be a bit more efficient.
>
> As to HTML content for your newsletter, I would test first. Create a
> newsletter, send it to yourself and, if possible a couple of other
> people. Try various layouts until it looks right. But bear in mind
> that different e-mail clients are not consistent with the display of
> html content. So try as many different clients as you can, especially
> Outlook, Lotus Notes (if there are a lot of busness users),
> Thunderbird, Gmail, hotmail, etc.
>
> For what it's worth, I do a popular and highly regarded newsletter
> entirely in ASCII text. Of the over 2000 subscribers, only one person
> every complained about the appearance - and his complaints were such
> that it was clear he wasn't remotely interested in the actual content
> of the newsletter.
>
> For the last question, get the date info from your drop down menus,
> then in php...
>
> $date_for_db=$year."-".$month."-".$day;
>
> ...and insert $date_for_db into your table.
>
> Good luck,
>
> Jeffrey
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>
> --
> No virus found in this incoming message.
> Checked by AVG Anti-Virus.
> Version: 7.1.375 / Virus Database: 267.14.21/235 - Release Date:
> 19/01/2006
>
>



--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.1.375 / Virus Database: 267.14.21/236 - Release Date: 20/01/2006

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php