hudsonsnake
New Member
I am new to PHP so please excuse my mess. This is a very complicated query for somebody like me to change. Please see the query below. Right now all results are being displayed in the $row['Post']; Instead I want to be able to do something like:$somerow = $row['some_row'];$somerow2 = $row['some_row2'];and then be able to use it anywhere with the $variables used above. I tried using this below but it didn't work:\[code\]if($rows == 0){print("");}elseif($rows > 0){while($row = mysql_fetch_array($query)){$postid = htmlspecialchars($row['post_id']);$postname = htmlspecialchars($row['post_name']);print("$postname and the id is $postid");}}\[/code\]How can i achieve this?Full Query: \[code\]$denied = "Denied";$userid = Drawn from db for user viewing;$sql = "SELECT concat( (select client_name from user_accounts where User_id = tv.User_id), ' commanded ' , title_1 ,' on ', CAST(other_date AS CHAR(10)) ) AS Post FROM client_visits tv where User_id in (select contact_id from contacts where User_id = '$userid' ) and user_allowed = '$denied'or User_id in (select User_id from contacts where contact_id = '$userid')and user_allowed = '$denied'unionSELECT concat( (select client_name from user_accounts where User_id = tv.User_id), ' commanded ' , title_2 ,' on ', CAST(other_date AS CHAR(10)) )AS Post FROM client_notes tv where User_id in (select contact_id from contacts where User_id = '$userid' ) and user_allowed = '$denied'or User_id in (select User_id from contacts where contact_id = '$userid')and user_allowed = '$denied'unionSELECT concat( (select client_name from user_accounts where User_id = tv.User_id), ' commanded ' , title_3 ,' on ', CAST(other_date AS CHAR(10)) )AS Post FROM client_media tv where User_id in (select contact_id from contacts where User_id = '$userid' ) and user_allowed = '$denied'or User_id in (select User_id from contacts where contact_id = '$userid')and user_allowed = '$denied'unionSELECT concat( (select client_name from user_accounts where User_id = tv.User_id), ' commanded ' , title_4 ,' on ', CAST(other_date AS CHAR(10)) )AS Post FROM client_stats tv where User_id in (select contact_id from contacts where User_id = '$userid' ) and user_allowed = '$denied'or User_id in (select User_id from contacts where contact_id = '$userid')and user_allowed = '$denied'unionSELECT concat( (select client_name from user_accounts where User_id = tv.User_id), ' commanded ' , title_5 ,' on ', CAST(other_date AS CHAR(10)) )AS Post FROM client_current_list tvwhere User_id in (select contact_id from contacts where User_id = '$userid' )and user_allowed = '$denied'or User_id in (select User_id from contacts where contact_id = '$userid')and user_allowed = '$denied'unionSELECT concat( (select client_name from user_accounts where User_id = tv.User_id), ' commanded ' , title_6 ,' on ', CAST(other_date AS CHAR(10)) )AS Post FROM client_past tvwhere User_id in (select contact_id from contacts where User_id = '$userid' )and user_allowed = '$denied'or User_id in (select User_id from contacts where contact_id = '$userid')and user_allowed = '$denied'unionSELECT concat( (select client_name from user_accounts where User_id = tv.User_id), ' commanded ' , title_7 ,' on ', CAST(other_date AS CHAR(10)) )AS Post FROM client_listers tvwhere User_id in (select contact_id from contacts where User_id = '$userid' )and user_allowed = '$denied'or User_id in (select User_id from contacts where contact_id = '$userid')and user_allowed = '$denied'unionSELECT concat( (select client_name from user_accounts where User_id = tv.User_id), ' commanded ' , title_8 ,' on ', CAST(other_date AS CHAR(10)) )AS Post FROM client_events tvwhere User_id in (select contact_id from contacts where User_id = '$userid' )and user_allowed = '$denied'or User_id in (select User_id from contacts where contact_id = '$userid')and user_allowed = '$denied'unionSELECT concat( (select client_name from user_accounts where User_id = tv.User_id), ' commanded ' , title_9 ,' on ', CAST(other_date AS CHAR(10)) )AS Post FROM client_admissions tvwhere User_id in (select contact_id from contacts where User_id = '$userid' )and user_allowed = '$denied'or User_id in (select User_id from contacts where contact_id = '$userid')and user_allowed = '$denied'unionSELECT concat( (select client_name from user_accounts where User_id = tv.User_id), ' commanded ' , title_10 ,' on ', CAST(other_date AS CHAR(10)) )AS Post FROM client_immu tvwhere User_id in (select contact_id from contacts where User_id = '$userid' )and user_allowed = '$denied'or User_id in (select User_id from contacts where contact_id = '$userid')and user_allowed = '$denied'";$query = mysql_query($sql) or die ("Error: ".mysql_error());$result = mysql_query($sql);if ($result == ""){echo "";}echo "";$rows = mysql_num_rows($result);if($rows == 0){print("");}elseif($rows > 0){while($row = mysql_fetch_array($query)){print($row['Post']);}}\[/code\]