Revision: 14395
Updated Code
at June 2, 2009 13:37 by kilrizzy
Updated Code
function getrowdata($tablename,$rowid,$prefix){ $field_query = mysql_query("SELECT * FROM ".$tablename." WHERE id = ".$rowid.""); if(mysql_num_rows($field_query) > 0){ //Get field data $field_array = mysql_fetch_array($field_query); foreach($field_array as $field_key=>$field_value){ //Setup a global variable name for this data based on prefix global ${"{$prefix}$field_key"}; ${"{$prefix}$field_key"} = stripslashes($field_value); } } }
Revision: 14394
Updated Code
at June 2, 2009 13:01 by kilrizzy
Updated Code
function getrowdata($tablename,$rowid,$prefix){ $field_query = mysql_query("SELECT * FROM ".$tablename." WHERE id = ".$rowid.""); if(mysql_num_rows($user_query) > 0){ //Get field data $field_array = mysql_fetch_array($field_query); foreach($field_array as $field_key=>$field_value){ //Setup a global variable name for this data based on prefix global ${"{$prefix}$field_key"}; ${"{$prefix}$field_key"} = stripslashes($field_value); } } }
Revision: 14393
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at June 2, 2009 12:57 by kilrizzy
Initial Code
function getrowdata($tablename,$rowid,$prefix){ $user_query = mysql_query("SELECT * FROM ".$tablename." WHERE id = ".$rowid.""); if(mysql_num_rows($user_query) > 0){ //Get field data $field_array = mysql_fetch_array($user_query); foreach($field_array as $field_key=>$field_value){ //Setup a global variable name for this data based on prefix global ${"{$prefix}$field_key"}; ${"{$prefix}$field_key"} = stripslashes($field_value); } } }
Initial URL
http://www.jeffkilroy.com
Initial Description
Use this function to pull all columns from a single database field. getrowdata(tablename,rowid,prefix); You would call this function like: getrowdata("users",$_SESSION['user'],"user_"); The prefix is the prefix you want for the array names, so if I have a field in my "users" table called "username", the example above would output the variable "$user_username = 'data';"
Initial Title
PHP/MySQL - Get Row Data
Initial Tags
mysql, database, php, data
Initial Language
PHP