while($row = mysqli_fetch_array($result))
{
$output .= '
<tr>
<td>'.$row["orderNumber"].'</td>
<td>'.$row["orderDate"].'</td>
<td>'.$row["requiredDate"].'</td>
<td>'.$row["status"].'</td>
<td><a title="Click To Edit Order Detail" rel="facebox" href="editorderdetail.php?id=' .$row["orderNumber"];.'"><button class="btn btn-warning btn-mini"><i class="icon-edit"></i> Edit </button></a>
<button class="btn btn-danger btn-mini"><i class="icon-trash"></i> Delete</button></td>
</tr>
';
}
I expect to get the $row["orderNumber"] in the url for edit and delete purpose.
You should consider using an editor with syntax highlighting, so the obvious errors are easily fixed. Try following:
while ($row = mysqli_fetch_array($result)) {
$output .= '<tr><td>' .
$row["orderNumber"] . '</td><td>' .
$row["orderDate"] . '</td><td>' .
$row["requiredDate"] . '</td><td>' .
$row["status"] . '</td><td>' .
'<a title="Click To Edit Order Detail" rel="facebox" href="editorderdetail.php?id=' . $row["orderNumber"] . '">' .
'<button class="btn btn-warning btn-mini"><i class="icon-edit"></i> Edit </button></a>' .
'<a href="#" id="' . $row["orderNumber"] . 'class="delete" title="Click To Delete">' .
'<button class="btn btn-danger btn-mini"><i class="icon-trash"></i> Delete</button></a>' .
'</td></tr>';
}
Related
i am getting these
but i need this
How to get seperate value for quiz name ?
query=select userquiz.id,userquiz.user_id,userss.username,quiz.quiz_name,GROUP_CONCAT(userquiz.quiz_id) as 'quiz_id',GROUP_CONCAT(quiz.quiz_name) as 'quiz_name' from userquiz join userss on userss.id=userquiz.user_id join quiz on quiz.quiz_id=userquiz.quiz_id group by user_id;
$filter_query = $query . ' ' . 'LIMIT ' . $start . ', ' . $limit
. '';
$statement = $connect->prepare($query);
// print_r($query);
$statement->execute();
$total_data = $statement->rowCount();
$statement = $connect->prepare($filter_query);
$statement->execute();
$result = $statement->fetchAll();
$total_filter_data = $statement->rowCount();
$output = '
<label> Total Records :- ' . $total_data . '</label>
<table class="table table-bordered" style="margin-top:40px";>
<tr>
<th>Username</th>
<th>Quizname</th>
<th>Action</th>
</tr>
';
if ($total_data > 0) {
foreach ($result as $row) {
$output .= '
<tr>
<td>' . $row["username"] . '</td>
<td><button type=" button" style="background-color:maroon; border: #4685A9;" class="btn btn-success"">' . $row["quiz_name"] . '</td>
<td><button type=" button" style="background-color:red; border: #4685A9;" class="btn btn-primary dltbtn" data-id="' . $row["user_id"] . '"> DELETE</button>
<button type=" button" style="background-color:orange; border: #4685A9;" class="btn btn-primary editbtn" data-eid="' . $row["user_id"] . '">Assign Quiz</button></td>
</tr>
';
}
this is how i am fetching the values
i need to make quiz as button so that can be deleted
Here is the code i have tried in controller
$categories = Category::where('categories.name', 'LIKE', '%' . $category_name . '%')
->where('categories.category_code', 'LIKE', '%' . $category_code . '%')->get();
$category_data = $categories->count();
if ($category_data > 0) {
$i = 1;
foreach ($categories as $category) {
$output .=
'<tr>
<td>' . $i++ . '</td>
<td><img src="' . asset($category->photo) . '" class="img-fluid" style="width: 170px; object-fit: cover;"></td>
<td>' . $category->name . '</td>
<td>' . $category->category_code . '</td>
<td><a href="' . route("category.edit", $category->id) . '" class="btn btn-warning">
<i class="icofont-ui-settings icofont-1x"></i>
</a>
#if($delete == "yes")
<form action="' . route("category.destroy", $category->id) . '" method="POST" class="d-inline-block" onsubmit="return confirm("Are you sure to delete the item?")">
#csrf
#method("DELETE")
<button class="btn btn-outline-danger" type="submit"><i class="icofont-close icofont-1x"></i></button>
</form>
#endif
</td>
</tr>';
}
return Response($output);
Code in blade file, jquery
$('#filtersearch').click(function() {
var category_name = $('#category_name').val();
var category_code = $('#category_code').val();
// alert(category_name)
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
})
$.get('/categorysearch', {
category_name: category_name,
category_code: category_code
},
function(data) {
$('#filter_data').html(data);
})
})
the output looks like thisall of the blade directive are showing as string
Is there a way to develop this, any solution would be very greatful.
Thanks!
I think the best way to do this is by using render() method
you can create your view file and pass your data and render the final HTML code
Example
$renderedHtml = view('your_view_file',compact('some_data'))->render();
then you can respond with your rendered HTML
return Response($renderedHtml );
I hope it's helpful
You have to use Concatenation in laravel for parsing string:
foreach ($categories as $category) {
$output .=
'<tr>
<td>' . $i++ . '</td>
<td><img src="' . asset($category->photo) . '" class="img-fluid" style="width: 170px; object-fit: cover;"></td>
<td>' . $category->name . '</td>
<td>' . $category->category_code . '</td>
<td><a href="' . route("category.edit", $category->id) . '" class="btn btn-warning">
<i class="icofont-ui-settings icofont-1x"></i>
</a>';
if($delete == "yes"){
$output .= '<form action="' . route("category.destroy", $category->id) . '" method="POST" class="d-inline-block" onsubmit="return confirm("Are you sure to delete the item?")">';
$output .= '<input type="hidden" name="_token" value="'.csrf_token().'">';
$output .= '<input type="hidden" name="_method" value="DELETE"><button class="btn btn-outline-danger" type="submit"><i class="icofont-close icofont-1x"></i></button>
</form>';
}
$output .='</td></tr>';
}
Starting from laravel 9.0, you can render blade strings on the fly
use Illuminate\Support\Facades\Blade;
//...
$categories = Category::where('categories.name', 'LIKE', '%' . $category_name . '%')
->where('categories.category_code', 'LIKE', '%' . $category_code . '%')->get();
$category_data = $categories->count();
if ($category_data > 0) {
$i = 1;
foreach ($categories as $category) {
$output .=
'<tr>
<td>' . $i++ . '</td>
<td><img src="' . asset($category->photo) . '" class="img-fluid" style="width: 170px; object-fit: cover;"></td>
<td>' . $category->name . '</td>
<td>' . $category->category_code . '</td>
<td><a href="' . route("category.edit", $category->id) . '" class="btn btn-warning">
<i class="icofont-ui-settings icofont-1x"></i>
</a>
#if($delete == "yes")
<form action="' . route("category.destroy", $category->id) . '" method="POST" class="d-inline-block" onsubmit="return confirm("Are you sure to delete the item?")">
#csrf
#method("DELETE")
<button class="btn btn-outline-danger" type="submit"><i class="icofont-close icofont-1x"></i></button>
</form>
#endif
</td>
</tr>';
}
return Blade::render($output, ['delete' => 'yes']);
If you're on laravel 8.x or lower, you can use this package felixdorn/laravel-render-blade-string or the other answers solutions
while($row =$result->fetch())
{
$output .= '
<tr>
<td>' . $row["ID_personne"] . '</td>
<td>' . $row["Nom"] . '</td>
<td>' . $row["Prenom"] . '</td>
<td>' . $row["Telephone"] . '</td>
<td>' . $row["Mail"] . '</td>
<td>' . $row["Categorie"] . '</td>
<td>' . $row["Type"] . '</td>
'.$q2 = $db->prepare("SELECT * FROM entretiens WHERE ID_entretien=:id");
$q2->bindValue(":id",$row["Entretien"]);
$q2->execute();
$entretien=$q2->fetch().'
<td>'.$entretien["Date"].'</td>
<td width=250>
<a class="btn btn-primary" href="update_personnes.php?ID_personne='.$row["ID_personne"].'"><span class="glyphicon glyphicon-pencil"></span> Modifier</a>
<a class="btn btn-danger" href="delete_personnes.php?ID_personne='.$row["ID_personne"].'"><span class="glyphicon glyphicon-remove"></span> Supprimer</a>
</td>
</tr>';
}
$output .= '</table>';
echo $output;
I have always an Error: ( ! ) Catchable fatal error: Object of class PDOStatement could not be converted to string in C:.......... on line 61('.$q2 = $db->prepare("SELECT * FROM entretiens WHERE ID_entretien=:id");
$row["Entretien"] it's a foreign key
There was some syntax error in your code as $q2 is being concat with html string. Improved code should be:
while ($row = $result->fetch()) {
$output .= '
<tr>
<td>' . $row["ID_personne"] . '</td>
<td>' . $row["Nom"] . '</td>
<td>' . $row["Prenom"] . '</td>
<td>' . $row["Telephone"] . '</td>
<td>' . $row["Mail"] . '</td>
<td>' . $row["Categorie"] . '</td>
<td>' . $row["Type"] . '</td>';
$q2 = $db->prepare("SELECT * FROM entretiens WHERE ID_entretien=:id");
$q2->bindValue(":id", $row["Entretien"]);
$q2->execute();
$entretien = $q2->fetch();
$output .= '<td>' . $entretien["Date"] . '</td>
<td width=250>
<a class="btn btn-primary" href="update_personnes.php?ID_personne=' . $row["ID_personne"] . '"><span class="glyphicon glyphicon-pencil"></span> Modifier</a>
<a class="btn btn-danger" href="delete_personnes.php?ID_personne=' . $row["ID_personne"] . '"><span class="glyphicon glyphicon-remove"></span> Supprimer</a>
</td>
</tr>';
}
$output .= '</table>';
echo $output;
see my code here
if(isset($_POST['table_category_view'])){
$result = $wpdb->get_results('SELECT id,category FROM '.$ps_category_table_name,ARRAY_A);
$html = "";
foreach ($result as $value){
$id = $value['id'];
$categry = $value['category'];
$html .= '<tr id="catgry-row' . $id . '">';
$html .= '<td id="catgry-row' . $id . '">'.$categry.'</td>';
$html .= '<td><button class="btn btn-primary btn-sm" id="edit-catgry' . $id . '" onclick="edit_category("' . $id . '");">Edit</button>';
$html .= '<button class="btn btn-danger btn-sm" id="delete-catgry' . $id . '" onclick="delete_category("' . $id . '");">Delete</button>';
$html .= '<button class="btn btn-primary btn-sm" style="display:none" id="update-catgry' . $id . '" onclick="update_category("' . $id . '");">Update</button>';
$html .= '<button class="btn btn-warning btn-sm" style="display:none" id="cancel-update-catgry' . $id . '" onclick="cancel_update_category("' . $id . '");">Cancel</button></td></tr>';
}
echo $html;
}
here how to write onclick function in my code it was not working please give me solution
enclose your sentence inside the double quote ("") not single code & write your code as below,
$html = "<td><button class='btn btn-primary btn-sm' id='edit-catgry".$id." ' onclick=edit_category('$id');>Edit</button>";
you have to write the function parameter like this in php.
onclick="edit_category('.$id.');"
Please try below code:
<?php
if(isset($_POST['table_category_view'])){
$result = $wpdb->get_results('SELECT id,category FROM '.$ps_category_table_name,ARRAY_A);
$html = "";
foreach ($result as $value){
$id = $value['id'];
$categry = $value['category'];
$html .= '<tr id="catgry-row' . $id . '">';
$html .= '<td id="catgry-row' . $id . '">'.$categry.'</td>';
$html .= '<td><button class="btn btn-primary btn-sm" id="edit-catgry' . $id . '" onclick="edit_category(' . $id . ');">Edit</button>';
$html .= '<button class="btn btn-danger btn-sm" id="delete-catgry' . $id . '" onclick="delete_category(' . $id . ');">Delete</button>';
$html .= '<button class="btn btn-primary btn-sm" style="display:none" id="update-catgry' . $id . '" onclick="update_category(' . $id . ');">Update</button>';
$html .= '<button class="btn btn-warning btn-sm" style="display:none" id="cancel-update-catgry' . $id . '" onclick="cancel_update_category(' . $id . ');">Cancel</button></td></tr>';
}
echo $html;
}
?>
Being a complete numpty at this....
I am having troubles getting the below code to work (just shows the white screen of death)
case 'venue' :
if( self::isValid($atts['venue'])) {
$output .= '<td>' . apply_filters( 'ecs_event_list_venue', tribe_get_venue(), $atts ) . '</span></td>';
if( !empty(tribe_get_event_website_link()) ) {
$output .= '<td><a class="btn btn-danger btn-small" href="' . tribe_get_event_website_link() . '">Bookings</a></td>';
} else {
$output .= '<td><a class="btn btn-danger btn-small" href="' . tribe_get_event_link() . '">Read More</a></td>';
}
}
}
break;
The original code was
case 'venue' :
if( self::isValid($atts['venue'])) {
$output .= '<td>' . apply_filters( 'ecs_event_list_venue', tribe_get_venue(), $atts ) . '</span></td>';
}
break;
This works fine..
Any assistance appreciated and respected!!
You can try this :
if( self::isValid($atts['venue'])) {
$output .= '<td>' . apply_filters( 'ecs_event_list_venue', tribe_get_venue(), $atts ) . '</span></td>';
$is_value = tribe_get_event_website_link();
if( !empty($is_value) ) {
$output .= '<td><a class="btn btn-danger btn-small" href="' . tribe_get_event_website_link() . '">Bookings</a></td>';
} else {
$output .= '<td><a class="btn btn-danger btn-small" href="' . tribe_get_event_link() . '">Read More</a></td>';
}
}
You can't use function return value like this.