Need help in below XML issue.
Create table #temp
( NAME VARCHAR(MAX)
)
Insert Into #temp
select
'<div class="form-group form-row"><label class="col-sm-5 control-label">Account Name</label><div class="form-controls"><div class="form-control-static">Bond</div></div></div><div class="form-group form-row"><label class="col-sm-5 control-label">Account Number</label><div class="form-controls"><div class="form-control-static">PQR</div></div></div><div class="form-group">
<label class="control-label">Specific subject</label>
<input class="input-text form-control" type="text" name="Specific subject" size="20" value="Money Transfer" DISABLED>
</div><div class="form-group">
<label class="control-label mandatory" for="message">Message</label>
<textarea class="textarea form-control" name="message" id="message" cols="30" rows="3" maxlength="5000" DISABLED REQUIRED> The Name is XYZ </textarea><span class="mand">*</span><span class="help-text">Max. 5000 characters</span>
</div>'
select convert(XML, NAME) from #temp
and whenever I am converting the column to XML using
convert(XML, Name)
it is showing me below error
XML parsing: line 3, character 119, equal expected.
Need help.
XML requires fully qualified elements, unlike HTML.
So, your code...
Create table #temp
( NAME VARCHAR(MAX)
)
Insert Into #temp
select
'<div class="form-group form-row"><label class="col-sm-5 control-label">Account Name</label><div class="form-controls"><div class="form-control-static">Bond</div></div></div><div class="form-group form-row"><label class="col-sm-5 control-label">Account Number</label><div class="form-controls"><div class="form-control-static">PQR</div></div></div><div class="form-group">
<label class="control-label">Specific subject</label>
<input class="input-text form-control" type="text" name="Specific subject" size="20" value="Money Transfer" DISABLED>
</div><div class="form-group">
<label class="control-label mandatory" for="message">Message</label>
<textarea class="textarea form-control" name="message" id="message" cols="30" rows="3" maxlength="5000" DISABLED REQUIRED> The Name is XYZ </textarea><span class="mand">*</span><span class="help-text">Max. 5000 characters</span>
</div>'
select convert(XML, NAME) from #temp
May only work if you specify values for the assumed Boolean types of DISABLED and REQUIRED...
Create table #temp
( NAME VARCHAR(MAX)
)
Insert Into #temp
select
'<div class="form-group form-row">
<label class="col-sm-5 control-label">Account Name</label>
<div class="form-controls"><div class="form-control-static">Bond</div></div>
</div>
<div class="form-group form-row">
<label class="col-sm-5 control-label">Account Number</label>
<div class="form-controls"><div class="form-control-static">PQR</div></div>
</div>
<div class="form-group">
<label class="control-label">Specific subject</label>
<input class="input-text form-control" type="text" name="Specific subject" size="20" value="Money Transfer" disabled="true">
</div>
<div class="form-group">
<label class="control-label mandatory" for="message">Message</label>
<textarea class="textarea form-control" name="message" id="message" cols="30" rows="3" maxlength="5000" disabled="true" required="true"> The Name is XYZ </textarea>
<span class="mand">*</span>
<span class="help-text">Max. 5000 characters</span>
</div>'
select convert(XML, NAME) from #temp
I have only picked out the obvious differences, however. I would recommend that you sanitise your data completely, if you are going to process it with SQL.
Related
I'd like to obtain a record of a student's attendance from the "attendance" table. From a date to a date, e.g., from September 23, 2022, to December 10, 2022. Admin will enter the student's class and roll number, as well as a From date to date range.
Using his class and roll number. How to do this in Laravel 9 Thanks
this is the from through which a specific students record will be retirved.
<form class="mt-3" method="POST" action="\record">
#csrf
<div class="mb-3">
<label for="exampleInputEmail1" class="form-label">Student Class</label>
<input type="number" name="class" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp">
</div>
<div class="mb-3">
<label for="exampleInputPassword1" class="form-label">Roll Number</label>
<input type="number" name="roll number" class="form-control" id="exampleInputPassword1">
</div>
<div class="mb-3">
<label for="exampleInputPassword1" class="form-label">From Date</label>
<input type="date" name="from_date" class="form-control" id="exampleInputPassword1">
</div>
<div class="mb-3">
<label for="exampleInputPassword1" class="form-label">To Date</label>
<input type="date" name="to_date" class="form-control" id="exampleInputPassword1">
</div>
<button type="submit" class="btn btn-primary">Generate</button>
You can use the whereBetween in laravel to achieve this.
Suppose you have a model named Student.
You'd then do this in your controller:
$from = now();
$to = now()->addDays(5);
$studentAttendance = Student::whereBetween('date', [$from, $to])->get();
Which will get the students who have a date between $from and $to dates.
I have a list of persons That I bonded two ways to a form using a for each,
everything works fine, but when I want to bind the person's array of emails, it does not work!!
it sets the same value toall the other persons in my list!
Here is my code:
it works fine for the firstName element, but not for the email
<div class="col-md-3">
<div class="form-group">
<label>Prénom</label><span>*</span>
<input type="text" placeholder="First Name" required [(ngModel)]="listGlobalBeneficiaries[i].firstName"
[ngModelOptions]="{standalone: true}" class="form-control" id="bfirstName"
name="{{i}}_bfirstName" #bfirstName="ngModel">
<div [hidden]="bfirstName.valid || bfirstName.pristine" class="alert alert-danger">
Prénom est obligatoire
</div>
</div>
</div>
<input _ngcontent-fsl-c265="" type="text" placeholder="First Name" required="" id="bfirstName" class="form-control ng-dirty ng-valid ng-touched" ng-reflect-required="" ng-reflect-name="1_bfirstName" ng-reflect-options="[object Object]" ng-reflect-model="name">
<div class="col-md-4" >
<div class="form-group">
<label>E-mail</label><span>*</span>
<input type="email" placeholder="Email" email
required [(ngModel)]="listGlobalBeneficiaries[i].emails![0].address"
[ngModelOptions]="{standalone: true}" class="form-control"
name="{{i}}_emailaddress" id="{{i}}_emailaddress" #emailaddress="ngModel">
<div [hidden]="emailaddress.valid || emailaddress.pristine" class="alert alert-danger">
E-mail est obligatoire
</div>
</div>
</div>
<input _ngcontent-qhm-c265="" type="email" placeholder="Email" email="" required="" class="form-control ng-dirty ng-invalid ng-touched" ng-reflect-required="" ng-reflect-email="" ng-reflect-name="2_emailaddress" id="2_emailaddress" ng-reflect-model="" ng-reflect-options="[object Object]">
Fixed it, the problem was that when initializing the emails array.
Previous:
this.listGlobalBeneficiaries[i].emails = this.init_emails;
Fix:
this.listGlobalBeneficiaries[i].emails = [
{
type: 'WORK',
stillPrimary: true,
valid: true,
address: '',
},
];
because objects are assigned and copied by reference in typescript
I tried looking up at the issue but, it seems like I am doing it right?
So my HTML content shows that
<label for="email"><b>Email</b></label>
<input type="text" placeholder="Enter Email" [(ngModel)]="email" required>
<label for="username"><b>User Name</b></label>
<input type="text" placeholder="User Name" [(ngModel)]="username" required>
<label for="firstname"><b>First Name</b></label>
<input type="text" placeholder="Enter First Name" [(ngModel)]="firstname" required>
<label for="lastname"><b>Last Name</b></label>
<input type="text" placeholder="Enter Last Name" [(ngModel)]="lastname" required>
I have errors running through my HTML
Error occurs in the template of component SignupComponent.
and each of them says
Property 'lastname' does not exist on type 'SignupComponent'.
I want to ask how to call the value from another table under same database ?
Database table name: bit_app_policy_category
Under the database I have these columns:
ID
code
description
parent_id
status
Another Database Table name under same database : company_policy
Under the database i have these columns:
ID
policy_category_id
policy_title
version_no
policy_details
expiry_date
file_path
As for now I want to link the table bit_app_policy_category and get the columns of id's value into company_policy - policy_category_id. I don't know how to write the code.
Here is my current code :
<form method="post" action="{{route('policy.store')}}">
{{csrf_field()}}
#csrf
<div class="form-group">
<label for="bit_app_policy_category_parent">Parent Category</label>
<select id="bit_app_policy_category_parent" name="parent_id" class="form-control">
<option value=" {{"$parents->id"}} </option>n>
</select>
</div>
<div class="form-group">
<label for="company_policy_policy_title">Policy Title<span class="required">*</span></label>
<input id="company_policy_policy_title" type="text" name="policy_title" class="form-control" placeholder="Please Enter the policy title" />
</div>
<div class="form-group">
<label for="company_policy_version-no">Version-no<span class="required">*</span></label>
<input id="company_policy_version-no" type="text" name="version_no" class="form-control" placeholder="Please Enter the Version-no" />
</div>
<div class="form-group">
<label for="company_policy_policy_details">Policy Details<span class="required">*</span></label>
<input id="company_policy_policy_details" type="text" name="policy_details" class="form-control" placeholder="Please Enter the Policy Details" />
</div>
<div class="form-group">
<label for="company_policy_expiry_date">Expiry Date<span class="required">*</span></label>
<input id="company_policy_expiry_date" type="datetime-local" name="expiry_date" class="form-control" placeholder="Please Enter the Expiry Date time" />
</div>
<div class="form-group">
<label for="company_policy_file_path">Policy File Path<span class="required">*</span></label>
<input id="company_policy_file_path" type="text" name="file_path" class="form-control" placeholder="Please Enter the file path" />
</div>
<div class="form-group">
<input type="submit" class="btn btn btn-primary" />
Back</span>
Back to home</span>
</div>
</form>
</div>
</div>
#endsection
First create two model
1. PolicyCategory and put the code in model
public function companyPolicies()
{
return $this->hasMany('App\CompanyPolicy');
}
2.CompanyPolicy
public function policyCategory()
{
return $this->belongsTo('App\PolicyCategory',policy_category_id);
}
and in you controller then you can get all the info of related table. Like say, you have one/two company under the policy_category which id is 1. Now you can get all the companies info like below
$policy_category = PolicyCategory::find(1);
dd($policy_category->companyPolicies);
try this and let me know is this really you want or not
If I have an HTML form with two inputs that would insert/modify a columns with the same name in two tables in a database.
What would be the best way to name my input elements?
<div class="form-group">
<input type="text" class="form-control" id="mothers_name" name="name" placeholder="Enter Mothers Name">
</div>
<div class="form-group">
<input type="text" class="form-control" id="childs_name" name="name" placeholder="Enter Child's Name">
</div>
db-
--table1
---name
--table2
--name
I am trying to save these information using laravels create(request->all())
I see that the request object contains the last input value.
I would name the inputs the same way you have named the ids. (Or something similar.)
<div class="form-group">
<input type="text" class="form-control" id="mothers_name" name="mothers_name" placeholder="Enter Mother's Name">
</div>
<div class="form-group">
<input type="text" class="form-control" id="childs_name" name="childs_name" placeholder="Enter Child's Name">
</div>
Within your Controller, you could do something like this:
public function storeNameTable1(Request $request) {
$store_name = new Table1;
$store_name->name = $request->mothers_name;
$store_name->save();
}
public function storeNameTable2(Request $request) {
$store_name = new Table2;
$store_name->name = $request->childs_name;
$store_name->save();
}