Jump to content

display result from another table


adzie

Recommended Posts

Hi folks,

 

I'm still rather new to php so please be gentle :)

 

The script I'm using display changes made to a members accounts.  The information display shows the correct numbers form the members_records table.  i'd like for the informatoin being displayed to be th actual values which are stored in other databases.

 

below ".$change[3]." dictates what type of change has happened, ie 1=level change,  2=group change and ".$change[4]." is the new level

 

if ".$change[3]." = 1 then I'd like for the script to display ".$change[4]." entry as NAME from table level_change

an example ".$change[4]." will display 7 that is the ID in the table level_change

 

if ".$change[3]." = 2 then I'd like for the script to display ".$change[4]." entry as NAME from table group_change

an example ".$change[4]." will display 7 that is the ID in the table group_change

 

hope that makes some sense, and I'd appreciate any thoughts or direction on this.

 

many thanks

 

 

				<tr>";

				$sql = "select * from member_records where member_num='".$_POST[member]."'";
				$result = mysql_query($sql,$conn);
				while($change = mysql_fetch_row($result))
									{

					$msg.="<tr><td><a href=index.php?page=management&managementpage=viewpromotions&member=".$change[1].">Update</a></td><td>".$change[2]."</td><td>".$change[3]."</td><td>".$change[4]."</td><td>".$change[5]."</td></tr>";
				}
				$msg.="</tr>					

				<tr>

Link to comment
https://forums.phpfreaks.com/topic/98478-display-result-from-another-table/
Share on other sites

Just to clarify, in the table you have the user account information and a number that represents a change_id. In another table, there is change_id and its value change_value?

Could we get  a sample of what the tables you are pulling from look like?

Here is a rough idea of what you want to do (and it is most likely not a drop-in):

<?php
switch (change[3]){
  case '1':
    $query = 'SELECT name FROM level_change WHERE id = 7';
    break;
  case '2':
    $query = 'SELECT name FROM group_change WHERE id = 7';
    break;
  default:
    // Display an error
    break;
}
$result = mysql_query($query);
$change[4] = mysql_result($result, 0);
?>

I hope it at least gives you the idea.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.