i have method to get word form searchbar and query in db,then return to view
but it show empty table although i check for null variable
this is controller code
<?php
public function getSearch($title) {
$words = Word::where('title', $title)->first();
if (empty($words)) {
abort(404);
}
return view('dict.index', compact('words'));
}
here is view code
<?php
foreach ($words as $row) {
echo '<tr>';
echo '<td>' . $row['title'] . '</td>';
echo '<td>' . $row['meaning'] . '</td>';
echo '<td>';
for ($i = 0; $i < $row['rate']; $i++) {
echo '<img src="/images/pjdict/star.png" width="20" height="20">';
}
echo '</td>';
echo '</tr>';
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire