https://www.icyphoenix.com/viewtopic.php?f=26&t=5548 ----------------------------------- DWho Fri 06 Mar, 2009 10:54 Sql Query Problem ----------------------------------- I have a small script that calls three different thing from a database table ... it does not call everything correctly as shown in the image... [img]http://www.icyphoenix.com/files/images/166/06_03_2009_09_51_11.png[/img] here is the code.... I have spent forever reading php but cannot find the problem... any help I would be very grateful [spoiler][code linenumbers=false]$mode = isset($_POST['mode']) ? $_POST['mode'] : $_GET['mode']; $user = isset($_POST['user']) ? intval($_POST['user']) : intval($_GET['user']); $char = isset($_POST['char']) ? intval($_POST['char']) : ''; $action = isset($_POST['action']) ? $_POST['action'] : ''; $sql = 'SELECT * FROM '. USER_CHARACTERISTICS_TABLE .' GROUP BY characteristics_name'; $r = $db->sql_query($sql); $uc_rows = $db->sql_fetchrowset($r); $sql = 'SELECT * FROM '. USER_CHARACTERISTICS_DATA_TABLE .' ORDER BY characteristics_id DESC'; $r = $db->sql_query($sql); $uc_data_rows = $db->sql_fetchrowset($r); if ($mode == 'who') { $template->assign_block_vars('who', array()); $sql = 'SELECT username, user_id FROM '. USERS_TABLE; $r = $db->sql_query($sql); $users = $db->sql_fetchrowset($r); for ($x = 0; $x < count($uc_data_rows); $x++) { if ($uc_data_rows[$x]['to_user_id'] == $user) { for ($y = 0; $y < count($users); $y++) { if ($uc_data_rows[$x]['from_user_id'] == $users[$y]['user_id']) { $user_id = $users[$y]['user_id']; $username = $users[$y]['username']; break; } }; $template->assign_block_vars('who.rows', array( 'ROW_CLASS' => (($x % 2) ? $theme['td_class2'] : $theme['td_class1']), 'CHARACTERISTIC' => $uc_rows[$x]['characteristics_name'], 'IMAGE' => '', 'WHO' => ''. $username .'') ); } } } $template->set_filenames(array('body' => 'user_characteristics_body.tpl')); $template->assign_vars(array( 'L_IMAGE_TITLE' => $lang['uc_main_image'], 'L_NAME_TITLE' => $lang['uc_main_name'], 'L_VOTES_TITLE' => $lang['uc_main_votes'], 'L_SUBMIT' => $lang['uc_main_add'], 'HIDDEN' => $hidden, 'ACTION' => append_sid('user_characteristics.'. $phpEx)) ); include_once($phpbb_root_path .'includes/page_header.'. $phpEx); $template->pparse('body'); include_once($phpbb_root_path .'includes/page_tail.'. $phpEx);[/code][/spoiler] ----------------------------------- DWho Wed 22 Apr, 2009 22:53 Re: Sql Query Problem ----------------------------------- still stuck :( ----------------------------------- Mighty Gorgon Sun 26 Apr, 2009 18:26 Re: Sql Query Problem ----------------------------------- We need at least to know the table structure before being able to help. :wink: ----------------------------------- DWho Sun 26 Apr, 2009 20:35 Re: Sql Query Problem ----------------------------------- [quote user="Mighty Gorgon" post="38783"]We need at least to know the table structure before being able to help. :wink:[/quote] Is this what you need... this is the part I have not looked at.. :oops: [spoiler][code linenumbers=false]CREATE TABLE `ip_user_characteristics` ( `characteristics_id` int(10) unsigned NOT NULL auto_increment, `characteristics_name` varchar(255) NOT NULL default '', `characteristics_img` varchar(255) NOT NULL default '', PRIMARY KEY (`characteristics_id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ; -- -- Dumping data for table `ip_user_characteristics` -- -- -------------------------------------------------------- -- -- Table structure for table `ip_user_characteristics_data` -- CREATE TABLE `ip_user_characteristics_data` ( `characteristics_id` int(10) unsigned NOT NULL default '0', `to_user_id` int(10) unsigned NOT NULL default '0', `from_user_id` int(10) unsigned NOT NULL default '0' ) ENGINE=MyISAM DEFAULT CHARSET=latin1;[/code][/spoiler] :mrgreen: :mrgreen: ----------------------------------- Mighty Gorgon Thu 30 Apr, 2009 12:46 Re: Sql Query Problem ----------------------------------- Tell me exactly what you want to show as a result, and I will try to build the SQL for you. ----------------------------------- DWho Thu 30 Apr, 2009 15:36 Re: Sql Query Problem ----------------------------------- Basically in the acp you can add the images and the name you want.... then in users profile you click a link and you can vote on an image for that user... then the member can click and look at who voted for them and what they voted... the part above is when the user checks to see who voted them... I have added all the files in a pm you are just about to get... thank you so much for looking... :mrgreen: :mrgreen: ----------------------------------- Informpro Thu 05 Nov, 2009 12:34 Re: Sql Query Problem ----------------------------------- There is 2 sql request, you can build only one with Join ;) ----------------------------------- spydie Thu 05 Nov, 2009 15:16 Re: Sql Query Problem ----------------------------------- have you had a look at the $php_ex Mike? should be PHP_EXT now ----------------------------------- DWho Thu 05 Nov, 2009 16:03 Re: Sql Query Problem ----------------------------------- this post is over 6 months old and is being spammed by laracroft... I have reported it but am waiting for confirmation... FYI :mrgreen: :mrgreen: ----------------------------------- Informpro Thu 05 Nov, 2009 18:37 Re: Sql Query Problem ----------------------------------- I have see after, but this mod is interesting me (that's why I don't try to delete my post). But, if you have stop ... ----------------------------------- DWho Thu 05 Nov, 2009 23:12 Re: Sql Query Problem ----------------------------------- This mod is one i paid for a few years ago so it is not available for use.. :mrgreen: :mrgreen: