how to insert three dropdown valuein one field in to database - dropdownbox

How can i insert three dropdown values in one field into my database for inserting date of birth. I am $dob variable is it ok or not? please help me.
My form is
<form name="" id="order-form" class="smart-form" role="form" action="" method="post" enctype="multipart/form-data">
<tr>
<td><font color="#334D66"> Date of Birth: </td>
<td><select name="birthday">
<option selected></option>
<option>01</option>
<option>02</option>
.
.
</select>
<select name="birthmonth">
<option selected></option>
<option>January</option>
<option>February</option>
.
.
</select>
<select name="birthyear">
<option selected></option>
<option>1999</option>
<option>1998</option>
.
.
</select>
</td>
</tr>
AND
my insert code like this
<?php
if(isset($_POST['submit']))
{
$day=$_POST['birthday'];
$month=$_POST['birthmonth'];
$year=$_POST['birthyear'];
$dob = $day.'/'.$month.'/'.$year;
$data =array('username' => $_POST['username'],
'firstname' => $_POST['firstname'],
'lastname' => $_POST['lastname'],
'email' => $_POST['email'],
'homepage' => $_POST['homepage'],
'adress' => $_POST['adress'],
'city' => $_POST['city'],
'province_id' => $_POST['province_id'],
'postcode' => $_POST['postcode'],
'country_id' => $_POST['country_id'],
'phone' => $_POST['phone'],
'dob' => $dob,
'gender' => $_POST['gender'],
'occupation' => $_POST['occupation'],
'fav_quotes' => $_POST['fav_quotes'],
'news' => $_POST['news'],
'newsletter' => $_POST['newsletter'],
'reg_type_id' => $reg_type_id,
'images' => $_POST['images']
);
insert('user', $data);
//echo "Success";
header("Location: paypal-invoice/createandsend.example.php");
}
?>
Thanks In Advance.

you can insert dob in a mysql dababase because mysql accept yyyy-mm-dd format so you should
$year.'-'.$month.'-'.$day
I think it will work for you

Related

How to insert multiple text input data with checkbox in laravel?

Basically I want to insert into database the data according to input value. I have multiple checkbox and input field. When I store data only " A " then its working and others are null values. If I stored others with A then stored all the values. User can be check and input values any time and any number of check box.
Here are the code snippet,
<form action="">
<input type="checkbox" name="txt_check[]" id="">A
<label for="fname">Win1:</label>
<input type="text" id="fname" name="txt_win[]"><br><br>
<label for="fname">Win2:</label>
<input type="text" id="fname" name="txt_loss[]"><br><br>
<label for="fname">Win3:</label>
<input type="text" id="fname" name="txt_draw[]"><br><br>
<input type="checkbox" name="txt_check[]" id="">B
<label for="lname">Loss1:</label>
<input type="text" id="fname" name="txt_win[]"><br><br>
<label for="lname">Loss2:</label>
<input type="text" id="fname" name="txt_loss[]"><br><br>
<label for="lname">Loss3:</label>
<input type="text" id="fname" name="txt_draw[]"><br><br>
<input type="checkbox" name="txt_check[]" id="">C
<label for="lname">Draw1:</label>
<input type="text" id="fname" name="txt_win[]"><br><br>
<label for="lname">Draw2:</label>
<input type="text" id="fname" name="txt_loss[]"><br><br>
<label for="lname">Draw3:</label>
<input type="text" id="fname" name="txt_draw[]"><br><br>
<input type="submit" value="Submit">
</form>
Here is the Controller:
$win = $request->txt_win;
$loss = $request->txt_loss;
$draw = $request->txt_draw;
$checkValue = $request->txt_check ;
foreach $checkValue as $key => $value) {
$result[] = Model::create([
'checkValue' => $value,
'winning' => $win [$key],
'lost' => $loss [$key],
'draw' => $draw [$key],
]);
}
This code works well for the first insert but when I try to second insert then insert null value like this-
I want to insert into database this way,
checkval win loss draw
A 2 3 4
B 3 4 3
C 4 5 5
How can I do this. I need help. Advanced thanks.
Your code is missing a circular brace on the foreach loop.
Change this
foreach $checkValue as $key => $value) {
$result[] = Model::create([
'checkValue' => $value,
'winning' => $win [$key],
'lost' => $loss [$key],
'draw' => $draw [$key],
]);
}
to this
foreach ($checkValue as $key => $value) {
$result[] = Model::create([
'checkValue' => $value,
'winning' => $win [$key],
'lost' => $loss [$key],
'draw' => $draw [$key],
]);
}

Yii 1.1.21 : is it possible to create two dropdown buttons in the same button group?

I am new to Yii, and I have been LOOKING for documentation on Yii and CMenu. I have used Phalcon and various other frameworks with similar options, but Yii's menu engine is new to me.
I am trying to create a button menu with two drop down menu buttons, each with sub menu items, like this:
Drop Down Button Group
But what is being rendered by the Yii CMenu engine is two drop down menus overlayed on each other and both are being triggered by the same buttons. Like this:
enter image description here
Looking at the rendered code, it looks like the two dropdown menus are being assigned the "dropdown-menu" class by CMenu, (or whatever the bootstrap enabled lib is) and becasue they are in the same button group, when the "open" class is assigned, it's opening BOTH dropdowns at the same time.
So my question is simple, is is even possible, using the CMenu menu arrays, to have two dropdowns in the same. Is there a menu "Item Option" or "HTML Option" I can add to the menu item properties that will all this to reference two different css tags? I know I gotta be missing something.
Here is how the menu's are being built in the view.
$this->menu = array_merge($this->menu, array(
array(
'label' => '<span class="hidden-xs hidden-sm">' . Yii::t('app', 'Export') . '</span>',
'encodeLabel' => false,
'htmlOptions' => array('id' => 'export-or-email-btn', 'class' => 'navbar-btn btn-sm',),
'items' => array(
array(
'label' => Yii::t('app', 'Export'),
'icon' => 'fa fa-file-excel-o',
'visible' => true,
'itemOptions' => array('class' => 'work-order-export-btn'),
),
array(
'label' => Yii::t('app', 'Email Export'),
'icon' => 'fa fa-envelope-o',
'visible' => true,
'itemOptions' => array('id' => $model->getClassName(), 'class' => 'email-export-btn', 'data-grid-id' => 'work-order-grid'),
),
array(
'label' => Yii::t('app', 'Export as Import Template'),
'icon' => 'fa fa-file-excel-o fa-lg',
'visible' => true,
'itemOptions' => array('class' => 'work-order-export-import-btn'),
),),),);
$this->menu = array_merge($this->menu, array(
array(
'label' => '<span class="hidden-xs hidden-sm">' . Yii::t('app', 'Actions') . '</span>',
'encodeLabel' => false,
'htmlOptions' => array(
'id' => 'work-order-actions-btn work-order-actions',
'class' => 'navbar-btn btn-sm',
'style' => 'margin: 0 0 0 15px;',
),
'items' => array(
array(
'icon' => 'fa fa-print fa-lg',
'label' => Yii::t('app', 'Print to PDF'),
'visible' => true,
'itemOptions' => array(
'class' => 'work-order-print-pdf',
),),
array(
'icon' => 'fa fa-print fa-lg',
'label' => Yii::t('app', 'Print'),
'visible' => true,
'itemOptions' => array(
'class' => 'work-order-print-selected',
),),))));
and here is the rendered code snippet:
<div class="btn-toolbar">
<div class="operations btn-group-sm btn-group open">
<button id="export-or-email-btn" class="navbar-btn btn-sm btn btn-primary dropdown-toggle" data-toggle="dropdown" name="yt7" type="button">
<span class="hidden-xs hidden-sm">Export</span>
<span class="caret"></span>
</button>
<ul id="yw6" class="dropdown-menu">
<li class="work-order-export-btn nav-header" data-ol-has-click-handler="">
<i class="fa fa-file-excel-o"></i> Export
</li>
<li id="WorkOrder" class="email-export-btn nav-header" data-grid-id="work-order-grid" data-ol-has-click-handler="">
<i class="fa fa-envelope-o"></i> Email Export
</li>
<li class="work-order-export-import-btn nav-header" data-ol-has-click-handler="">
<i class="fa fa-file-excel-o fa-lg"></i> Export as Import Template
</li>
</ul>
<button id="work-order-actions-btn work-order-actions" class="navbar-btn btn-sm btn btn-primary dropdown-toggle" style="margin: 0 0 0 15px;" data-toggle="dropdown" name="yt8" type="button">
<span class="hidden-xs hidden-sm">Actions</span>
<span class="caret"></span>
</button>
<ul id="yw7" class="dropdown-menu">
<li class="work-order-print-pdf nav-header">
<i class="fa fa-print fa-lg"></i> Print PDF
</li>
<li class="work-order-print-selected nav-header">
<i class="fa fa-print fa-lg"></i> Print Selected
</li>
</ul>
</div>
</div>
I think your problem is you are merging both arrays in the same $this->menu attribute.
Maybe you should use CMenu as widget like in the documentation
$this->widget('zii.widgets.CMenu', array(
'items'=>array(
// Important: you need to specify url as 'controller/action',
// not just as 'controller' even if default action is used.
array('label'=>'Home', 'url'=>array('site/index')),
// 'Products' menu item will be selected no matter which tag parameter value is since it's not specified.
array('label'=>'Products', 'url'=>array('product/index'), 'items'=>array(
array('label'=>'New Arrivals', 'url'=>array('product/new', 'tag'=>'new')),
array('label'=>'Most Popular', 'url'=>array('product/index', 'tag'=>'popular')),
)),
array('label'=>'Login', 'url'=>array('site/login'), 'visible'=>Yii::app()->user->isGuest),
),
));
For more information and attributes check out the official documentation here.

CHtml submit button is not working when 'enter' key press in Yii

In my Yii web application, CHtml submit button is not working when 'enter' key press in Login form. My login form is,
<?php echo CHtml::beginForm(); ?>
<h3 class="form-title">Login to your account</h3>
<div class="alert alert-danger display-hide">
<button class="close" data-close="alert"></button>
<span> Enter any username and password. </span>
</div>
<div class="form-group">
<label class="control-label visible-ie8 visible-ie9">Username</label>
<div class="input-icon">
<i class="fa fa-user"></i>
<?php echo CHtml::activeTextField($model, 'username', array("class" => "form-control placeholder-no-fix", 'placeholder' => "Username")) ?>
</div>
</div>
<div class="form-group">
<label class="control-label visible-ie8 visible-ie9">Password</label>
<div class="input-icon">
<i class="fa fa-lock"></i>
<?php echo CHtml::activePasswordField($model, 'password', array("class" => "form-control placeholder-no-fix", 'placeholder' => "Password")) ?>
</div>
</div><br>
<div class="form-group">
<?php echo CHtml::submitButton(UserModule::t("Login "), array('class' => 'btn green pull-right')); ?>
</div>
<div class="text-danger"><?php echo CHtml::errorSummary($model); ?></div>
<?php echo CHtml::endForm(); ?><br><br><br>
<?php
$form = new CForm(array(
'elements' => array(
'username' => array(
'type' => 'text',
'maxlength' => 32,
),
'password' => array(
'type' => 'password',
'maxlength' => 32,
),
'rememberMe' => array(
'type' => 'checkbox',
)
),
'buttons' => array(
'login' => array(
'type' => 'submit',
'label' => 'Login',
),
),
), $model);
?>
In this login form using chtml submit button. I want to submit this login form by press enter key.
How to resolve this problem.
Please help me.
If you want to use onclick:
<?php echo CHtml::submitbutton(UserModule::t("Login "), array('class ' => 'btn green pull-right', 'onclick' => ' '));?>

Cannot pass SelectedValue and Text to Controller for a KendoUIDropDownListFor widget

This works fine if I don't use any KendoUI functionality and am able to pass it easily using a regular Html.DropDownListfor helper (seen as comments in the code). The Description and the StatusID both do not come through.
How can I pass these values to the controller after selecting them in the dropdown list and then clicking enter with the KendoUI extension?
If I uncomment the Value and Text properties, I get "Object not set to an instance of an Object".
#using (Html.BeginForm("AddSingleStatus", "Status", new AjaxOptions { HttpMethod = "POST", }))
{
#Html.ValidationSummary(true)
<table>
<tr>
<td>
<div class="display-label">
#Html.LabelFor(model => Model.Description);
</div>
<div class="display-label" style="display: none;">
#Html.HiddenFor(model => Model.Description)
</div>
<div class="editor-field">
#(Html.Kendo().DropDownListFor(model => Model.StatusID)
.Name("statusDropDownList")
.DataTextField("Description")
.DataValueField("StatusID")
.DataSource(source =>
{
source.Read(read =>
{
read.Action("ReadDDL", "Status");
})
.ServerFiltering(false);
})
.OptionLabel("Select a status")
.SelectedIndex(0)
.Events(e => e
.Change("dropdownlist_change")
)
)
#* #Html.DropDownListFor(model => Model.StatusID, new SelectList((YeagerTechModel.Status[])ViewData["statuses"], "StatusID", "Description"));*#
#*#Html.ValidationMessageFor(model => Model.StatusID)*#
</div>
</td>
</tr>
<tr>
<td>
<input type="submit" id="ddlSubmit" value='#Resources.Add' />
</td>
</tr>
</table>
}
<script type="text/javascript">
function dropdownlist_change()
{
var dropdownlist = $("#statusDropDownList").data("kendoDropDownList");
dropdownlist.bind("change", function (e)
{
var value = dropdownlist.value();
});
}
</script>

Adding a column which contains a hyperlink for every row in KendoUI grid control in ASP.NET MVC

Here is my View that contains the KendoUI Grid Control:
I want to add a new column that contains a hyperlink before the Date of creation column .
#using Kendo.Mvc.UI
#model IEnumerable<ExamplekendoDropdown.Models.FacilityGroup>
#{
ViewBag.Title = "Grid";
}
<table width="700">
<tr>
<td align="center">
<table width="1000">
<tr>
<td align="left">
#using (Html.BeginForm("Grid", "Grid", FormMethod.Get))
{
<table>
<tr>
<td>
<span>Facility Group Name</span>
</td>
<td>
#(Html.Kendo().AutoComplete()
.Name("FacilityGroupName")
.Value("")
.Enable(true)
)
#Html.Hidden("FacilityGroupName")
</td>
</tr>
<tr>
<td>
<input id="Submit1" type="submit" value="Search" />
</td>
</tr>
</table>
}
</td>
</tr>
<tr>
<td align="center" >
#(Html.Kendo().Grid(Model)
.Name("Grid")
.Columns(columns =>
{
columns.Bound(p => p.FacilityGroupId);
//columns.Bound(#Html.ActionLink("Create Facility", "Facility"));
columns.Bound(p =>p.FaclityGroupName);
columns.Bound(p => p.status).Width(80);
columns.Bound(p => p.CreationDate);
columns.Command(command => { command.Edit(); });
})
//.ToolBar(toolbar =>toolbar.Create())
//.Editable(editable => editable.Mode(GridEditMode.PopUp))
.Editable(editable => editable.Mode(GridEditMode.PopUp).TemplateName("EditUserPopupTemplate")
.Window(w => w.Title("Facility").Name("editWindow").Width(300).Height(300)))
.Pageable()
.Sortable()
.Scrollable()
.DataSource(datasource => datasource
.Server()
.Model(model => model.Id(p => p.FacilityGroupId ))
.Read("Grid", "Grid")
.Update("Update", "Grid")
//.Create("Create","Grid")
//.Destroy("Destroy","Grid")
)
)
<script type="text/javascript">
$(document).ready(function () {
$("form.k-edit-form").kendoValidator();
});
</script>
</td>
</tr>
</table>
</td>
</tr>
</table>
Now i need to add another column before the "Date Of Creation" Column that contains a hyperlink.
Please share your inputs
Thanks
But why not this if you are using ajax
Ajax().ClientTemplate("#=FileName#");
if server()
columns.Bound(p => p.ProductID).Template(#<text>
#Html.ActionLink("Show Product Details", "ProductDetails", new { id = #item.ProductID } )>
</text>);
This example
columns.Template(#<text></text>).ClientTemplate(
#Html.ActionLink("Send Reset Email", "Login", new { loginButton = "reset",activate=true,fromAdmin=true,rowField="#=rowField#" }).ToHtmlString()
);
This worked for me.
You can use Template and ClientTemplate, to get a column with a hyperlink.
columns.Bound(p => p.CreationDate)
.Template(#<text>#item.CreationDate</text>)
.ClientTemplate("<a href=''>#CreationDate<a/>").Title("Link");
columns.Bound(p => p.CreationDate);
You only need to use the Template method for Server Binding. (ClientTemplate is for Ajax binding). You do not need to bind it to specific property unless you want to associate the column header to filter/sort/group by that property.
columns.Template(#<text>#Html.ActionLink("Create Facility", "Facility")</text>)
columns.Template(#<text></text>)
.ClientTemplate("<a href='" + Url.Action("Index", "Home") + "'>Create Facility</a>")
.HtmlAttributes(new { style = "text-align: left;" })
.Width(60);
This worked for me
If your grid has Server Binding use this:
columns.Bound(x => x.ProjectCode)
.Template(items => Html.ActionLink(items.ProjectCode, "Manage", "Project", new {projectId = items.ProjectId}, null));