JohnnyKennedy Posted August 15, 2011 Share Posted August 15, 2011 Okay, so I have a friend request system on my website and part of my website requests information from two tables and displays it together. E.G: my 'ACCOUNT' table holds Fn, Ln, Username, and password. And my friend request table (FRIEND) holds data which fit into the columns user1, user2, confirmed. (confirmed being either 1 for YES, 0 for NO or NOT FRIENDS YET). I can successfully return the values of the friend request table - ignoring my username using this line: //my variables $me = $_SESSION['MM_Username']; $zero = "0"; mysql_select_db($database_NewConnection, $NewConnection); $query_rqs = "SELECT *, IF (usera = '$me', userb, usera) AS Other FROM buddies WHERE '$me' IN (usera, userb) AND confirmed='$zero'"; $rqs = mysql_query($query_rqs, $NewConnection) or die(mysql_error()); $row_rqs = mysql_fetch_assoc($rqs); $totalRows_rqs = mysql_num_rows($rqs); --------- Then, to get the full name of the person who sent the request I use a variable $un = $row_rqs['Other']; and then use this variable to run another query on the accounts table. like this: mysql_select_db($database_NewConnection, $NewConnection); $query_getfullname = sprintf("SELECT * FROM accounts WHERE `username`='$un'", GetSQLValueString($colname_getfullname, "text")); $getfullname = mysql_query($query_getfullname, $NewConnection) or die(mysql_error()); $row_getfullname = mysql_fetch_assoc($getfullname); $totalRows_getfullname = mysql_num_rows($getfullname); My problem is this; when I repeat region (in DW) the entire table which holds the results of the first query - I can successfully get the username of the person who sent the request, but when I use that username in the second query - it doesn't repeat -- it simply returns the first result of the query every single time. Any help would be appreciated.. Let me know if you need more code - here is the code I'm using to repeat region the table. <?php do { ?> <table width="440" border="0"> <tr> <td height="22"><img src="user.png" width="20" height="20" /></td> <td height="22" colspan="5"><?php echo $row_getfullname['fn']; ?> <?php echo $row_getfullname['ln']; ?> (<?php echo $row_rqs['Other']; ?>)</td> </tr> <tr style="font-size:11px;"> <td width="22" height="22"><span style="font-size:11px; vertical-align:;"><img src="clock.png" width="19" height="19" /></span></td> <td width="27" valign="middle">Sent:</td> <td width="89" valign="middle"><?php echo $row_rqs['rsendtime']; ?></td> <td width="24" valign="middle"><a><img src="nect.png" width="22" height="22" /></a></td> <td width="63" valign="middle"><a style="text-decoration:none; color:#555; font-size:11px;" href="http://www.google.com/" target="_parent">View Profile</a></td> <td width="202" valign="middle"><span style="font-size:14px;"> <img src="ignore.gif" width="77" height="22" /> <img src="approve.gif" width="78" height="22" /></span></td> </tr> <tr style="font-size:11px;"> <td height="20" colspan="6" align="left">...</td> </tr> </table> <?php } while ($row_rqs = mysql_fetch_assoc($rqs)); ?> Quote Link to comment https://forums.phpfreaks.com/topic/244828-repeating-two-regions-from-mysql/ 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.