Jump to content

bytesize

Members
  • Posts

    56
  • Joined

  • Last visited

Everything posted by bytesize

  1. If jquery 1.3 is used with this code a single click works, which is what I want, but if jquery 1.4 or higher is used a double click is required. Can anyone tell me what is causing the double click? <head> <style type="text/css"> .interactionLinksDiv a { font-size: 12px; font-family: Geneva, sans-serif; font-weight: normal; } .interactionLinksDiv a:hover { font-size:12px; text-decoration: underline; } .interactContainers { display:none; margin-top: 4px; } </style> <script type="text/javascript"> function toggleInteractContainers(x) { if ($('#'+x).is(":hidden")) { $('#'+x).slideDown(200); } else { $('#'+x).hide(); } $('.interactContainers').hide(); } </script> </head> <body> <?php $interactionBox = '<div class="interactionLinksDiv"> <a href="#" onclick="return false" onmousedown="toggleInteractContainers(\'add_friend\');">Add <b>Joey</b> to Friends</a> </div>'; echo $interactionBox; ?> <div class="interactContainers" id="add_friend"> Friend <b>Joey</b>? <a href="#" onclick="return false" onmousedown="toggleInteractContainers('add_friend');" title="Close">Later</a> </div> </body> </html>
  2. I can't figure out how to make - textarea[name=send[mc_comment]] - work. When I add text to send[mc_comment] it only works on the first post comment and the other post comments are empty! Can anyone help me with this? a, b, c, d, e work as they should. $curpost = postid in the database. <script type="text/javascript"> var commentUrl = "views/layouts/comments.php"; function mainComment(a,b,c,d,e,f) { var f = $("textarea[name=send[mc_comment]]").val(); var page = (d); $("#"+page).text("Please wait...").show(); $.post(commentUrl,{user:a, friend:b, postid:c, where:d, which:e, send:f},function(data){$("#"+page).html(data).show().fadeOut(1000)}) } </script> <form action="" method='POST'> <textarea name='send[mc_comment]'></textarea> <a href='#' onclick="return false" onmousedown="javascript:mainComment('<?php echo $usercode; ?>', '<?php echo $othermember; ?>', '<?php echo $curpost; ?>', '<?php echo 'add'.$curpost; ?>', '<?php echo $comment; ?>');">Yes</a> </form>
  3. Jessica, thank you for your help, you pointed me in the right direction. It took a little bit of work on the php side, but I got it to work!
  4. Yes, the page is being redirected in the controller. Thanks for your help. I will continue working on this until I figure it out.
  5. <script type="text/javascript"> function toggleInteractContainers(x) { if ($('#'+x).is(":hidden")) { $('#'+x).slideDown(200); } else { $('#'+x).hide(); } $('.interactContainers').hide(); } </script> <?php $interactionBox = '<div class="interactionLinksDiv"> <a href="#" onclick="return false" onmousedown="javascript:toggleInteractContainers(\''.$show['wb_memberid'].'\');">Send Request</a> </div>'; echo $interactionBox; ?> <div class="interactContainers" id="<?php echo $show['wb_memberid']; ?>"> <a href="users/add?add=<?php echo $show['code']; ?>">Yes</a> <a href="#" onclick="return false" onmousedown="javascript:toggleInteractContainers('<?php echo $show['wb_memberid']; ?>');" title="Close">No</a> </div> When scrolled down to the "Yes" link and it is clicked, the page jumps up to the top of the browser. If "No" is clicked, the page does not move, which is the effect I'm looking for. How can I stop the page from jumping to the top? I have tried using "#", onclick, and onmousedown within the "Yes" href to no avail. Anyone?
  6. $user = current_user('code'); $query = sprintf("SELECT * FROM responds JOIN questions ON questions.q_id=responds.question_id JOIN users ON questions.q_questionby=users.code WHERE responds.re_respondby='%s' AND questions.q_questionby=users.code ORDER BY questions.question", mysql_real_escape_string($user)); $result = mysql_query($query); $exists = mysql_num_rows($result); while($row = mysql_fetch_array($result)) { if($user!=$row['code']) { echo $row["question"]; } } Thank you for responding to my question. This is the display output. The numbers represent the question id. 6 Proin id lorem nunc, eget scelerisque lectus. Nulla quis nisi accumsan leo rhoncus elementum.… 6 Proin id lorem nunc, eget scelerisque lectus. Nulla quis nisi accumsan leo rhoncus elementum.… 16 Eget diam mi. Nam sed lectus vel metus elementum varius. Curabitur tincidunt faucibus neque… 3 Diam libero iaculis a gravida ac elementum ac dolor. In hac habitasse platea dictumst. Nulla tem… 3 Diam libero iaculis a gravida ac elementum ac dolor. In hac habitasse platea dictumst. Nulla tem… 20 Cras aliquam odio a metus varius eget dictum ipsum accumsan. Maecenas justo dui, aliquam… 20 Cras aliquam odio a metus varius eget dictum ipsum accumsan. Maecenas justo dui, aliquam… As you can see, the question is being display more than once for questions with more than one answer. The $user variable is showing all my answers in responds.re_respondby='%s' How can I show only one question?
  7. <?php $user = current_user('code'); $query = sprintf("SELECT * FROM responds JOIN questions ON questions.q_id=responds.question_id JOIN users ON questions.q_questionby=users.code WHERE responds.re_respondby='%s' AND questions.q_questionby=users.code ORDER BY responds.re_id", mysql_real_escape_string($user)); $result = mysql_query($query); $exists = mysql_num_rows($result); ?> If I have more than one answer per question, the same question will display multiple times depending on how many answers there are for that question. Example question: How can I do this if I'm doing that? Let's say there are 10 answers to that question. 3 of those answers are mine. That question will display 3 times instead of once. Can this be done in the query?
  8. The users table seems to be the missing link.
  9. sasa, That did it, it works great. @ silkfire, I recreated your table and query and it worked for me, but would not work with the other code. Thank you both very much, I really appreciate your help.
  10. This is my php. <?php $username = 'Joe'; $query = "SELECT f_userid, friendwith FROM friends WHERE f_userid <> '$username' AND f_userid NOT IN (SELECT friendwith FROM friends WHERE friendwith <> '$username')"; $result = mysql_query($query); while($row = mysql_fetch_array($result)) { echo $row['f_userid']."<br/>"; echo $row['friendwith']."<br/>"; } ?> This is what I get when I echo the $query. SELECT f_userid, friendwith FROM friends WHERE f_userid <> 'Joe' AND f_userid NOT IN (SELECT friendwith FROM friends WHERE friendwith <> 'Joe') Nothing echos out for $row['f_userid'] or $row['friendwith']. If I change the query to: SELECT f_userid, friendwith FROM friends WHERE f_userid = 'Joe' AND f_userid NOT IN (SELECT friendwith FROM friends WHERE friendwith <> 'Joe') $row['f_userid'] and $row['friendwith'] echo out content form table friends using the query with =.
  11. You can use this table example. I'm trying to isolate Fred and Tom because Joe has not made friends with them. f_userid Fred Tom Henry Bill Joe Joe friendwith Joe Joe Joe Joe Henry Bill
  12. Table friends f_userid Fred Tom Henry Bill Julie Wally Joe Joe friendwith Joe Joe Joe Joe Joe Joe Julie Wally This what your table should look like. Joe is in both columns because Joe friended Julie and Wally but not the others. I get the same query you get when it echos out on my page. This is why I'm having trouble with the query.
  13. I copied your query and nothing happens because f_userid and friendwith both contain Joe. Doesn't <> represent not equal to? SELECT f_userid, friendwith FROM friends WHERE f_userid <> 'Joe' AND f_userid NOT IN (SELECT friendwith FROM friends WHERE friendwith <> 'Joe') When I echo the query, I get the query with Joe.
  14. f_userid and friendwith columns are both equal to Joe in different rows depending on who is friends with who.
  15. Yes, I only need table friends, but table users is needed to display the images of those that are not friends with f_userid. I can add table users after solving friends table. Still not working. SELECT f_userid, friendwith FROM friends WHERE f_userid <> 'Joe' AND f_userid NOT IN (SELECT friendwith FROM friends WHERE friendwith <> 'Joe')
  16. users is a table and code is a column in users. SELECT users, friendwith FROM friends WHERE users <> 'Joe' AND users NOT IN (SELECT friendwith FROM friends WHERE friendwith <> 'Joe') I tried this but it doesn't work. SELECT code, friendwith FROM friends, users WHERE code <> 'Joe' AND code NOT IN (SELECT friendwith FROM friends WHERE friendwith <> 'Joe')
  17. Table users code Fred Julie Bill Wally Joe Table friends f_userid Fred Julie Bill Wally Joe Joe friendwith Joe Joe Joe Joe Julie Wally Joe is friends with Julie and Wally. <?php $username = 'Joe'; $myfriends = "SELECT * FROM users JOIN friends ON users.code = friends.friendwith WHERE friends.f_userid ='$username'"; $myfriendsresult = mysql_query($myfriends); while($myfriendsrow = mysql_fetch_array($myfriendsresult)) { echo $myfriendsrow['f_userid']."<br/>"; echo $myfriendsrow['friendwith']."<br/>"; } ?> Fred, Julie, Bill, and Wally have friended Joe. <?php $username = 'Joe'; $query = "SELECT * FROM users JOIN friends ON users.code = friends.f_userid WHERE friends.friendwith='$username'"; $result = mysql_query($query); while($row = mysql_fetch_array($result)) { echo $row['f_userid']."<br/>"; echo $row['friendwith']."<br/>"; } ?> Julie and Wally should not be included in the query because Joe has friended them as well. I want to know who friended Joe except for those that Joe has friended. In other words, I want to show Fred and Bill. Julie and Wally should not be included in the query because Joe has friended them as well. ============================================ I've included my attempt at creating a subcategory. This subcategory shows Fred and Bill plus Joe the User because Joe is friends with Julie and Wally. I need to show only Fred and Bill. <?php $query = "SELECT DISTINCT * FROM users JOIN friends ON users.code = friends.f_userid WHERE NOT EXISTS (SELECT * FROM friends WHERE users.code = friends.friendwith AND friends.f_userid='$username')"; $result = mysql_query($query); while($row = mysql_fetch_array($result)) { echo $row['f_userid']."<br/>"; echo $row['friendwith']."<br/>"; } ?> Pointing me in the right direction will be greatly appreciated.
  18. I will try your method of sub query and post back later. Thanks for your reply.
  19. Table friends users Fred Tom Julie Henry Bill Wally Joe Joe friendwith Joe Joe Joe Joe Joe Joe Julie Wally Fred, Tom, Julie, Henry, Bill, and Wally have friended Joe. <?php $username = 'Joe'; $query = "SELECT * FROM friends WHERE friendwith=' $username'"; $result = mysql_query($query); while($row = mysql_fetch_array($result)) { echo $row['users']."<br/>"; echo $row['friendwith']."<br/>"; } ?> Joe is friends with Julie and Wally. <?php $username = 'Joe'; $query = "SELECT * FROM friends WHERE users='$username'"; $result = mysql_query($query); while($row = mysql_fetch_array($result)) { echo $row['users']."<br/>"; echo $row['friendwith']."<br/>"; } ?> Here's where I need your expert advice! I want to know who friended Joe except for those that Joe has friended. In other words, I want to show Fred, Tom, Henry, and Bill. Julie and Wally should not be included in the query because Joe has friended them as well.
  20. Can someone please tell my why the 'more' link continues to load after reaching the last message in the database. It should stop and display 'The End' loadmore.php <?php include('db_connect.php'); ?> <script type="text/javascript" src="jquery-1.4.4.js"></script> <script type="text/javascript"> $(document).ready(function() { $('.more').live("click",function() { var ID = $(this).attr("id"); if(ID) { $("#more"+ID).html('<img src="moreajax.gif" />'); $.ajax({ type: "POST", url: "ajax_more.php", data: "lastmsg="+ID, cache: false, success: function(html){ $("ol#updates").append(html); $("#more"+ID).remove(); } }); } else { $(".morebox").html('The End'); } return false; }); }); </script> </head> <body> <ol class="timeline" id="updates"> <?php $sql=mysql_query("SELECT * FROM messages ORDER BY msg_id DESC LIMIT 8"); while($row=mysql_fetch_array($sql)) { $msg_id=$row['msg_id']; $message=$row['message']; ?> <li> <?php echo $message; ?> </li> <?php } ?> </ol> <div id="more<?php echo $msg_id; ?>" class="morebox"> <a href="#" class="more" id="<?php echo $msg_id; ?>">more</a> </div> </body> </html> ajax_more.php <?php include("db_connect.php"); if(isset($_POST['lastmsg'])) { $lastmsg=$_POST['lastmsg']; $result=mysql_query("SELECT * FROM messages WHERE msg_id<'$lastmsg' ORDER BY msg_id DESC LIMIT 8"); $count=mysql_num_rows($result); while($row=mysql_fetch_array($result)) { $msg_id=$row['msg_id']; $message=$row['message']; ?> <li> <?php echo $message; ?> </li> <?php } ?> <div id="more<?php echo $msg_id; ?>" class="morebox"> <a href="#" id="<?php echo $msg_id; ?>" class="more">more</a> </div> <?php } ?>
  21. Thank you dragon_sa, it works. I really appreciate your help. Thanks again!
  22. I need to set the width and let height adjust to the proportions of width. Can someone please help me with this? I understand that $canvas_height should be 160, but then the image will crop to whichever side is greatest not by the width only. <?php $img = "image.jpg"; $canvas_width = 160; $canvas_height = 0; list($img_width, $img_height) = getimagesize($img); $ratio_orig = $img_width / $img_height; if($canvas_width / $canvas_height > $ratio_orig) { $canvas_width = $canvas_height * $ratio_orig; } else { $canvas_height = $canvas_width / $ratio_orig; } $original = imagecreatefromjpeg($img); $canvas = imagecreatetruecolor($canvas_width, $canvas_height); imagecopyresampled($canvas, $original, 0, 0, 0, 0, $canvas_width, $canvas_height, $img_width, $img_height); $dest = "medium/image.jpg"; imagejpeg($canvas, $dest, 100); ?>
  23. $_GET["find"] displays all users including the current user. The current user should not be displayed. I would like to display members that are NOT friends with the current user. Do I need to join the tables to make this work? $_GET["add"] inserts "screen_name" into "member and friendwith" <?php if(isset($_GET["find"])) { $username = $_POST["screen_name"]; $query = "SELECT * FROM users WHERE screen_name LIKE '%$username%'"; $result = mysql_query($query); $exist = mysql_num_rows($result); if($exist=='0') { echo "No match found"; } else { echo "Matches for search: $username<br>"; while($currow = mysql_fetch_array($result)) { ?> <a href="users/member?addfriend=<?php echo $currow['screen_name']; ?>"><img src="avatars/<?php echo $currow["image"]; ?>" ></a> <?php } } } if(isset($_GET["add"])) { $username = $_SESSION["screen_name"]; $friend = $_GET["add"]; $query = "SELECT * FROM friends WHERE member='$username' AND friendwith='$friend'"; $result = mysql_query($query); $exist = mysql_num_rows($result); if($exist=='0') { $query = "INSERT INTO friends(member,friendwith) VALUES('$username','$friend')"; mysql_query($query); echo "$friend is now your friend!"; } else { echo "$friend is already your friend!"; } } ?>
  24. I will try joining the tables and see what happens. Thank you for the input.
  25. Can someone please help me figure out how to insert "image" from table users, that contains the .jpg data associated with "screen_name", into table friends "friendimg" Here are the tables: friends: id, member, friendwith, friendimg users: id, screen_name, image $_GET["id"] only contains "screen_name" and"image" is not included add.php <?php if(isset($_GET["id"])) { echo "<br/><a href=\"member?add=".$_GET["id"]."\">Add ".$_GET["id"]." to your list of friends</a>"; } ?> member.php <?php if(isset($_GET["add"])) { $username = $_SESSION["screen_name"]; $friend = $_GET["add"]; $query = "SELECT * FROM friends WHERE member='$username' AND friendwith='$friend'"; $result = mysql_query($query); $exist = mysql_num_rows($result); if($exist=='0') { $query = "INSERT INTO friends(member,friendwith) VALUES('$username','$friend')"; mysql_query($query); echo "<br/>You are now friends with $friend"; } else { echo "<br/>$friend is already in your list of friends!"; } } ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.