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>
Related
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?
I want to do multiple edit, I want to edit from the data I checked following script .blade, I found the TokenMismatchException error in VerifyCsrfToken.php line 68: when updating.
<form name="form" action="{{url('/update-kb')}}" method="post" onsubmit="return deleteConfirm();"/>
<div class="table table-responsive">
<table id="example1" class="table table-bordered">
<thead>
<tr class="info">
<th width="3%"><input type="checkbox" name="select_all" id="select_all" value=""/></th>
<th>No</th>
<th>Data lengkap</th>
<th>Aksi</th>
</tr>
</thead>
<tbody>
<?php $i = 1; ?>
#foreach( $datasiswa as $row )
<tr>
<td>
<label class="checkbox-inline"><input type="checkbox" name="checked_id[]" class="checkbox" value="{{$row->id}}"/>
</label>
</td>
<td width="5%">{{ $i }}</td>
<td width="95%">
<table class="table">
<tr>
<td class="info">Nama panggilan</td>
<td>{{$row->nm_panggilan}}</td>
<td class="warning">Pekerjaan ibu</td>
<td>{{$row->pekerjaan_ibu}}</td>
</tr>
<tr>
<td class="info">Jenis kelamin</td>
<td>{{$row->jenis_kelamin}}</td>
<td class="warning">No. Handphone</td>
<td>{{$row->hp_ibu}}</td>
</tr>
<tr>
<td class="info">Tempat, Tanggal lahir</td>
<td>{{$row->tempat}}, {{$row->tanggal_lahir}}</td>
<td class="warning">Alamat</td>
<td>{{$row->alamat}}</td>
</tr>
<tr>
<td class="info">Status anak</td>
<td>{{$row->status_anak}}</td>
<td class="warning">Golongan darah</td>
<td>{{$row->goldar}}</td>
</tr>
<tr>
<td class="info">Agama</td>
<td>{{$row->agama}}</td>
<td class="warning">Nama wali</td>
<td>{{$row->nm_wali}}</td>
</tr>
<tr>
<td class="info">Kewarganegaraan</td>
<td>{{$row->kewarganegaraan}}</td>
</tr>
<tr>
<td class="info">Anak ke-</td>
<td>{{$row->anak_ke}}</td>
</tr>
<tr>
<td class="info">Kelas</td>
<td>{{$row->kelas}}</td>
</tr>
</table>
</td>
<td>
<a href="{!! url('/'.$row->id.'/edit-siswa') !!}">
<button class="btn btn-default btn-block"><i class="fa fa-edit"></i></button><br>
</a>
<a href="{!! url('/'.$row->id.'/delete-siswa') !!}">
<button class="btn btn-danger btn-block"><i class="fa fa-trash"></i></button>
</a>
</td>
</td>
</tr>
<?php $i++; ?>
#endforeach
</tbody>
</table>
<div class="col-md-3">
<input type="submit" class="btn btn-danger" name="delete_submit" value="Hapus"/>
</div>
</div>
</form>
But I still have error, what causes it?
public function updatekb($id, Request $request)
{
$data = Datasiswa::find($id);
if (isset($request->delete_submit)) {
$idArr = $request->checked_id;
foreach ($idArr as $id) {
DB::update('update tb_siswa, tb_pernyataan set tb_pernyataan.kelas = "cekcek" where tb_pernyataan.kelas = "TK A" and tb_siswa.sekolah = "KB TK KHALIFAH 25" and id = "' . $id . '" ');
}
return back();
Session::flash('sukses', 'Data berhasil di update', compact('data'));
}
}
Add below to your form element.
<input type="hidden" name="_token" value="{{ csrf_token() }}" />
Some answers are suggesting to disable csrf protection which is possible but NOT RECOMENDED. This leaves your application vulnureable.
Laravel use CSRF token to verify user request. so you have to use it on yevery request if you want to disable it then you can disable it from See here how to disable it or you can use it as
{{ csrf_field() }}
or
<input type="hidden" name="_token" value="{{ csrf_token() }}"/>
You can resolve this issue in two ways:-
First One:-
{{ csrf_field() }}
or
<input type="hidden" name="_token" value="{{ csrf_token() }}"/> // add this in form
Or the other (simpler) way, inside your app\Http\Middleware/VerifyCsrfToken.php add
protected $except = [
'update-kb', // your route name
];
Hope it helps!
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>";
}
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();
?>
how do i save multiple rows in child without using any extensions?
Within parent form I have a child form, user just input whatever row is needed. Right now it only saves the first row.
controller:
//some parent stuff form here
$valid = true;
$arrAttrData = array();
if($model->save()){
if(isset($_POST['ProductAttribute'])){
foreach($_POST['ProductAttribute'] as $i=>$attrItem){
$attr = new ProductAttribute;
$attr->attributes = $attrItem;
if ( $model->product_id )
$attr->product_id = $model->product_id;
if ( ! $attr->validate() )
$valid = false;
else $arrAttrData[] = $attr;
}
}
if ( $valid ){
foreach( $arrAttrData as $attr ){
$attr->product_id = $model->product_id;
$attr->save();
}
}
}
parent:
//some parent stuff here
<div id="attribute">
<?php
$this->renderPartial('_attr', array(
'attr' => $attr,
));?>
</div>
_attr:
<?php $form=$this->beginWidget('bootstrap.widgets.TbActiveForm', array(
'id'=>'attr-form',
'htmlOptions'=>array('enctype'=>'multipart/form-data'),
)); ?>
<?php echo $form->errorSummary($attr); ?>
<table>
<tbody>
<tr>
<td>Attribute's Name</td><td>Attribute Price</td><td>Description</td>
</tr>
<?php for ($i=0;$i<5;$i++):?>
<tr>
<td><?php echo CHtml::activeTextField($attr,'[$i]name',array('class'=>'span12','placeholder'=>'Red or X-Small')); ?></td>
<td><?php echo CHtml::activeTextField($attr,'[$i]cost',array('class'=>'span4','placeholder'=>'89.99')); ?></td>
<td><?php echo CHtml::activeTextField($attr,'[$i]description',array('class'=>'span12','placeholder'=>'Spicy Red Thingy')); ?></td>
</tr>
<?php endfor?>
<br>
<?php echo CHtml::error($attr, '[$i]name'); ?>
<?php echo CHtml::error($attr, '[$i]cost'); ?>
<?php echo CHtml::error($attr, '[$i]description'); ?>
</tbody>
</table>
<?php $this->endWidget(); ?>
[edit]:
form html view
<table>
<tbody>
<tr>
<td>Attribute's Name</td><td>Attribute Price</td><td>Description</td>
</tr>
<tr>
<td><input class="span12" placeholder="Red or X-Small" name="ProductAttribute[$i][name]" id="ProductAttribute_$i_name" type="text" maxlength="155"></td>
<td><input class="span4" placeholder="89.99" name="ProductAttribute[$i][cost]" id="ProductAttribute_$i_cost" type="text"></td>
<td><input class="span12" placeholder="Spicy Red Thingy" name="ProductAttribute[$i][description]" id="ProductAttribute_$i_description" type="text" maxlength="155"></td>
</tr>
<tr>
<td><input class="span12" placeholder="Red or X-Small" name="ProductAttribute[$i][name]" id="ProductAttribute_$i_name" type="text" maxlength="155"></td>
<td><input class="span4" placeholder="89.99" name="ProductAttribute[$i][cost]" id="ProductAttribute_$i_cost" type="text"></td>
<td><input class="span12" placeholder="Spicy Red Thingy" name="ProductAttribute[$i][description]" id="ProductAttribute_$i_description" type="text" maxlength="155"></td>
</tr>
<tr>
<td><input class="span12" placeholder="Red or X-Small" name="ProductAttribute[$i][name]" id="ProductAttribute_$i_name" type="text" maxlength="155"></td>
<td><input class="span4" placeholder="89.99" name="ProductAttribute[$i][cost]" id="ProductAttribute_$i_cost" type="text"></td>
<td><input class="span12" placeholder="Spicy Red Thingy" name="ProductAttribute[$i][description]" id="ProductAttribute_$i_description" type="text" maxlength="155"></td>
</tr>
<tr>
<td><input class="span12" placeholder="Red or X-Small" name="ProductAttribute[$i][name]" id="ProductAttribute_$i_name" type="text" maxlength="155"></td>
<td><input class="span4" placeholder="89.99" name="ProductAttribute[$i][cost]" id="ProductAttribute_$i_cost" type="text"></td>
<td><input class="span12" placeholder="Spicy Red Thingy" name="ProductAttribute[$i][description]" id="ProductAttribute_$i_description" type="text" maxlength="155"></td>
</tr>
<tr>
<td><input class="span12" placeholder="Red or X-Small" name="ProductAttribute[$i][name]" id="ProductAttribute_$i_name" type="text" maxlength="155"></td>
<td><input class="span4" placeholder="89.99" name="ProductAttribute[$i][cost]" id="ProductAttribute_$i_cost" type="text"></td>
<td><input class="span12" placeholder="Spicy Red Thingy" name="ProductAttribute[$i][description]" id="ProductAttribute_$i_description" type="text" maxlength="155"></td>
</tr>
</tbody>
</table>
In your controller , try this
if($model->save()){
if(isset($_POST['ProductAttribute'])){
foreach($_POST['ProductAttribute'] as $i=>$attrItem){
$attr = new ProductAttribute;
$attr->attributes = $attrItem;
if ( $model->product_id )
$attr->product_id = $model->product_id;
if ($attr->validate() )
$attr->save();
}
}
unset($attr);
} // foreach
}