Adding multiple date in a field

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
onimmusha
User
Posts: 5

Adding multiple date in a field

Post by onimmusha »

Hi, guys. I'm a new user of phpmaker and I got a question regarding a module. I want to make a ad subcribtion registration page where in that page there are the start date field, end date field, field for dates where the ad are not launched, and field for days in the week where the ad are not launched (like in every sunday or monday or sunday and monday). I got no problem with the first two fields but the last two fields has been wrecking my head. Can someone help me with this problem? Thank you beforehand.


mobhar
User
Posts: 11905

Post by mobhar »

You can create the third field which has a varchar type. In other words, the value of the field might be like "1,2,3,4,5,6,7" or "2,3,4", and so forth. From "Fields" setup of PHPMaker, use the field as a "Multiple Select" control.


onimmusha
User
Posts: 5

Post by onimmusha »

Thank you mobhar for the quick reply. Really sorry to say, there's some detail that I haven't mentioned before. The page will input the date into database as a series of dates ranged from the start date and end date. For example if we input 2013/8/8 as start date and 2013/8/18 as end date, it will input 10 entry of dates into the database. I've already taken care of that. But the problem is with the third and fourth field where I have to exclude the entry based on data that inputted there. The dates inputted in the third field are excluded. And also the dates which day mentioned in the fourth field also excluded. That's why my head been hurting since I got this task. And regarding the last post, I've tried to look into that but can't find the 'Multiple Select' option on field page, found multi-update instead. Can you, or anyone help me with this? Thanks


mobhar
User
Posts: 11905

Post by mobhar »

If you want to exclude the fields on the Add and Edit form, then simply uncheck the fields from "Fields" setup -> under the "Add" and "Edit" column. Afterwards, write your own code in the "Row_Inserting" and "Row_Updating" to update the third and fourth fields.

Regarding the "Multiple Select", actually, it is a "Select" control which has "Multiple" option enable under the "Select Tag Attributes".


onimmusha
User
Posts: 5

Post by onimmusha »

I found the one you mentioned about the Select Tag Attributes (unter the drop box field).

I am really sorry about this, think it's either I didn't explain it properly or you didn't get my question. I'll give you an example of what my client wants.

input start date : 2013/08/08
input End date : 2013/08/18
input dates when the ad doesn't appear (excluded dates) : 2013/08/09, 2013/08/13, 2013/08/14
input days when the ad doesn't appear (excluded dates based on the days selected) : Sunday and Monday

the entries in the database will be 2013/08/08, 2013/08/10, 2013/08/15, 2013/08/16 and 2013/08/17.

2013/08/09, 2013/08/13 and 2013/08/14 won't be inputted because we've already specify it,
2013/08/12 won't appear because it's Monday and,
2013/08/11 and 2013/08/18 won't appear because it's Sunday.

I hope this example will explain more about my question. Thanks.


mobhar
User
Posts: 11905

Post by mobhar »

So, the question is, in which part now you encounter the problem? Can you show us what have you done so far (like the code, etc)?


onimmusha
User
Posts: 5

Post by onimmusha »

I apologize, I guess I didn't really mentioned my question there.
So here the question, can phpmaker make a field to input multiple date/or day, and help me omit/exclude the date mentioned in the 3rd and 4th field (based on the example before)? Or do I have to code them by myself in another php page?

What I've done is putting strtotime codes in the row inserted, row updated and row deleted events in phpmaker. Here the example of the row inserted that take care the start and end date range.

// Row Inserted event
function Row_Inserted($rsold, &$rsnew) {
$date=$rsnew['tgl_mulai'];
$end_date=$rsnew['tgl_selesai'];
$no_order=$rsnew['no_order'];
$keterangan=$rsnew['keterangan'];
// Start date
// $date = '2013-07-01';
// End date
//$end_date = '2013-09-01';
$con=mysqli_connect("localhost","root","","satelit");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
while (strtotime($date) <= strtotime($end_date))
mysqli_query($con,"INSERT INTO tgl_tayang (no_order, tgl_tayang, keterangan) VALUES ('$no_order', '$date' ,'$keterangan')");
echo "$date\n <br>";
$date = date ("Y-m-d", strtotime("+1 day", strtotime($date)));
}
mysqli_close($con);
}

Thank you very much for bear with me and my question.


mobhar
User
Posts: 11905

Post by mobhar »

onimmusha wrote:
So here the question, can phpmaker make a field to input multiple date/or day, and
help me omit/exclude the date mentioned in the 3rd and 4th field (based on the example
before)? Or do I have to code them by myself in another php page?

You have to write the code by yourself since there are no such built-in feature in PHPMaker.


danielc
User
Posts: 1599

Post by danielc »

onimmusha wrote:
So here the question, can phpmaker make a field to input multiple date/or day, and
help me omit/exclude the date mentioned in the 3rd and 4th field (based on the example
before)? Or do I have to code them by myself in another php page?

For your 3rd field, you can define it as a string. Input for this field can be date1, date2, .... So, you can use php explode() to get the date.
For your 4th field, you can define it as checkbox, monday - sunday. So, user check the box to select (multi-select). See Field setup in help file.

Then you write your program to exclude those date.


onimmusha
User
Posts: 5

Post by onimmusha »

I see, I've been expecting this answer but... oh well, I'll make it happen somehow. Thanks for the help guys :D


Post Reply