Getting a variable in while loop

WockoLad

SELECT * FROM `lads` WHERE `username` = 'WockoLad'
Dec 24, 2014
233
23
Hello,

I've got a table, and a while loop to get the rows from the database and echo into the table.
However, I want a modal that will display the name of the person that you click edit by.

I've done $person = $getpeople2['name'];
And the name comes up with the first person in the table, regardless.

Any help would be greatly appreciated.
 

MayoMayn

BestDev
Oct 18, 2016
1,423
683
  1. mysql_* functions are deprecated, don't use them
  2. Don't execute multiple queries when you can combine them into one
  3. Be a little bit more descriptive about what you want help with exactly
 
Last edited by a moderator:

WockoLad

SELECT * FROM `lads` WHERE `username` = 'WockoLad'
Dec 24, 2014
233
23
  1. mysql_* functions are deprecated, don't use them
  2. Don't execute multiple queries when you can combine them into one
  3. Be a little bit more descriptive about what you want help with exactly
I know MySQL is deprecated. It's going to be redone in Laravel when I have time.
That is ... True.
So, basically. I need the variable $user to match the particular row in the table? So I can echo it in a modal?
 

Adil

DevBest CEO
May 28, 2011
1,276
714
What I would do is append some data to the table rows.
Something like this (pseudocode):
Code:
while(results not null) {
echo "<tr><td onclick="alertName(username_var)">somevar1</td><td>somevar2</td><td>somevar3</td>";
}

You could also have the data be returned as JSON, and then build the table using javascript.
(quite advanced but very nice)
 

Users who are viewing this thread

Top