I'm following a tutorial online but I think it's slightly outdated or they're using a different program so I just need help converting the below SQL code into a version PHP can understand.
$req1 = mysql_query('select m1.id, m1.title, m1.timestamp, count(m2.id) as reps, st_accounts.id as st_accountsid, st_accounts.username from pm as m1, pm as m2,st_accounts where ((m1.user1="'.$_SESSION['st_accountsid'].'" and m1.user1read="no" and st_accounts.id=m1.user2) or (m1.user2="'.$_SESSION['userid'].'" and m1.user2read="no" and st_accounts.id=m1.user1)) and m1.id2="1" and m2.id=m1.id group by m1.id order by m1.id desc');
$req2 = mysql_query('select m1.id, m1.title, m1.timestamp, count(m2.id) as reps, st_accounts.id as userid, st_accounts.username from pm as m1, pm as m2,users where ((m1.user1="'.$_SESSION['userid'].'" and m1.user1read="yes" and st_accounts.id=m1.user2) or (m1.user2="'.$_SESSION['userid'].'" and m1.user2read="yes" and st_accounts.id=m1.user1)) and m1.id2="1" and m2.id=m1.id group by m1.id order by m1.id desc');