Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to return a combine result of 2 queries from a PHP function?
    primarykey
    data
    text
    <p>I have a PHP function <code>view_activated_profile();</code>. I want it to return a result for two different queries. I don't know if it's possible or not, but there must be some way to achieve full result on another page.</p> <p>I have two pages, functions.php and profile.php. In functions.php, I have defined the functions:</p> <pre><code>$activated = check_activated(); while($row = mysql_fetch_array($activated)) { $userid = $row['admin_id']; } $query = "SELECT * from cv_user_profile WHERE admin_id=$userid"; $result = mysql_query($query); $array1 = mysql_fetch_array($result); $query2 = "SELECT * from cv_adminlogin WHERE admin_id=$userid"; $result2 = mysql_query($query2); $array2 = mysql_fetch_array($result2); $overall = $array1.$array2; return $overall; </code></pre> <p>Then I called the function in profile.php like this:</p> <pre><code>$user_profile = view_activated_profile(); while($row = mysql_fetch_array($user_profile)) { $showfullname = $row['full_name']; $showjob_title = $row['job_title']; $showemail = $row['email_address']; $showdob = $row['dob']; $showmobile = $row['mobile']; $showphone = $row['phone']; $shownationality = $row['nationality']; $showprofilepic = $row['profile_image']; $showaddress = $row['address']; $showaboutme = $row['about_me']; $showlastupdated = $row['last_updated']; } </code></pre> <p>I get this error on profile.php page:</p> <blockquote> <p>Warning: mysql_fetch_array() expects parameter 1 to be resource, string given in C:\xampp\htdocs\aptanaProjects\pakistanihaider\admin\profile.php on line 30</p> </blockquote> <p>Below are my database tables that i have used in queries: <img src="https://i.stack.imgur.com/66SBb.png" alt="cv_adminlogin"> <img src="https://i.stack.imgur.com/WhNNc.png" alt="cv_user_profile"></p> <p>What i am doing wrong? How to get result of both queries successfully on profile.php?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload