Hi,
I am trying to write a function that will:
- take a list of mysql tables as an array ($sqltables)
- take a unique row identifier common to all tables ($rid)
- iterate through the $sqltables array and fetch the row for each table
where rid = $rid
- discover the names of the fields in each table and do
session_register for all of them
- set the value of each session_registered variable to the row contents
for that $rid
- go to the next table and do it again, until all tables have been
queried and all variables have been discovered and populated
I just need some help. Here is what I have written from the top of my
head:
Thanks in advance,
Mike
PS: please reply to my address personaly also!
-----------------------------------------------
<?php
function load_all($rid) {
// this is a list of sql tables stored in an array that we will
iterate through
// and use to populate session variables
include("/usr/local/apache/htdocs/survey/inc/sqltables.inc");
for($Index=0;$Index<count($sqltables);$Index++) {
// select the database for usage
mysql_select_db($db2, $competency_link);
// query the table for the row containing $rid
$sql_query = mysql_query("SELECT * FROM $sqltables[$Index] WHERE
rid = $rid");
$result = mysql_query($sql_query);
// fetch the row
$myrow = msyql_fetch_array($result);
// return the values of each fieldname as variables with same
name
// count the fields in the row
$num_fields = mysql_num_fields($myrow);
for($fieldindex=0;$index<count($num_fields);$fieldindex++) {
// return the field names
$fieldname = mysql_field_name($num_fields[$fieldindex]);
// return the values of each fieldname as variables with
same name
session_register('fieldname');
}
}
}
?>
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]