how to print data in pdf format yii - pdf

in yii 1.1,I want to print list of data displayed in table into pdf format .I have no idea about this.I am in need of help.
My view code:
<?php echo CHtml::link('Print Envelop','marketingEmail/pdfPrint', array('class'=>'btn','target'=>'_blank')); ?>
<?php $form=$this->beginWidget('CActiveForm', array(
'id'=>'search-form',
'enableClientValidation'=>true,
'clientOptions'=>array(
'validateOnSubmit'=>true,
),
));
?>
<table class="bluetable" id="myDemoTable" cellpadding="0" cellspacing="0">
<thead>
<tr>
<th colspan="24"><b>Mail Listing</b></th>
</tr>
</thead>
<tbody>
<tr>
<td><b>S.N.</b></td>
<td width="300"><b>Company</b></td>
<td width="300"><b>Follow up By</b></td>
</tr>
</tbody>
</table>
<?php
$this->endWidget();
?>

Related

auto refresh div only when data is changed in laravel-8

I can auto-refresh the page every 5 seconds using this code
?php
$page = $_SERVER['PHP_SELF'];
$sec = "10";
?>
<html>
<head>
<meta http-equiv="refresh" content="<?php echo $sec?>;URL='<?php echo $page?>'">
</head>
<body>
<div id="auto_refresh">
<table id="example1" class="table table-bordered table-striped table-sm">
<thead>
<tr>
<th>SL</th>
<th>Match Name</th>
<th>Team Name</th>
</tr>
</thead>
<tbody>
#foreach ($databowlersecond as $key => $row)
<tr>
<td>{{ $key + 1 }}</td>
<td>{{ $row->matchh->match_name }}</td>
<td>{{ $row->team->team_name }}</td>
</tr>
#endforeach
</tbody>
</table>
</div>
</body>
</html>
But I want auto-refresh my div when data is updated how to do this?

how to get data from database in wordpress

Hello i want to get the data from database and put in on pages i write this code but it didnt work. how can i get the data from sql to be appear in the page thank for helping
<?php
global $wpdb;
$table_name = $wpdb wp_ ."sheet1";
$sql = "SELECT * FROM sheet1 WHERE Course='Filipino' ORDER BY Lastname";
$results = $wpdb->get_results( $sql);
?>
Data should be appear in this table
<table id="passers_table">
<thead>
<tr>
<th><center>Course</center></th>
<th><center>Student Number</center></th>
<th><center>Name</center></th>
<th><center>LinkedIn Account</center></th>
<th><center>Email Address</center></th>
<th><center>Nationality</center></th>
<th><center>City</center></th>
<th><center>Country</center></th>
</tr>
</thead>
<tbody>
<tr>
<td>$print->;Course</td><br>
<td>$print->;Studno</td><br>
<td>$print->;Title $print->Firstname $print->Lastname</td><br>
<td style="font-style: italic;"><center>PRIVATE</center></td><br>
<td><center><a href="$print->Linkedin" target="_blank" rel="noopener
noreferrer"><u>Click Here</u></a></center></td><br>
<td style="font-style: italic;"><center>PRIVATE</center></td><br>
<td><center>$print->;Email</center></td><br>
<td>$print->;Nationality</td><br>
<td>$print->;City</td><br>
<td>$print->;Country</td>
</tr>
</tbody>
</table>
Table and data wont appear do it have a problem in my code?
this is the other code that i tried but the data wont appear also
<?php global $wpdb; $table_name = $wpdb wp_ ."sheet1";
$sql = "SELECT * FROM sheet1 WHERE Course='Filipino' ORDER BY Lastname";
<br>$result = $wpdb-> ;get_results($sql) or die(mysql_error());
<p>foreach ( $result as $print )<br>{<br>echo"</p>
<p>";</p>
<p>if ($print->Linkedin==null)<br>{<br>echo"</p>
<p>";<br>}else<br>{<br>echo"</p>
<p>";<br>}</p>
<p>if ($print->Email==null)<br>{<br>echo"</p>
<p>";<br>}else<br>{<br>echo"</p>
<p>";<br>}</p>
<p>echo"</p>
<p>";<br>}<br>?>;</p> ?>
<table id="passers_table">
<thead>
<tr>
<th><center>Course</center></th>
<th><center>Student Number</center></th>
<th><center>Name</center></th>
<th><center>LinkedIn Account</center></th>
<th><center>Email Address</center></th>
<th><center>Nationality</center></th>
<th><center>City</center></th>
<th><center>Country</center></th>
</tr>
</thead>
<tbody>
<tr>
<td>$print->;Course</td><br>
<td>$print->;Studno</td><br>
<td>$print->;Title $print->Firstname $print->Lastname</td><br>
<td style="font-style: italic;"><center>PRIVATE</center></td><br>
<td><center><a href="$print->Linkedin" target="_blank" rel="noopener
noreferrer"><u>Click Here</u></a></center></td><br>
<td style="font-style: italic;"><center>PRIVATE</center></td><br>
<td><center>$print->;Email</center></td><br>
<td>$print->;Nationality</td><br>
<td>$print->;City</td><br>
<td>$print->;Country</td>
</tr>
</tbody>
</table>
i put it on the wp-login in the page where should the table and the data should appear
Hi please check below code and let me know if its not working. can i know which file you add this code ?
<?php
global $wpdb;
$table_name = $wpdb->prefix."sheet1";
$sql = "SELECT * FROM ".$table_name." WHERE Course ='Filipino' ORDER BY Lastname";
$results = $wpdb->get_results($sql);
?>
<!-- Data should be appear in this table-->
<table id="passers_table">
<thead>
<tr>
<th><center>Course</center></th>
<th><center>Student Number</center></th>
<th><center>Name</center></th>
<th><center>LinkedIn Account</center></th>
<th><center>Email Address</center></th>
<th><center>Nationality</center></th>
<th><center>City</center></th>
<th><center>Country</center></th>
</tr>
</thead>
<tbody>
<tr>
<?php
foreach($results as $print){
?>
<td><?php echo $print->Course;?></td><br>
<td><?php echo $print->Studno;?></td><br>
<td><?php echo $print->Title.' '.$print->Firstname.' '.$print->Lastname;?></td><br>
<td style="font-style: italic;"><center>PRIVATE</center></td><br>
<td><center><a href="<?php echo $print->Linkedin;?>" target="_blank" rel="noopener
noreferrer"><u>Click Here</u></a></center></td><br>
<td style="font-style: italic;"><center>PRIVATE</center></td><br>
<td><center><?php echo $print->Email;?></center></td><br>
<td><?php echo $print->Nationality;?></td><br>
<td><?php echo $print->City;?></td><br>
<td><?php echo $print->Country;?></td>
<?php } ?>
</tr>
</tbody>
</table>
Here is your code
<?php
global $wpdb;
$table_name = $wpdb wp_ ."sheet1";
$sql = "SELECT * FROM sheet1 WHERE Course='Filipino' ORDER BY Lastname";
$results = $wpdb->get_results( $sql);
?>
//Data should be appear in this table
<table id="passers_table">
<thead>
<tr>
<th><center>Course</center></th>
<th><center>Student Number</center></th>
<th><center>Name</center></th>
<th><center>LinkedIn Account</center></th>
<th><center>Email Address</center></th>
<th><center>Nationality</center></th>
<th><center>City</center></th>
<th><center>Country</center></th>
</tr>
</thead>
<tbody>
<tr>
<?php foreach($results as $print-> )
{ ?>
<td><?php echo $print->Course;?></td><br>
<td><?php echo $print->Studno;?></td><br>
<td><?php echo $print->Title;.$print->Firstname.$print->Lastname;?></td><br>
<td style="font-style: italic;"><center>PRIVATE</center></td><br>
<td><center><a href="<?php echo $print->Linkedin;?>" target="_blank" rel="noopener
noreferrer"><u>Click Here</u></a></center></td><br>
<td style="font-style: italic;"><center>PRIVATE</center></td><br>
<td><center><?php echo $print->Email;?></center></td><br>
<td><?php echo $print->Nationality;?></td><br>
<td><?php echo $print->City;?></td><br>
<td><?php echo $print->Country;?></td>
<?php } ?>
</tr>
</tbody>
</table>

pdo code for fetching data dynamically in a table

I want a pdo code for fetching data from database into a table dynamically when the page is opened.It took me an entire day but I still didnt get an appropriate code,PLEASE HELP ME OUT
<div class="card">
<div class="card-header">
<h2>Selection Example <small>Ensure that the data attribute [data-identifier="true"] is set on one column header.</small></h2>
</div>
<table id="data-table-command" class="table table-striped table-vmiddle">
<thead>
<tr>
<th data-column-id="id" data-type="numeric">ID</th>
<th data-column-id="sender">Sender</th>
<th data-column-id="received" data-order="desc">Received</th>
<th data-column-id="commands" data-formatter="commands" data-sortable="false">Commands</th>
</tr>
</thead>
<tbody>
<tr>
<td>10238</td>
<td>eduardo#pingpong.com</td>
<td>14.10.2013</td>
</tr>
<tr>
<td>10243</td>
<td>eduardo#pingpong.com</td>
<td>19.10.2013</td>
</tr>
<tr>
<td>10248</td>
<td>eduardo#pingpong.com</td>
<td>24.10.2013</td>
</tr>
<tr></tbody>
</table>
</div></div>
$data = $pdo->query("SELECT * FROM t")->fetchAll();
if ($data) {
echo "<table><tr>";
foreach (array_keys($data[0] as $col)) {
echo "<th>$col</th>";
}
echo "</tr>";
foreach($pdo->query("SELECT * FROM t") as $row) {
echo "<tr>";
foreach ($row as $col) {
echo "<td>$col</td>";
}
echo "</tr>";
}
echo "</table>";
}

How to select radio button in selenium web driver java using text of nearby element in XPath

I need to select radion button with id="optProfile" in 7th tr using text "Internet Users" in td/font tag. I am using below code but it is not working and selecting radio button from 1st tr row. Can anyone help
<html>
<head>
<body onmousedown="infCheckMouseDown(event);" onkeydown="infCheckDownKey(event);" onbeforeunload="INFIEExit();" onload="INFsetInitialFocus();window_onload();CreateScriptingFrames();">
<form action="PEINFCommon.ASP?WCI=Genericcreen&WCE=GenericEvent" onsubmit="return false" name="Genericcreen" method="post">
<table class="TopLevelTable" align="center" width="100%" border="0">
<tbody>
<tr>
<td width="100%">
<table width="100%" border="0">
<tbody>
<tr>
<tr>
<tr>
<tr>
<tr>
<td width="100%">
<div align="center">
<center>
<table width="98%" cellspacing="0" cellpadding="0" border="0" cols="1">
<tbody>
<tr align="center">
<td align="left">
<table width="100%">
<tbody>
<tr>
<tr>
<tr>
<tr height="">
<tr height="">
<tr height="">
<tr height="">
<tr height="">
<tr height="">
<tr height="">
<tr height="">
<tr height="">
<tr height="">
<tr height="">
<tr height="">
<td width="5%">
<input id="optProfile" type="Radio" callfunction="" value="" onblur="ResetScript(this);return true;" onfocus="HighlightScript(this);" onclick="" name="" size="11">
<font class="fLabel"></font>
<br>
<input id="hidCurrentProfile" type="hidden" onblur="ResetScript(this);" onfocus="HighlightScript(this);" value="N" callfunction="" size="11" name="/Root/ACORD/InsuranceSvcRs/nk_ck_com.cc_FetchUserProfileRs/nk_ck_com.cc_SecurityDetails/nk_ck_com.cc_AvailableProfile[12]/nk_ck_com.cc_CurrentProfileInd">
<input id="hidProfile" type="hidden" onblur="ResetScript(this);" onfocus="HighlightScript(this);" value="RACINTER" callfunction="" size="11" name="/Root/ACORD/InsuranceSvcRs/nk_ck_com.cc_FetchUserProfileRs/nk_ck_com.cc_SecurityDetails/nk_ck_com.cc_AvailableProfile[12]/nk_ck_com.cc_ProfileCd">
</td>
<td>
<font class="">Internet Users</font>
</td>
</tr>
<tr height="">
<tr height="">
<tr height="">
<tr>
<tr>
<tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</center>
</div>
</td>
</tr>
<tr>
<tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</form>
</body>
</html>
</frame>
<frame id="Script" scrolling="Yes" frameborder="0" noresize="">
</frameset>
</html>
you need to use ancestor instead of preceding:
//font[text()='Internet Users']/ancestor::tr[1]/td/input[#type='Radio']
and it's also a better practice to tell which one of the tr-ancestors you want -> [1] - since you want the first direct ancestor
Is there a reason why you are not using the id of the radio button?
WebElement wElement = wDriver.findElement(By.Id("optProfile"));
You can use the following XPath
//tr[.//font[text()='Internet Users']]//input[#id='optProfile']
This xpath looks for the tr containing the font tag with text "Internet Users" and then navigates to the input tag with id = 'optProfile'
You can use preceding as below-
By.xpath("//font[contains(text(),'Internet Users')]/preceding::input[#id='optProfile']")
Thanks everyone here for your help. I really appreciate it.Its working with below code
WebElement trs = GlobalVar.wDriver.findElement(By.xpath("//font[text()='Internet Users']/ancestor::tr[1]"));
trs.findElement(By.id("optProfile")).click();
I would try something like this
List<WebElement> trs = driver.findElements(By.cssSelector("table > tr"));
for (WebElement tr : trs)
{
List<WebElement> fonts = tr.findElements(By.tagName("font"));
if (!fonts.isEmpty() && fonts.get(0).getText().trim().equals("Internet Users"))
{
tr.findElement(By.id("optProfile")).click();
break;
}
}
You didn't show the TABLE tag in the HTML snippet so you will likely need to be more specific in the initial CSS selector. Basically this code loops through the TRs looking for "Internet Users" in the FONT tag. Once it finds it, it click the radio button with id=optProfile.
If you will post the TABLE tag in the HTML snippet I can help with the CSS selector.
Edit 1: changed the code to address the case where some TRs don't contain FONT tags.

Issue Saving Edited Data: DDL Value can not be null

I am having an issue with saving the edited fields in my MVC project. When I click the submit button I get an error
Value cannot be null.
Parameter name: items
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentNullException: Value cannot be null.
Parameter name: items
Source Error:
Line 63:
Line 64:
Line 65: #Html.DropDownListFor(model => model.EventTypeID, new SelectList(ViewBag.EventTypes, "EventTypeID", "EventType1"), "Choose")
Line 66:
Line 67:
I have tried some things that I have seen on the internet but it doesn't seem to be doing anything for me :( Help would be appreciated thank you!
this is my controller When I put a break point here it never triggers.
[HttpPost]
public ActionResult IndexPST(Event_Setup es)
{
db.Event_Setup.Add(es);
db.SaveChanges();
return View("Index",es);
}
And this is my View
#model DixonGroupInc.Models.Event_Setup
<link href="~/Content/EventManagement.css" rel="stylesheet" />
#using (Html.BeginForm("IndexPST", "EventManagement", FormMethod.Post))
{
#Html.AntiForgeryToken()
#Html.ValidationSummary(true)
<div id="cntr">
<div id="emLoc">
<table id="ldTbl">
<thead>
<tr>
<th class="ln">
<img src="~/Images/4.gif" />
</th>
<th>
<img src="~/Images/5.gif" />
</th>
<th>
<img src="~/Images/5.gif" />
</th>
<th>
<img src="~/Images/5.gif" />
</th>
<th>
<img src="~/Images/5.gif" />
</th>
</tr>
</thead>
<tbody>
<tr>
<td class="chosen space">EventMetadata
</td>
<td class="space">Client / Vendor
</td>
<td class="space">Venu info
</td>
<td class="space">Sponsored Participants
</td>
<td class="space">Event Services
</td>
</tr>
</tbody>
</table>
</div>
<div id="emSetup">
Setup Meeting
</div>
<div id="emTable">
<table class="myTbl">
<tr>
<td class="lblEvent clm1">
#Html.Label("Event Type")
</td>
<td class="clm2">
#Html.DropDownListFor(model => model.EventTypeID, new SelectList(ViewBag.EventTypes, "EventTypeID", "EventType1"), "Choose")
</td>
<td class="clm3">
#{Html.RenderAction("EventType", "EventManagement");}
</td>
</tr>
<tr class="rows">
<td class="lblEvent clm1">
#Html.Label("Event Title")
</td>
<td class="clm2">
#Html.EditorFor(model => model.EventTitle)
#Html.ValidationMessageFor(model => model.EventTitle)
</td>
</tr>
<tr>
<td class="lblEvent clm1">
#Html.Label("Event Identifier")
</td>
<td class="clm2">
#Html.EditorFor(model => model.EventIdentifier)
#Html.ValidationMessageFor(model => model.EventIdentifier)
</td>
</tr>
</table>
<table class="dateTbl">
<tr class="rows">
<td class="lblEvent clm1">
#Html.Label("Event Date From")
</td>
<td class="clm2">
#Html.TextBoxFor(model => model.EventDateFrom, new { #class = "dateFrom" })
#Html.ValidationMessageFor(model => model.EventDateFrom)
</td>
<td class="lblEvent">
#Html.Label("To")
</td>
<td class="clm4">
#Html.TextBoxFor(model => model.EventDateTo, new { #class = "dateTo" })
#Html.ValidationMessageFor(model => model.EventDateTo)
</td>
</tr>
</table>
<table class="myTbl">
<tr>
<td class="lblEvent clm1">
#Html.Label("Event Description")
</td>
<td class="clm2">
#Html.TextAreaFor(model => model.EventDescription, new
{
id = "taED"
})
<div>
<span id="charLeft2"></span>characters remaining.
</div>
#Html.ValidationMessageFor(model => model.EventDescription)
</td>
</tr>
<tr class="rows">
<td class="lblEvent clm1">
#Html.Label("Custom Message")
</td>
<td class="clm2">
#Html.TextAreaFor(model => model.CustomMessage, new
{
id = "taCM"
})
<div>
<span id="charLeft1"></span>characters remaining.
</div>
#Html.ValidationMessageFor(model => model.CustomMessage)
</td>
</tr>
<tr>
<td class="lblEvent clm1">
#Html.Label("Instructions")
</td>
<td class="clm2">
#Html.TextAreaFor(model => model.Instructions, new
{
id = "taInstrct"
})
<div>
<span id="charLeft"></span>characters remaining.
</div>
#Html.ValidationMessageFor(model => model.Instructions)
</td>
</tr>
</table>
<table class="myTbl">
<tr class="rows">
<td>
#{Html.RenderAction("AddTrack", "EventManagement");}
</td>
</tr>
<tr>
<td>
#{Html.RenderAction("EventTrack", "EventManagement");}
</td>
</tr>
</table>
<table class="myTbl">
<tr class="rows">
<td class="lblEvent clm1">
#Html.Label("CFP Pocess")
</td>
<td class="clm2">
#Html.RadioButtonFor(model => model.CFPRequired, "true") Yes
</td>
<td class="clm3">
#Html.RadioButtonFor(model => model.CFPRequired, "false") No
</td>
</tr>
</table>
</div>
<div id="emSubmit">
<input type="submit" value="Save & Next" id="submit" />
</div>
</div>
}
Viewbag can be unreliable so generally it isn't recommended to pass your drop down list data through the viewbag. I would recommend adding it to your view model instead. In your Event_Setup class make sure that you have
public int EventTypeID { get; set; }
and
public List<SelectListItem> EventTypeList { get; set; }
on your controller get you can set EventTypeID to set a default on the drop down so your controller should have something like
Event_Setup es = new Event_Setup();
es.EventTypeID = //default value if you want;
es.EventTypeList = //Method call here where List<SelectListItem> is returned with your event list
then on your view you can change your drop down to
#Html.DropDownListFor(x => x.EventTypeID, Model.EventTypeList)