Hey guys and gals, I have the following function which accesses the following tables, now i want to know if there is a way to get the quiz_id from table quiz without runnning both these queries... thanks,
Jule --tables-- mysql> describe user; +------------+------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +------------+------------------+------+-----+---------+----------------+ | user_id | int(10) unsigned | | PRI | NULL | auto_increment | | first_name | varchar(10) | | | | | | last_name | varchar(20) | | | | | | email | varchar(100) | | | | | | username | varchar(16) | | | | | | password | varchar(32) | | | | | +------------+------------------+------+-----+---------+----------------+ mysql> describe quiz; +---------+------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +---------+------------------+------+-----+---------+----------------+ | quiz_id | int(10) unsigned | | PRI | NULL | auto_increment | | user_id | int(10) unsigned | | | 0 | | | title | varchar(255) | | | | | | noa | tinyint(2) | | | 0 | | +---------+------------------+------+-----+---------+----------------+ --function-- function addquiz_get_quiz_id() { global $valid_user, $valid_password; mysql_select_db($db_glob, $link_glob); $table_user = "user"; $table_quiz = "quiz"; $query = "SELECT * FROM $table_user WHERE username='$valid_user' AND password='$valid_password'"; $result = mysql_query($query); $user_info = mysql_fetch_array($result); $user_id = $user_info[user_id]; $query = "SELECT * FROM $table_quiz WHERE user_id='$user_id'"; $result = mysql_query($query); $user_info = mysql_fetch_array($result); $quiz_id = $user_info[quiz_id]; mysql_close($link_glob); return $quiz_id; } -- Jule Slootbeek [EMAIL PROTECTED] http://blindtheory.cjb.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php