This topic is locked

DATABASE-BASED DROPDOWNS WITH DIALOG API

4/3/2023 8:24:48 AM
PHPRunner General questions
C
chopperpilot author

Hi,
I need help here, I copied the code from https://xlinesoft.com/blog/2021/05/26/database-based-dropdowns-with-dialog-api/?fbclid=IwAR3U_LeloCHU3KxhgF7C0Q7cwKtygHgI7ue_q797Bst2qjNnUmTLYZ3sPck, however it doesnt do anything, this is my code, I will appreciate if someone can help me.:
//Before Display $lookup = array(); $rs1 = DB::Query("SELECT Email,Full_Name FROM Applicants ORDER BYFirst Name` ASC");
while( $data1 = db_fetch_array($rs1))
{
$row = array();
$row[] = $data1["Full_Name"];
$row[] = $data1["Email"];
}
$pageObject->setProxyValue("lookup", $lookup);
///////////////////////////////////////////////////////////////////// For another table//////////
$rs = DB::Query("SELECT RId, nick_name FROM Restaurants ORDER BY nick_name ASC");
$restaurants = [];
while($data = $rs->fetchAssoc())
{
$restaurants[] = [$data['RId'], $data['nick_name'] ];
}
$pageObject->setProxyValue('restaurants',$restaurants);

///////////////////// End Before Display////////////////

//Client Before

window.proxy = proxy;

return ctrl.Dialog
(
{
title: 'Preferences',

fields: [
{
name: 'email',
label: 'Select emails',
type: 'lookup',
required: true,
//attribute:'multiple',
options: window.proxy['lookup']
}
],
ok: 'Save',
cancel: 'Cancel',
beforeOK: function( popup, controls ) {
swal('Success', 'Selected emails: ' + controls[0].val(), 'success');
}
}
);

// Server

$result["email"] = $params["email"];

// Client After

// Put your code here.
var message = result['email'];
swal (message);`

Sergey Kornilov admin 4/3/2023

You cannot expect your code to work if you randomly remove parts of the code. My advice is start from scratch, use the code from the article and only change database field and table names, do not change anything else. It will work.