Код:

#include 'array.au3'
#include 'mysql.au3'
#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <WindowsConstants.au3>
Global $sHost = FileReadLine ("set.ini",1)
Global $sUser = FileReadLine ("set.ini",2)
Global $sPass = FileReadLine ("set.ini",3)
Global $sDbName = FileReadLine ("set.ini",4)
Global $hMainWin = GUICreate('History Show', 800, 500)
GUIRegisterMsg($WM_NOTIFY, 'WM_NOTIFY')
Global $clientIDs = GUICtrlCreateListView('', 10, 30, 100, 200)
_GUICtrlListView_SetExtendedListViewStyle($clientIDs, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT))
_GUICtrlListView_AddColumn($clientIDs, 'CLients', 96)
Global $rcvrAccs = GUICtrlCreateListView('', 120, 30, 100, 200)
_GUICtrlListView_SetExtendedListViewStyle($rcvrAccs, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT))
_GUICtrlListView_AddColumn($rcvrAccs, 'Access', 96)
Global $results = GUICtrlCreateEdit('', 230, 30, 570, 460)
$gg = _SQL_GetData($sHost,$sUser,$sPass,$sDbName, 'SELECT DISTINCT ClientID FROM hist')
_ArrayDisplay($gg)
_ArrayToList($clientIDs, $gg, 1)
;$gg = _SQL_GetData('127.0.0.1', 'root', 'GsM2562r', 'chat', 'SELECT DISTINCT rcvrAccs FROM hist')
;_ArrayDisplay($gg)
;_ArrayToList($rcvrAccs, $qq, 1)
Func _SQL_GetData($sHost, $sUser, $sPass, $sDbName, $sQuery)
Local $MysqlConn, $connected, $errno, $res, $gg
_MySQL_InitLibrary()
$MysqlConn = _MySQL_Init()
$connected = _MySQL_Real_Connect($MysqlConn, $sHost, $sUser, $sPass, $sDbName)
If $connected = 0 Then
$errno = _MySQL_errno($MysqlConn)
MsgBox(0,'Error:',$errno & @LF & _MySQL_error($MysqlConn))
If $errno = $CR_UNKNOWN_HOST Then MsgBox(0, 'Error:', '$CR_UNKNOWN_HOST' & @LF & $CR_UNKNOWN_HOST)
Endif
$query = "/*!40101 SET NAMES 'cp1251' */"
_MySQL_Real_Query($MysqlConn, $query)
$query = $sQuery
_MySQL_Real_Query($MysqlConn, $query)
$res = _MySQL_Store_Result($MysqlConn)
$gg = _MySQL_Fetch_Result_StringArray($res)
Return $gg
EndFunc
GUISetState()
Do
$msg = GUIGetMsg()
;~ Select
;~ Case
;~ EndSelect
Until $msg = $GUI_EVENT_CLOSE
_MySQL_Free_Result($res)
_MySQL_Close($MysqlConn)
_MySQL_EndLibrary()
Func _ArrayToList($hList, $aArray, $iStart=0, $iEnd=0)
If NOT IsArray($aArray) Then Exit MsgBox(48, 'Внимание', 'Ошибка: $aArray не является маасивом')
If NOT $iEnd Then $iEnd = UBound($aArray)-1
MsgBox(48, 'Инфо', 'В массиве всего элементов: ' & (UBound($aArray)-1) & @CRLF & 'Перебор массива с: ' & $iStart & ' по: ' & $iEnd)
Local $i
For $i=$iStart To $iEnd
MsgBox(0, 'Ввод данных', 'i: ' & $i)
_GUICtrlListView_AddItem($hList, $aArray[$i])
Next
EndFunc
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
#forceref $hWnd, $iMsg, $iwParam
Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo
;~ Local $tBuffer
$hWndListView = $iwParam
If Not IsHWnd($hWndListView) Then $hWndListView = GUICtrlGetHandle($hWndListView)
$tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
$hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
$iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
$iCode = DllStructGetData($tNMHDR, "Code")
Switch $hWndFrom
Case $hWndListView
Switch $iCode
Case $NM_CLICK
Local $iIndex = _GUICtrlListView_GetSelectedIndices($hWndListView)
Local $sText = _GUICtrlListView_GetItemText($hWndListView, $iIndex)
Switch $iwParam
Case $clientIDs
_GetClientData($sText)
Case $rcvrAccs
_GetAccessData($sText)
EndSwitch
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY
Func _GetClientData($sText)
MsgBox(0, 'Client выбранно:', $sText)
;~ Сформировать нужный SELECT запрос для базы:
Local $aResult = _SQL_GetData('127.0.0.1', 'root', 'GsM2562r', 'chat', 'SELECT DISTINCT ClientID FROM hist')
GUICtrlSetData($results, _ArrayToString($aResult, 1, UBound($aResult), @CRLF))
EndFunc
Func _GetAccessData($sText)
MsgBox(0, 'Access выбранно:', $sText)
;~ Сформировать нужный SELECT запрос для базы:
Local $aResult = _SQL_GetData('127.0.0.1', 'root', 'GsM2562r', 'chat', 'SELECT DISTINCT rcvrAccs FROM hist')
GUICtrlSetData($results, _ArrayToString($aResult, 1, UBound($aResult), @CRLF))
EndFunc