janniesekind Posted April 27, 2011 Share Posted April 27, 2011 hey everyone will you please assist. I'm getting data from a mysql database. And I want to assign the data to a single value, if possible For example, in my database I have 2 columns, name and group Lets say John, Peter and Cathy belongs to group 555, where Sally and Marcus belongs to group 777. So my sql query outputs all users in group 555 Is there a way to assign the search result to a vlue, for example $result = ??? and If I said echo $result, it should show the users who belongs to group 555 as an example. I tried to use row[Name][1]; but it doesnt work. The thing is, I can display the data the way I am familiar with, but I'm sending an automated email to myself, containing the users. So if I would used a for each statement, the mail will trigger and send a copy for every count, in this case, 3 times. And thats my huge problem. The mail must trigger only once, containing the users in my search query, in this case, group 555. Any help will be appreciated Thank you Quote Link to comment https://forums.phpfreaks.com/topic/234843-need-help-to-assign-an-array-to-a-single-value/ Share on other sites More sharing options...
janniesekind Posted April 27, 2011 Author Share Posted April 27, 2011 I think the main issue is getting that data to a single variable. For example, $result = ??? array ??? echo $result; // Users who belong to group 555 as an example Quote Link to comment https://forums.phpfreaks.com/topic/234843-need-help-to-assign-an-array-to-a-single-value/#findComment-1206827 Share on other sites More sharing options...
Muddy_Funster Posted April 27, 2011 Share Posted April 27, 2011 You can use the loop, you just need to put it in the right place - have the html content generated through the loop before the mail is sent, that way you won't mail for every result - or look at using vardump() or print_r() instead of echo Quote Link to comment https://forums.phpfreaks.com/topic/234843-need-help-to-assign-an-array-to-a-single-value/#findComment-1206832 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.