note 40576 deleted from function.mysql-fetch-row by philip

From: Date: Mon, 26 Feb 2007 06:55:11 +0000
Subject: note 40576 deleted from function.mysql-fetch-row by philip
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-123872@lists.php.net to get a copy of this message
Note Submitter: wizzkidy at hotmail dot com ---- Here's a little code snipped I used to make dynamic HTML even if the table changed its rows. Hope somebody can use it. <?PHP #Find all columns in the table $sql_a = "select * FROM table_a"; $exc_a = mysql_query($sql_a) or die(mysql_error()); $fields = mysql_list_fields($DBname, $DBTableName); $columns = mysql_num_fields($fields); for ($i = 0; $i < $columns; $i++){ $fieldnames[] = mysql_field_name($exc_a, $i); } #by referencing the values inserting it in the array IF($rst_a = mysql_fetch_array($exc_a)){ $num_fields = count($fieldnames); for ($ii = 0; $aantal_fields > $ii; $ii++){ $fieldValues[$fieldnames[$ii]] = $rst_a[$fieldnames[$ii]]; } } ?> $fieldValues[] = array of column names with their corresponding values, you can even make it multi dimensional by adding $fieldValues[$fieldnames[$ii]][] instead (so if youre wanting to have your complete database table in this array its possible :)

« previous php.notes (#123872) next »