bruckerrlb Posted October 20, 2009 Share Posted October 20, 2009 Hello, I'm trying to pull data from my mysql query, which I know how to do, but I'm finding it a hard to specifify which data I'd like to show, to give you an example, my query and display results are below $query_customfield = mysql_query("SELECT * FROM `swusers` LEFT JOIN `swcustomfieldvalues` ON swusers.userid = swcustomfieldvalues.typeid") or die(mysql_error()); while($info = mysql_fetch_array($query_customfield)) { $aonumber = $info['customfieldid']; $aoname = $info['fullname']; $fieldvalue = $info['fieldvalue']; Print "<table><tr>"; Print "</td><b>Name:</b> ".$aoname . "</td>"; Print "<td><b>Number:</b> ".$aonumber . "</td> "; Print "<td><b>Number:</b> ".$fieldvalue . "</td> "; Print "</tr></table><br><br><br>"; } The main question here is how can I make the following a variable using 51 as the sample value of customfieldid $_POST['customfieldid'] == '51' Link to comment https://forums.phpfreaks.com/topic/178358-taking-multiple-results-from-a-mysql-query-and-storing-them-in-php-variables/ Share on other sites More sharing options...
bruckerrlb Posted October 20, 2009 Author Share Posted October 20, 2009 Just to clarify, I'm trying to figure out how I can make the following a variable $_POST['customfieldid'] = '51' is that even possible? Link to comment https://forums.phpfreaks.com/topic/178358-taking-multiple-results-from-a-mysql-query-and-storing-them-in-php-variables/#findComment-940645 Share on other sites More sharing options...
bruckerrlb Posted October 21, 2009 Author Share Posted October 21, 2009 A little update on what I'm trying to do here, can someone show me how to do it, I'm trying to take the following sql query and get the individual results from the table joins to display in a while table $query_customfield = mysql_query("SELECT userid, fullname, phase.fieldvalue, aonumber.fieldvalue, das.fieldvalue, address.fieldvalue, city.fieldvalue, state.fieldvalue, zip.fieldvalue, phone.fieldvalue, custom.fieldvalue FROM `swusers` LEFT JOIN `swcustomfieldvalues` as phase ON swusers.userid = phase.typeid LEFT JOIN `swcustomfieldvalues` as aonumber ON swusers.userid = aonumber.typeid LEFT JOIN `swcustomfieldvalues` as das ON swusers.userid = das.typeid LEFT JOIN `swcustomfieldvalues` as address ON swusers.userid = address.typeid LEFT JOIN `swcustomfieldvalues` as city ON swusers.userid = city.typeid LEFT JOIN `swcustomfieldvalues` as state ON swusers.userid = state.typeid LEFT JOIN `swcustomfieldvalues` as zip ON swusers.userid = zip.typeid LEFT JOIN `swcustomfieldvalues` as phone ON swusers.userid = phone.typeid LEFT JOIN `swcustomfieldvalues` as custom ON swusers.userid = custom.typeid WHERE aonumber.customfieldid='51' AND das.customfieldid='52' AND address.customfieldid='22' AND city.customfieldid='5' AND state.customfieldid='6' AND zip.customfieldid='30' AND phone.customfieldid='7' AND custom.customfieldid='34' LIMIT 10 ") or die(mysql_error()); What I'd like to get is the fields such as aonumber.customfieldid, das.customfieldid, address.customfieldid and so on for each user. The while statement I have now returns a particular user, but returns the user for all the different custom fields while($info = mysql_fetch_array($query_customfield)) { $aonumber = $info['userid']; $aoname = $info['fullname']; $fieldvalue = $info['fieldvalue']; Print "<table><tr>"; Print "</td><b>Company:</b> ".$aoname . "</td>"; Print "<td><b>variable ao number:</b> ".$aonumber . "</td> "; Print "<td><b>field value:</b> ".$fieldvalue . "</td> "; Print "</tr></table><br><br><br>"; } An example of the output would be Company: Mikes variable ao number: 27 field value: nextel Company: Mikes variable ao number: 27 field value: 00411497 Company: Mikes variable ao number: 27 field value: What I'm trying to do is something like this Company: Mikes variable ao number: 27 fieldone: nextel fieldtwo: value2 fieldthree: value3 field4: value4 field5: value5 Company: company2 variable ao number: 55 fieldone: verizon fieldtwo: value2 fieldthree: value3 field4: value4 field5: value5 Link to comment https://forums.phpfreaks.com/topic/178358-taking-multiple-results-from-a-mysql-query-and-storing-them-in-php-variables/#findComment-941110 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.