Data from second table
Data from second table
Driver
Posts: 23Questions: 0Answers: 0
I've got two tables:
Table1
------
element_25
Table2
------
element_id
option_id
option
Scenario 1:
Value for element_25 is "1".
Value for element_id is "25".
Value for option_id is "1".
Value for option is "poor".
Scenario 2:
Value for element_25 is "2".
Value for element_id is "25".
Value for option_id is "2".
Value for option is "good".
How could I get option value depending on my field value?
I just want to print for element_25 value from corresponding option field from second table.
My server_processing.php is taken from http://www.datatables.net/forums/discussion/5050/several-tables-added#Item_3
[code]<?php
/* Array of database columns which should be read and sent back to DataTables. Use a space where
* you want to insert a non-database field (for example a counter or static image)
*/
$aColumns = array( 'element_25' );
/* DB tables to use */
$aTables = array( 'Table1', 'Table2' );
/* Indexed column (used for fast and accurate table cardinality) */
$sIndexColumn = "";
/* CONDITIONS */
$sWhere = "";
/* Database connection information */
$gaSql['user'] = "";
$gaSql['password'] = "";
$gaSql['db'] = "";
$gaSql['server'] = "localhost";
$gaSql['link'] = mysql_pconnect( $gaSql['server'], $gaSql['user'], $gaSql['password'] ) or
die( 'Could not open connection to server' );
mysql_select_db( $gaSql['db'], $gaSql['link'] ) or
die( 'Could not select database '. $gaSql['db'] );
/*
* Paging
*/
$sLimit = "";
if ( isset( $_GET['iDisplayStart'] ) && $_GET['iDisplayLength'] != '-1' )
{
$sLimit = "LIMIT ".mysql_real_escape_string( $_GET['iDisplayStart'] ).", ".
mysql_real_escape_string( $_GET['iDisplayLength'] );
}
/*
* Ordering
*/
$sOrder = "";
if ( isset( $_GET['iSortCol_0'] ) )
{
$sOrder = "ORDER BY ";
for ( $i=0 ; $i $iFilteredTotal,
"aaData" => array()
);
while ( $aRow = mysql_fetch_array( $rResult ) )
{
$row = array();
for ( $i=0 ; $i[/code]
Table1
------
element_25
Table2
------
element_id
option_id
option
Scenario 1:
Value for element_25 is "1".
Value for element_id is "25".
Value for option_id is "1".
Value for option is "poor".
Scenario 2:
Value for element_25 is "2".
Value for element_id is "25".
Value for option_id is "2".
Value for option is "good".
How could I get option value depending on my field value?
I just want to print for element_25 value from corresponding option field from second table.
My server_processing.php is taken from http://www.datatables.net/forums/discussion/5050/several-tables-added#Item_3
[code]<?php
/* Array of database columns which should be read and sent back to DataTables. Use a space where
* you want to insert a non-database field (for example a counter or static image)
*/
$aColumns = array( 'element_25' );
/* DB tables to use */
$aTables = array( 'Table1', 'Table2' );
/* Indexed column (used for fast and accurate table cardinality) */
$sIndexColumn = "";
/* CONDITIONS */
$sWhere = "";
/* Database connection information */
$gaSql['user'] = "";
$gaSql['password'] = "";
$gaSql['db'] = "";
$gaSql['server'] = "localhost";
$gaSql['link'] = mysql_pconnect( $gaSql['server'], $gaSql['user'], $gaSql['password'] ) or
die( 'Could not open connection to server' );
mysql_select_db( $gaSql['db'], $gaSql['link'] ) or
die( 'Could not select database '. $gaSql['db'] );
/*
* Paging
*/
$sLimit = "";
if ( isset( $_GET['iDisplayStart'] ) && $_GET['iDisplayLength'] != '-1' )
{
$sLimit = "LIMIT ".mysql_real_escape_string( $_GET['iDisplayStart'] ).", ".
mysql_real_escape_string( $_GET['iDisplayLength'] );
}
/*
* Ordering
*/
$sOrder = "";
if ( isset( $_GET['iSortCol_0'] ) )
{
$sOrder = "ORDER BY ";
for ( $i=0 ; $i $iFilteredTotal,
"aaData" => array()
);
while ( $aRow = mysql_fetch_array( $rResult ) )
{
$row = array();
for ( $i=0 ; $i[/code]
This discussion has been closed.