All:
I have the following set of queries:
$queryid = "SELECT user_id from users where user_name='$_SESSION[Username]'";
$resultid = mysql_query($queryid);
$userid = mysql_fetch_array($resultid);
$userid = $userid[0];
$querysub = "SELECT subject from mail where user_id='$userid' AND status='Unread' OR status='Read' ORDER BY message_id DESC LIMIT 0, 14";
$resultsub = mysql_query($querysub);
$querydate = "SELECT date from mail where user_id='$userid' AND status='Unread' OR status='Read' ORDER BY message_id DESC LIMIT 0, 14";
$resultdate = mysql_query($querydate);
$querystatus = "SELECT status from mail where user_id='$userid' AND status='Unread' OR status='Read' ORDER BY message_id DESC LIMIT 0, 14";
$resultstatus = mysql_query($querystatus);
$querymailid = "SELECT message_id from mail where user_id='$userid' AND status='Unread' OR status='Read' ORDER BY message_id DESC LIMIT 0, 14";
$resultmailid = mysql_query($querymailid);
$queryfrom = "SELECT sentbyname from mail where user_id='$userid' AND status='Unread' OR status='Read' ORDER BY message_id DESC LIMIT 0, 14";
$resultfrom = mysql_query($queryfrom);
$resultfrom = mysql_query($queryfrom);
$queryfromfriend = "SELECT friend_id from mail where user_id='$userid' AND status='Unread' OR status='Read' ORDER BY message_id DESC LIMIT 0, 14";
$resultfriendid = mysql_query($queryfromfriend);
$friendid = mysql_fetch_array($resultfriendid);
$friendid = $friendid[0];
$querypic = "SELECT users.pic FROM mail, users WHERE users.user_id = mail.friend_id AND mail.friend_id = '$friendid'";
$query = "SELECT * from mail where user_id = '$userid' AND status='Unread' OR status='Read' ORDER BY message_id DESC LIMIT 0, 14";
$result = mysql_query($query) or die("select failed");
To display these I then have the following code:
if (mysql_num_rows($result) > 0) {
for ($j = 0; $j<mysql_num_rows($result); $j++) {
echo "<tr valign=\"top\">";
echo "<td width=62 bgcolor=\"E8F1FA\"><input type=\"checkbox\" name=\"column[]\" value=\"".mysql_result($resultmailid,$j)."\"></td>";
echo "<td width=104 bgcolor=\"E8F1FA\">";
echo "<span class=\"text\">". mysql_result($resultdate,$j) ."</span>";
echo "</td>";
echo "<td width=362 bgcolor=\"E8F1FA\">";
echo "<table width=\"150\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
echo "<tr><td>";
echo "<a href=\"../profile/viewprofile.php?id=" . mysql_result($resultfriendid,$j) . "\">";
echo "<img src=\"http://www.website.com/upload/images/".mysql_result($resultpic, $j). "\" width=\"75\" height=\"75\">";
echo "</a></td>";
echo "<td><span class=\"text\"><a href=\"../profile/viewprofile.php?id=" . mysql_result($resultfriendid,$j) . "\">" . mysql_result($resultfrom,$j) . "</a></span>";
echo "<br><DIV style=\"width:80px;height:20px;\"></div>";
echo "</td></tr>";
echo "</table>";
echo "</td>";
echo "<td width=108 bgcolor=\"E8F1FA\">";
echo "".mysql_result($resultstatus,$j)."";
echo "</td>";
echo "<td width=495 bgcolor=\"E8F1FA\"><a class=\"mailtext\" href=\"readmessage.php?id=" . mysql_result($resultmailid,$j) . "\">" . mysql_result($resultsub,$j) . "</a></td>";
echo "</tr>";
}
}
This code works good if I'm only trying to view one row, when there is more then one row it gives me the error: Warning: mysql_result(): Unable to jump to row 1 on MySQL result index 15 in /home/website/public_html/mail/getmail.php on line 294.
Line 294 is this one:
echo "<img src=\"http://www.webiste.com/upload/images/".mysql_result($resultpic, $j). "\" width=\"75\" height=\"75\">";
Can someone please help me fix this. The first row will display good and then the second row I get that error. Please help!
Thanks