How can I add dynamic text from a different table where primary key is a foreign key to adynamic table being shown?
Posted
by
Jethro Tamares Doble
on Stack Overflow
See other posts from Stack Overflow
or by Jethro Tamares Doble
Published on 2012-09-25T00:46:35Z
Indexed on
2012/09/25
3:37 UTC
Read the original article
Hit count: 123
I have here a dynamic table named tb_user with column region_id and institute_id and both ids are primary key of another table tb_region (with column region_name and region_id) and tb_institute (column institute_id and institute_name). I wanted to see region_name and institute_name instead of the ids.
I've used this php script
<?php echo $row_institute['institution_name']; ?>
and query to collect data for tb_institute
mysql_select_db($database_connection_ched, $connection_ched);
$query_institution = "SELECT institute_id, institute_name FROM tb_institute";
$institution = mysql_query($query_institution, $connection_ched) or die(mysql_error());
$row_institution = mysql_fetch_assoc($institution);
$totalRows_institution = mysql_num_rows($institution);
but it seems not to display the correct name of id.
query i used to collect data:
mysql_select_db($database_connection_ched, $connection_ched);
$query_notification = sprintf("SELECT * FROM tb_user WHERE status = 'inactive' ORDER BY date_register ASC", GetSQLValueString($colname_notification, "text"));
$query_limit_notification = sprintf("%s LIMIT %d, %d", $query_notification, $startRow_notification, $maxRows_notification);
$notification = mysql_query($query_limit_notification, $connection_ched) or die(mysql_error());
$row_notification = mysql_fetch_assoc($notification);
if (isset($_GET['totalRows_notification'])) {
$totalRows_notification = $_GET['totalRows_notification'];
} else {
$all_notification = mysql_query($query_notification);
$totalRows_notification = mysql_num_rows($all_notification);
}
$totalPages_notification = ceil($totalRows_notification/$maxRows_notification)-1;
© Stack Overflow or respective owner