jakebur01
Members-
Posts
885 -
Joined
-
Last visited
Everything posted by jakebur01
-
I tried using DISTINCT, but that did not do the trick. SELECT DISTINCT UserId1, UserId2 FROM life_approval WHERE (`UserId2`='$q' OR `UserId1`='$q') AND `Approved` = 'Approved'
-
I tried using DISTINCT, but that did not do the trick. SELECT DISTINCT UserId1, UserId2 FROM life_approval WHERE (`UserId2`='$q' OR `UserId1`='$q') AND `Approved` = 'Approved'
-
My table for displaying members has been working ok when querying all members. I have been trying to add an extra loop that will make the table only display members that are friends of a specific member. My problem is that it is grabbing the same member twice. For example if Fred is UserId1 and Tom is UserId2, then row 2 Joe is UserId1 and Fred is UserId2. It will display Fred twice. Also, I cannot get my <tr>'s to work correctly. echo '<table width="100%" border="0">'; $getimages = mysql_query("SELECT UserId1, UserId2 FROM life_approval WHERE (`UserId2`='$q' OR `UserId1`='$q') AND `Approved` = 'Approved'", $db); if(!$getimages) die("Cannot execute query. " . mysql_error()); $countRows = mysql_num_rows($getimages); $i = 0; if ($countRows > 0) { while ($rowimages = mysql_fetch_assoc($getimages)) { $result = mysql_query("SELECT Username, Company, Country, State, Link FROM life_useraccount WHERE (`Username`='$rowimages[userId1]' OR `Username`='$rowimages[userId2]') ", $db) or die(mysql_error()); if ($i % 3 == 0) echo ($i > 0? '</tr>' : '') . '<tr>'; while ($myrow = mysql_fetch_array($result)){ //$id=$myrow["Id"]; echo '<td><center><div class="product"><a href="profile.php?q='.$myrow['Username'].'"><img src="'.$myrow['Link'].'" width="145" border="0" /></a></div><b>'.$myrow["Company"].'</b><br />'.$myrow["State"].'<br />'.$myrow["Country"].'</center></td>'; } if ($i == $countRows - 1) echo '</tr>'; $i++; } } echo '</table>';
-
My table for displaying members has been working ok when querying all members. I have been trying to add an extra loop that will make the table only display members that are friends of a specific member. My problem is that it is grabbing the same member twice. For example if Fred is UserId1 and Tom is UserId2, then row 2 Joe is UserId1 and Fred is UserId2. It will display Fred twice. Also, I cannot get my <tr>'s to work correctly. echo '<table width="100%" border="0">'; $getimages = mysql_query("SELECT UserId1, UserId2 FROM life_approval WHERE (`UserId2`='$q' OR `UserId1`='$q') AND `Approved` = 'Approved'", $db); if(!$getimages) die("Cannot execute query. " . mysql_error()); $countRows = mysql_num_rows($getimages); $i = 0; if ($countRows > 0) { while ($rowimages = mysql_fetch_assoc($getimages)) { $result = mysql_query("SELECT Username, Company, Country, State, Link FROM life_useraccount WHERE (`Username`='$rowimages[userId1]' OR `Username`='$rowimages[userId2]') ", $db) or die(mysql_error()); if ($i % 3 == 0) echo ($i > 0? '</tr>' : '') . '<tr>'; while ($myrow = mysql_fetch_array($result)){ //$id=$myrow["Id"]; echo '<td><center><div class="product"><a href="profile.php?q='.$myrow['Username'].'"><img src="'.$myrow['Link'].'" width="145" border="0" /></a></div><b>'.$myrow["Company"].'</b><br />'.$myrow["State"].'<br />'.$myrow["Country"].'</center></td>'; } if ($i == $countRows - 1) echo '</tr>'; $i++; } } echo '</table>';
-
It worked with this: $sql = mysql_query("SELECT UserId1, UserId2 FROM life_approval WHERE (`UserId1` = '{$_SESSION['valid_user']}' AND `UserId2`='$q' OR `UserId2` = '{$_SESSION['valid_user']}' AND `UserId1`='$q') AND `Approved` = 'Approved'"); That is incredible. Now, I can really get some stuff done. Thank you all so much, I have been wanting to figure this out.
-
Should it be similar to this? $sql = mysql_query("SELECT userId1, userId2 FROM life_approval WHERE (`userId1` = '{$_SESSION['valid_user']}' AND `UserId2`='$user_profile' OR `userId2` = '{$_SESSION['valid_user']}')AND `UserId1`='$user_profile' AND `approve` = 'Approved'");
-
So, will this check both ways? $sql = mysql_query("SELECT userId1, userId2 FROM life_approval WHERE (`userId1` = '{$_SESSION['valid_user']}' OR `userId2` = '{$_SESSION['valid_user']}') AND `approve` = 'Approved'"); I should have posted this in mysql. I will take care to do that next time.
-
Sorry... I am trying to check and see if $_SESSION[valid_user] and $user_profile are friends correction: WHERE `UserId2`='$_SESSION[valid_user]' AND `UserId1`='$user_profile' AND `Approve` = 'Approved' and WHERE `UserId1`='$_SESSION[valid_user]' AND `UserId2`='$user_profile' AND `Approve` = 'Approved'
-
Could someone please show me a better way to do this so I will not have to make 2 queries out of it? <?PHP $sql = mysql_query("SELECT UserId1 FROM life_approval WHERE `UserId2`='$_SESSION[valid_user]' AND `Approve` = 'Approved'"); $num = mysql_num_rows($sql); if ($num > 0) { // we are good, this user is a friend } elseif { $sql = mysql_query("SELECT UserId2 FROM life_approval WHERE `UserId1`='$_SESSION[valid_user]' AND `Approve` = 'Approved'"); $num = mysql_num_rows($sql); if ($num > 0) { // we are good, this user is a friend } } else { //do nothing, this is not a friend } ?>
-
bump....
-
How should I query this table to select the friends of a member? Could I make it happen all in one query? members (Id, UserId1, UserId2, Approved)
-
bump...
-
Using the first table, how should I query to select all the friends of a particular member? Would I have to run 2 separate queries? Like: select UserId2 from friend_table where Approved = invite_accepted and UserId1 = $Username while { select * from user_table where Username=$myrow[username] } then, select UserId1 from friend_table where Approved = invite_accepted and UserId2 = $Username while { select * from user_table where Username=$myrow[username] }
-
I keep complicating things when trying to figure out how I should send messages and invites between members. The way I was trying to do my invites was to have a table (Id, UserId1, UserId2, Approved). I would mark the Approved as 1 when the invite was first sent. Then mark it as 3 if the invite was accepted and 2 if declined. This is basically how I was trying to setup my friends table. It didn't work very well when people was submit multiple invites to each other. Also, my messages table was setup like (Id, Userd1, UserId2, Subject, Message).
-
Thank you. Keith
-
Hi Keith, Would you just check to see how many blank rows are needed to make 4? And then insert like 4 <td> </td>'s ?
-
I am trying to create a "browse members" page. This page will display thumbnails in a table about 4 columns wide. I am not sure what the best way to set up the table would be. I am not sure how to count and loop through 4 <td>'s and then insert the <tr> tag. How would you do this? Like: <table width=100%> select username, nickname, image_link FROM user_table while { } </table>
-
Ha Ha.... my head way starting to get foggy and his footer looked as though it were part of the post. Sorry.... Thank you for all your help. It is working great now.
-
Does ini_set ("display_errors", "1"); error_reporting(E_ALL); log errors when someone is trying to inject stuff into url? How will you know when they are trying to do that? Isn't that what that is for? I read a little bit on ini_set ("display_errors", "1"); error_reporting(E_ALL); but I was having trouble understanding exactly how it works. - Jake
-
Where would these errors be reported to? Would they go to my web host? Is there a way to have them e-mailed to me?
-
it is all under if (isset($_SESSION['valid_user'])) { }
-
my image names have underscores and periods in it. I read: Returns a string in which all non-alphanumeric characters except -_. I want to do this the best way. I didn't know if urlencode would be the best option.
-
to delete an image, could i do something like this? echo"<a href=\"view_images.php?delete=urlencode($file)\">delete image</a> then if (isset($_GET['delete'])) { $delete_image=c:/images/urldecode($_GET['delete']); unlink("delete_image"); }
-
Ha.. That got it. Thank you so much!
-
That displayed only 3 images. It is missing 13330MarThu2009.jpg, 100_0383.JPG, 100_0388.JPG. The three it displayed were 100_0381.JPG, 100_0384.JPG, 100_0389.JPG. $file = readdir($dir_handle); $image_types = array("jpg","jpeg","gif","png"); while (false !== ($file = readdir($dir_handle))) { if(in_array(strtolower(substr($file,strpos($file,".")+1)),$image_types)){ $html .= "<tr><td><center><IMG SRC='/gallery/$_SESSION[valid_user]/uploads/{$file}' width='100' align='top' vspace='2' alt='{$file}' /></center></td><td>{$file}</td></tr>"; $file = readdir($dir_handle); } } closedir($dir_handle);