How to reset row in PHP?

Php to load a whole row from mysql?

  • Answer:

    Marcos code with a couple minor tweaks so you don't run over any constants or pull back more data than you hoped for. "select * from table where user_name = '{$_POST['user_name']}' limit 0,1"; Make sure to sanitize your post string before it reaches this point though.

Yahoo! Answers Visit the source

Was this solution helpful to you?

Other answers

Marcos code with a couple minor tweaks so you don't run over any constants or pull back more data than you hoped for. "select * from table where user_name = '{$_POST['user_name']}' limit 0,1"; Make sure to sanitize your post string before it reaches this point though.

You probably don't want to use PHP to do this as PHP only runs when the page is first loaded. If you use PHP, you'll have to reload the page everytime a user name is clicked. The better way would be to use Javascript. There are two options available to do this: 1. jQuery - With this method, you'll load the whole row of info and just hide everything but the user name. When the user name is clicked, jQuery will then show the rest of the row. 2. AJAX - With this method, you'll actually query the database when the username is clicked. Check out this site for a great example: http://www.w3schools.com/php/php_ajax_database.asp Frankly, jQuery would be better and easier. If you're already querying the database when the page loads to grab the user names, you might as well just grab all the info and just hide the section you dont want to show until the user names are clicked. Example would be like this: <style> .hidden{ display:none; } </style> <!-- We're just hiding anything with the class hidden when the page loads --> <div class="username">User Name</div> <div class="hidden">This is the hidden stuff</div> <script> //Now we write the script so when a username div is clicked is clicked, it shows the NEXT div right after it. IE it will show the hidden div right after it and no other hidden div. I set it to 'toggle' instead of show, that way if they click it twice, it hides it again. God jQuery makes life easy. // $('.username').click(function() { $(this).next().toggle(); }) <script>

board678

("select * from table where user name =( &_POST[user_name])";

Mark O

You probably don't want to use PHP to do this as PHP only runs when the page is first loaded. If you use PHP, you'll have to reload the page everytime a user name is clicked. The better way would be to use Javascript. There are two options available to do this: 1. jQuery - With this method, you'll load the whole row of info and just hide everything but the user name. When the user name is clicked, jQuery will then show the rest of the row. 2. AJAX - With this method, you'll actually query the database when the username is clicked. Check out this site for a great example: http://www.w3schools.com/php/php_ajax_database.asp Frankly, jQuery would be better and easier. If you're already querying the database when the page loads to grab the user names, you might as well just grab all the info and just hide the section you dont want to show until the user names are clicked. Example would be like this: <style> .hidden{ display:none; } </style> <!-- We're just hiding anything with the class hidden when the page loads --> <div class="username">User Name</div> <div class="hidden">This is the hidden stuff</div> <script> //Now we write the script so when a username div is clicked is clicked, it shows the NEXT div right after it. IE it will show the hidden div right after it and no other hidden div. I set it to 'toggle' instead of show, that way if they click it twice, it hides it again. God jQuery makes life easy. // $('.username').click(function() { $(this).next().toggle(); }) <script>

board678

("select * from table where user name =( &_POST[user_name])";

Mark O

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.