I'm developing a small project in which I use a loop to display all the contents of a database table in an HTML table. For each row I need a clickable button that, if pressed , can "remember" the ID of the table's element to witch it corresponds. I've some problem with the href of the link. That's my code:
<td>
<i class="small material-icons right">mode_edit</i>
</td>
I've also tried this:
<td>
<i class="small material-icons right">mode_edit</i>
</td>
Can anyone help me please? Thanks!
You're not setting any $_GET variable name in your href attribute.
Try replacing
<i class="small material-icons right">mode_edit</i>
By
<i class="small material-icons right">mode_edit</i>
Basically, I've added id between the ?=. And removed the space in your $row[' ID ']
modifica.php?id=
Instead of
modifica.php?=
I've removed the space in the index of the $row variable because $row[' ID '] is not the same as $row['ID'].
You should probably remove the spaces within the square brackets and add a name to the GET variable, it would look like this:
<td>
<i class="small material-icons right">mode_edit</i>
</td>
instead of writing
$row[ ' ID ']
use
$row['ID']
you have spaces before and after ID text, fix that please
Related
I already get all the data from the database and displayed it on my vue component. But, how can I display specific data on the table?
Like if the results from the database contains a user type of 'SuperAdmin'
I wanted to filter it like don't display if you find data related 'SuperAdmin'
https://imgur.com/kwTziOG - Here is my output.
I have searched this kind of problem and nothings pops-up.
Say for example.
['Paul','paul#new.com',['Admin']
['Paul', 'paul#new.com', ['SuperAdmin']
I just want to display the first array. Since it doesn't have a user type of SuperAdmin.
<tr v-for="user in users.data" :key="user.id">
<td>{{user.id}}</td>
<td>{{user.name}}</td>
<td>{{user.email}}</td>
<td>{{user.type}}</td>
<td>{{user.created_at |myDate}}</td>
<td>
<a href="#" #click="editModal(user)">
<i class="fa fa-edit"></i>
</a>
/
<a href="#" #click="deleteUser(user.id)">
<i class="fa fa-trash red"></i>
</a>
</td>
</tr>
I just displayed all the data being fetch in the database. Just wanted it to filter it somehow.
I have not used Vue in alittle while but if I remember correctly you can just use 'v-if' and it will conditionally render the data. Below is an example of how this could be done.
Possible Solution
<tr v-for="user in users.data" :key="user.id">
<div v-if="user.type == 'SuperAdmin'">
<td>{{user.id}}</td>
<td>{{user.name}}</td>
<td>{{user.email}}</td>
<td>{{user.type}}</td>
<td>{{user.created_at |myDate}}</td>
<td>
<a href="#" #click="editModal(user)">
<i class="fa fa-edit"></i>
</a>
<a href="#" #click="deleteUser(user.id)">
<i class="fa fa-trash red"></i>
</a>
</td>
</div>
</tr>
Hope this answered your question, good luck!
i'm trying to create a table with some button, a, glyphicon, span etc... but it is dynamic and goes inside php text. The table and the dynamic variables are showed but when I add everythings die. This is my code:
$output .= '<tr> <td>
<span class="glyphicon glyphicon-pencil"></span>
<span class="glyphicon glyphicon-remove"></span>
</td> <td>'.$product["Title"].'</td>
<td>'.money($product["Price"]).'</td>
<td>'.$category.'</td>
<td>'.$row1["mobile"].'</td></tr> ';' }
I am trying to get all record which are available in my database table currently there are 3 records available with id 1,2 and 3 and i am only getting record related to id 1.
My Controller method:
public function EmailList()
{
$listing = Buyer::all();
return view('email-list',compact('listing'));
}
and my route:
$router->get('/List-of-Emails', 'AjaxController#EmailList');
and in my view i am passing foreach loop
#foreach($listing as $list)
<tr>
<input type="hidden" id="rwid" value="{{$list->id}}"/>
<td>
<input id="{{$list->id}}" class="checkbox-custom" name="{{$list->id}}" type="checkbox"
value="{{$list->id}}">
<label for="{{$list->id}}" class="checkbox-custom-label"></label>
</td>
<td>
<p data-placement="top" data-toggle="tooltip" title="" data-original-title="Tolltip">
{{$list->name}}
</p>
</td>
<td>
<a href="" class="pglst-lnk">
{{$list->email}}
</a>
</td>
<td>
{{$list->created_at}}
</td>
<td>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
#endforeach
i am getting only first and only single record however i want to get all records from table where i am doing wrong.
Any help would be highly appreciated!
I think this is a DOM parsing error.
Can you put the #endforeach just below the closing </tr> tag?
#foreach($listing as $list)
<tr>
<!-- data -->
</tr>
#endforeach
EDIT: Explanation
For those interested: the browser is incapable of parsing the HTML as given by OP. This is because after one record, he closes the table and a couple of divs. Then the foreach-loop starts again, in which he suddenly introduces new <tr>s and is closing <table>s and <div>s that don't exist. It will probably put an error message in the console, but not everybody looks there as it's not directly obvious that the outputted HTML is wrong.
Use Some query like
$user = DB::table('users')->where('name', 'John')->orderby('id','desc')->limit('the record you want')->first();
I have the following <td> tag with <a> tag in it that contains a php variable in href. I only can browse upto uploads folder. Does anyone know why? It supposed to browse until uploads\$_POST['searchInput'] . But it is not doing that.
<td class="viewEditTd"><button class = "btn btn-info viewEditButton"><a href="file://///172.xx.xx.xxx\TEMP\xxx\uploads\"<?php echo $_POST['searchInput']; ?>"\" target="_blank"><span class="
glyphicon glyphicon-folder-open" aria-hidden="true"></span> View File</a></button></td>
I am able to solve the issue with the help of Stack overflow forum member. This is how it solved. My issue was as below
<td class="viewEditTd"><button class = "btn btn-info viewEditButton"><a href="file://///172.xx.xx.xxx\TEMP\xxx\uploads\"<?php echo $_POST['searchInput']; ?>"\" target="_blank"><span class="
glyphicon glyphicon-folder-open" aria-hidden="true"></span> View File</a></button></td>
It was solved by removing the two double quotes around the php tags. Working answer is
<td class="viewEditTd"><button class = "btn btn-info viewEditButton"><a href="file://///172.xx.xx.xxx\TEMP\xxx\uploads\<?php echo $_POST['searchInput']; ?>" target="_blank"><span class="
glyphicon glyphicon-folder-open" aria-hidden="true"></span> View File</a></button></td>
According to the loop in the fertilizer I'm just showing the value of one of them! It must be equal to the amount of data ID code because I want it to update the Value Form I, how do I do?
And if there is another way to say thanks.
In principle I would like to use AJAX Edition
#foreach($category as $cat)
<tr>
<td id="destroy_"><a data-delete id="destroy" data-id="{{$cat->id}}" href="#"><span
class="glyphicon glyphicon-remove" aria-hidden="true"></span></a></td>
<td id="update_"><a href="#" data-toggle="modal" data-target="#myModal"><span
class="glyphicon glyphicon-pencil" aria-hidden="true"></span></a></td>
<td>{{$cat->category}}
</td>
<th id="dataId" class="text-right">{{$cat->id}}</th>
</tr>
#endforeach