adzie Posted March 29, 2008 Share Posted March 29, 2008 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 More sharing options...
ucffool Posted March 29, 2008 Share Posted March 29, 2008 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? Link to comment https://forums.phpfreaks.com/topic/98478-display-result-from-another-table/#findComment-503966 Share on other sites More sharing options...
adzie Posted March 29, 2008 Author Share Posted March 29, 2008 member_records table ID type memberid change level_change (same for group_change) ID level changename Link to comment https://forums.phpfreaks.com/topic/98478-display-result-from-another-table/#findComment-503989 Share on other sites More sharing options...
ucffool Posted March 29, 2008 Share Posted March 29, 2008 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. Link to comment https://forums.phpfreaks.com/topic/98478-display-result-from-another-table/#findComment-504006 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.