= $anydk) { $useref = "AND ref='$ref'"; $targetdk = $refdk; } // Okay, we now have the right dk target to use, so select a title from // any titles available at that level. We will prefer titles that // match the ref if possible. $sql = "SELECT male,female FROM " . db_prefix("titles") . " WHERE dk='$targetdk' $useref ORDER BY RAND(" . e_rand() . ") LIMIT 1"; $res = db_query($sql); $row = array('male'=>'God', 'female'=>'Goddess'); if (db_num_rows($res) != 0) { $row = db_fetch_assoc($res); } if ($gender == SEX_MALE) return $row['male']; else return $row['female']; } ?>