chuck808 Posted December 28, 2011 Share Posted December 28, 2011 Hi, I hope I'm not about to offend anyone by posting this in the wrong place. V 5.1.56 I have a PHP SQL query/function that returns two users details based on a transaction Id from a transaction table and it works fine. However, in the returned result I would also like to show the Transaction Id and for the life of me I can't get it to work. This is the code showing one users details and the returned details below. $sql = "SELECT * from " . TABLEPREFIX . "transactiontxn where nSTId='" . $_REQUEST['nSTId'] . "'"; $res = mysql_query($sql) or die(mysql_error()); if ($srow = mysql_fetch_array($res)){ if ($srow['nUserId']==$_SESSION['guserid']) { $this_user = $srow['nUserId']; $other_user = $srow['nUserReturnId']; } }//end if if ($var_mode == "A" && $var_flag = "true") { $sql = "SELECT vLoginName,vFirstName,vLastName,vAddress1,vAddress2,vCity,vState, vCountry,nZip,vPhone,vFax,vEmail FROM " . TABLEPREFIX . "users U where nUserId='" . $this_user . "' "; $result = mysql_query($sql) or die(mysql_error()); if (mysql_num_rows($result) > 0) { if ($row = mysql_fetch_array($result)) { $var_login2 = stripslashes($row["vLoginName"]); $var_first2 = stripslashes($row["vFirstName"]); $var_last2 = stripslashes($row["vLastName"]); $var_address12 = stripslashes($row["vAddress1"]); $var_address22 = stripslashes($row["vAddress2"]); $var_city2 = stripslashes($row["vCity"]); $var_state2 = stripslashes($row["vState"]); $var_country2 = stripslashes($row["vCountry"]); $var_zip2 = stripslashes($row["nZip"]); $var_phone2 = stripslashes($row["vPhone"]); $var_fax2 = stripslashes($row["vFax"]); $var_email2 = stripslashes($row["vEmail"]); $var_transactionid = stripslashes($row["nTransactionId"]); }//end if }//end if $message = TEXT_DETAILS_OF_COMMUNITATION_GIVEN_BELOW; $var_form = "A"; }//end if else if ($var_mode == "R" && $var_flag = "true") { $message2 = TEXT_OFFER_REJECTED; $var_form = "R"; }//end else if What is returned; Full Name user name Address Line 1 user address Address Line 2 user address City user address State user address Country user address Zip user address Phone user number Fax user fax Email user email Transaction ID The Transaction isn't currently showing Any help would be appreciated Quote Link to comment https://forums.phpfreaks.com/topic/253945-show-an-id-from-2-tables/ Share on other sites More sharing options...
mikosiko Posted December 28, 2011 Share Posted December 28, 2011 The Transaction isn't currently showing $var_transactionid = stripslashes($row["nTransactionId"]); where in your SELECT are you getting the nTransactionId column (assuming that the column exists in your table users)? $sql = "SELECT vLoginName,vFirstName,vLastName,vAddress1,vAddress2,vCity,vState, vCountry,nZip,vPhone,vFax,vEmail FROM " . TABLEPREFIX . "users U where nUserId='" . $this_user . "' "; Quote Link to comment https://forums.phpfreaks.com/topic/253945-show-an-id-from-2-tables/#findComment-1301859 Share on other sites More sharing options...
chuck808 Posted December 28, 2011 Author Share Posted December 28, 2011 Hi mikosiko, Thanks for the reply. I have realised how thick I am, nTransactionId column is from $sql = "SELECT * from " . TABLEPREFIX . "transactiontxn where nSTId='" . $_REQUEST['nSTId'] . "'"; $res = mysql_query($sql) or die(mysql_error()); if ($srow = mysql_fetch_array($res)){ if ($srow['nUserId']==$_SESSION['guserid']) { $this_user = $srow['nUserId']; $other_user = $srow['nUserReturnId']; } }//end if I think I want to be able to show the transaction ID nSTID? Sorry for being so dense Quote Link to comment https://forums.phpfreaks.com/topic/253945-show-an-id-from-2-tables/#findComment-1301909 Share on other sites More sharing options...
mikosiko Posted December 28, 2011 Share Posted December 28, 2011 you are the only one that could know how your transaction id field is called... either way.. assuming (for you to check) that your field name is nSTId you can assign it value to some variable here: $this_user = $srow['nUserId']; $other_user = $srow['nUserReturnId']; $transactionId = $row['nSTId']; and use $transactionId in the rest of your code Quote Link to comment https://forums.phpfreaks.com/topic/253945-show-an-id-from-2-tables/#findComment-1301929 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.