woolyg Posted December 15, 2008 Share Posted December 15, 2008 Hi all, Apart from this topic title sounding marvellously intelligent, I'm looking to see if this can be done. Here's what I'm trying to do: Users upload videos to my site. I'm trying to grab a list of their active videos, and list the video details in an email to them, as a kind of update. Code: <?php $user_id = '1'; // Define the user_id //Find out if they have any active adverts $get_users_active_adverts = " SELECT * FROM videos WHERE videos.user_id='$user_id' "; $run_users_active_adverts = mysql_query($get_users_active_adverts); $num_users_active_adverts = mysql_num_rows($run_users_active_adverts); //If they have one or more adverts, send them an email with their stats if($num_users_active_adverts > = '1'){ // IF 71 while($display_users_active_adverts = mysql_fetch_assoc($run_users_active_adverts)){ // IF 73 $video_id = $display_users_active_adverts['video_id']; $video_name = $display_users_active_adverts['video_name']; echo "$video_name<br />"; // ****** } // IF 73 } else { // IF 71 //They have no active adverts - Send them an email prompting for them to use the service. } // IF 71 ?> If I echo'd the results, as above, I'd get a list of video names, as per: echo "$video_name<br />"; ..but what I'd like to do is put all of the iterations of $video_name<br /> into a variable, that I could then place into an HTML email and send to the user. If you can follow my idea, can anyone help? All input appreciated. WoolyG Quote Link to comment https://forums.phpfreaks.com/topic/136981-solved-concatenating-while-iterations-into-a-variable/ Share on other sites More sharing options...
Yesideez Posted December 15, 2008 Share Posted December 15, 2008 Declare an empty variable (to be safe) before the loop $email_body=""; Then inside the loop append the video details onto the variable: $email_body.="Video $video_name\n"; Then at the end you'll have a long list of everything that went through the while() loop. Quote Link to comment https://forums.phpfreaks.com/topic/136981-solved-concatenating-while-iterations-into-a-variable/#findComment-715466 Share on other sites More sharing options...
woolyg Posted December 15, 2008 Author Share Posted December 15, 2008 Yesideez - thanks a million, that answers my question perfectly. Solved! WoolyG Quote Link to comment https://forums.phpfreaks.com/topic/136981-solved-concatenating-while-iterations-into-a-variable/#findComment-715473 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.