Jump to content

ebolt007

Members
  • Posts

    119
  • Joined

  • Last visited

Everything posted by ebolt007

  1. Awesome thanks! And yes I know it's not always ideal and never should be used for beginers to keep an array inside a column but in a very complex program sometimes it's a necassary evil to do for organization.
  2. Naw, I have a ton of other tables for things like that, there has to be a way to pull an array out this way. Anyone with any ideas? I know how to easily pull it by grabbing it, exploding it by the , and using a foreach. I also put them in other tables with these id's, but for commenting and other purposes to keep them together I have to do it this way for this table. It's as easy as this to grab them, but what about searching right inside the query? $uploads= $true_row['photos']; $s = explode(",", $uploads); foreach($s as $a) { echo "$s"; }
  3. I have a query where I need to select an ID from a row where a column has an array. for instance I have ID Name photos 1 My Name 300,302,303, 2 2nd Name 304,405,309, How would I grab the ID where the "photos" contains 405,? But it can't select where it contains 1405 or 4054, or anything like that so I can't use LIKE %405% to select this. $sql = "SELECT ID FROM user_images WHERE photos LIKE '%405%'"; $sql_query = mysql_query($sql); $true_row = mysql_fetch_assoc($sql_query);
  4. Ok, so I have a nother JOIN question, still trying to grasp it and the parenthases, the explanations I always get are so short. So here's my question, I have 2 databases again, Users_Friends and Users_Online inside these I need to match up the ID's in UserID and FriendID inside Users_Friends and get the other ID from those, then I need to Check to make sure the Level in that is '1' and not '0' and then Check in the Users_Online that OnlineStatus for these UID's matching with the ID's I pulled from the Users_Friends is '1' and not '0' Below is what I have, and I can get all of the friends ID's correct, but can't get it to give me the OnlineStatus, I always get my OnlineStatus for each friend so it's like everyones always online. How do I get the OnlineStatus from the ID's that aren't mine from Users_Friends? SELECT f.FriendID, f.UserID, f.FriendIDMAIN, f.DateRequested, o.OnlineStatus FROM Users_Friends f INNER JOIN Users_Online o ON f.FriendID = o.UserID WHERE o.OnlineStatus = '1' AND f.FriendID = '$user_ID' AND f.Level = '1' UNION SELECT f.FriendID, f.UserID, f.FriendIDMAIN, f.DateRequested, o.OnlineStatus FROM Users_Friends f INNER JOIN Users_Online o ON f.UserID = o.UserID WHERE o.OnlineStatus = '1' AND f.UserID = '$user_ID' AND f.Level = '1' ORDER BY FriendIDMAIN ASC
  5. Even doing like below gives me 2 returns, with no AND's OR's just querying the "message msg_id" So I don't think it's parenthasis. SELECT m.msg_id, m.uid_fk, m.message, m.ToID, m.created, m.uploads FROM messages m LEFT JOIN Users_WallPosts_Hide w ON m.msg_id = w.PostID JOIN Users_Friends f ON m.uid_fk = f.FriendID JOIN Users_Friends j ON m.uid_fk = j.UserID WHERE m.uid_fk='$uid' ORDER BY m.msg_id DESC limit
  6. I still don't get it. I've tried every parenthesis logic possible and still always get 2 returns.
  7. Hmmm, can you elaborate on that a bit? I tried the below with parentheses and missing single quotes on the LEVEL=1 and get the same results. The 2nd one gives me 2 returns, the first one gives me 4 returns on each query. 4returns: SELECT m.msg_id, m.uid_fk, m.message, m.ToID, m.created, m.uploads FROM messages m LEFT JOIN Users_WallPosts_Hide w ON m.msg_id = w.PostID JOIN Users_Friends f ON m.uid_fk = f.FriendID JOIN Users_Friends j ON m.uid_fk = j.UserID WHERE ((w.Hidden IS NULL AND f.Level = '1' AND m.uid_fk='$uid') OR (w.Hidden IS NULL AND j.Level = '1' AND m.uid_fk='$uid')) ORDER BY m.msg_id DESC limit 10 2 returns: SELECT m.msg_id, m.uid_fk, m.message, m.ToID, m.created, m.uploads FROM messages m LEFT JOIN Users_WallPosts_Hide w ON m.msg_id = w.PostID JOIN Users_Friends f ON m.uid_fk = f.FriendID WHERE (w.Hidden IS NULL AND f.Level = '1' AND m.uid_fk='$uid') ORDER BY m.msg_id DESC limit 10
  8. Nope, unfortunately that didn't do the trick either, it didn't display anything until I modified it a bit like below, I had to use the INNER JOIN for the User_WallPosts_Hide part and then also had to ad the Friend part with UserID because it has to look at 2 different ID to see if Friends are Level 1 (UserID and FriendID) This made it display it 6 times tho per message, and I have 2 messages in the hidden part, and when I take out the FriendID part then it displays 4 of them, so it's still doubling up, but doubling up everything now. Below is what I have. SELECT m.msg_id, m.uid_fk, m.message, m.ToID, m.created, m.uploads FROM messages m LEFT JOIN Users_WallPosts_Hide w ON m.msg_id = w.PostID JOIN Users_Friends f ON m.uid_fk = f.FriendID JOIN Users_Friends j ON m.uid_fk = j.UserID WHERE w.Hidden IS NULL AND m.uid_fk='$uid' OR f.Level = 1 AND m.uid_fk='$uid' OR j.Level = 1 AND m.uid_fk='$uid' ORDER BY m.msg_id DESC limit 10
  9. That almost worked, but I am also doing to other Joins and using UNION to put them together, so now it is doubling up all of my messages that are coming in, altho it only shows one of the hidden ones, so it's hiding one, but I can't figure out why it's doubling up now that I have added it to my other query like below? Any ideas? $query = mysql_query(" SELECT messages.msg_id, messages.uid_fk, messages.message, messages.ToID, messages.created, messages.uploads FROM messages WHERE messages.uid_fk='$uid' UNION SELECT messages.msg_id, messages.uid_fk, messages.ToID, messages.message, messages.created, messages.uploads FROM messages INNER JOIN Users_Friends ON messages.uid_fk = Users_Friends.UserID WHERE Users_Friends.FriendID = '$uid' AND Users_Friends.Level = '1' UNION SELECT messages.msg_id, messages.uid_fk, messages.ToID, messages.message, messages.created, messages.uploads FROM messages INNER JOIN Users_Friends ON messages.uid_fk = Users_Friends.FriendID WHERE Users_Friends.UserID = '$uid' AND Users_Friends.Level = '1' UNION SELECT messages.msg_id, messages.uid_fk, messages.message, messages.created, messages.ToID, messages.uploads FROM messages LEFT JOIN Users_WallPosts_Hide ON messages.msg_id = Users_WallPosts_Hide.PostID AND Users_WallPosts_Hide.Hidden = '1' WHERE Users_WallPosts_Hide.PostID IS NULL order by msg_id ") or die(mysql_error());
  10. I think I need to use Join for this? I have 2 tables, where I have a bunch of messages, and basically on each message I have "hide" button that posts the UserID, PostID, and Hidden as 1 in another table. So my hidden table has 3 columns: UserID, PostID, Hidden My messages table has all that are shown below, but I need to get all the PostIDs from "messages" except the ones that have a "1" under Hidden in the Users_WallPosts_Hide table. I suck at Joins, and can't figure this. Any help would be appreciated. Thanks $query = mysql_query(" SELECT messages.msg_id, messages.uid_fk, messages.message, messages.ToID, messages.created, messages.uploads FROM messages INNER JOIN Users_WallPosts_Hide ON messages.msg_id = Users_WallPosts_Hide.PostID WHERE Users_WallPosts_Hide.Hidden = '1' order by msg_id desc") or die(mysql_error());
  11. I'm trying to make a form that has to carry the name address and all that to Paypal as well as some checkboxes that need to add themselves up if multiples are checked. But the Paypal form submit automatically goes to Paypal so the post doesn't post on my page to get the value if that makes any sence? Has anyone done anything like this? I'm trying to basically do. <FORM action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post"> <input type="hidden" name="cmd" value="_xclick"> <input type="hidden" name="business" value="myemail@email.com"> <input type="hidden" name="currency_code" value="USD"> <input type="hidden" name="return" value="http://backtomysite.com"> <table style="float:left; margin-bottom:10px;" width="700px"> <tr> <td>Name</td><td colspan="5"><input type="text" name="name" value="" size="40" /></td> </tr> <tr> <td>Address</td><td colspan="5"><input type="text" name="address1" value="" size="40" /></td> </tr> <tr> <td>City</td><td><input type="text" name="city" value="" size="20" /></td><td>State</td><td><input type="text" name="state" value="" size="4" /></td><td>Zip</td><td><input type="text" name="zip" value="" size="6" /></td> </tr> <tr> <td>Phone</td><td><input type="text" name="phone" value="" size="20" /></td> </tr> <tr> <td colspan="6">Professional: <input type="radio" name="item_name" value="Professional Package"> Non-Professional: <input type="radio" name="item_name" value="Non-Professional Package"></td> </tr> <tr> <td colspan="6"><b>REGISTRATION FEE:</b></td> </tr> <tr> <td colspan="6"><input type="checkbox" name="amount" value="150"> Professional – $150.00</td> </tr> <tr> <td colspan="6"><input type="checkbox" name="amount" value="95"> Student – $95.00</td> </tr> <tr> <td colspan="6"><input type="checkbox" name="amount" value="55"> Non-Professional: Single – $55.00 (family/survivors)</td> </tr> <tr> <td colspan="6"><input type="checkbox" name="amount" value="50"> *Optional Workshops - $50 for conference participant</td> </tr> <tr> <td colspan="6"><input type="checkbox" name="amount" value="85"> $85 for non-conference participant</td> </tr> <tr> <input type="hidden" name="on1" value="Comments"> <td>Additional Comments:</td><td colspan="5"><textarea rows="2" cols="50" value="" name="os1"></textarea></td> </tr> <tr> <td colspan="6"><input type="checkbox" name="amount" value="250"> Vendors: Vendor booth is available for $250.</td> </tr> --> <tr> <?echo "<input type=\"hidden\" name=\"amount\" value=\"$amount\">\n";?> <td colspan="6"><input name="Submit" type="submit" value="Submit Registration" /></td> </tr> </table> </form> How do I get the amount checkboxes to total into the amount? I have the Comments working and the Proffesional Radio buttons working to create the product, but I'm not sure if the Name and Address stuff is settup right either. I keep reading and reading, but there isn't much info on paypal, especially doing checkbox arrays. And doing an if (isset($_POST['amount'])) { code to add up the array } Doesn't help either. Any help would be great. Thanks
  12. I have a form where I have a dropdown with all 50 states. The value for each options is the State abbreviation. Now I have an input area that needs the name to change if the state is selected as SD so the shipping can be different where this form posts too. I'm not sure how to change an input name tho. I was trying something like below. <script language="javascript" type="text/javascript"> $(document).ready(function () { $('.group').hide(); $('#option').show(); $('#state').change(function () { $('.group').hide(); $('#option'+$(this).val()).show(); }) }); </script> Then inside my form I would do. <td>State</td><td> <?echo "<select id=\"state\" name=\"xxxState\">\n"; $state_query = mysql_query("SELECT * FROM State"); while ($state_row = mysql_fetch_assoc($state_query)) { $State = $state_row['State']; echo"<option value=\"$State\">$State</option>"; } ?> </select> <td> <td>Quantity</td><td> <div id="option" class="group"><input type="text" size="1" value="0" name="QuantityBook1"></div> <div id="optionSD" class="group"><input type="text" size="1" value="2" name="QuantityBookSD"></div> </td> But that javascript obviously would only hide and show the div's, which I guess might work, but wouldn't those values still be passed? So I need to actually remove and add the names. Plus my script above would only work if I had 50 inputs and then pulled the id's for each and only changed the SD one to the "QuantityBookSD". Any help would be appreciated.
  13. Nevermind, I got it working using the link you posted. THANKS! Still thought a group could be broken up to simplify it further.
  14. Why does it count all the rows even inside the Group tho? My problem is, I have to have the entire thing, even the title inside one while loop, because I can echo the title and put the other info in another inside the main loop, but with the pagination I have, then it'll either count the title, or count the info inside the while loop so my pages aren't correct. For instance, if I have my pages set to display 15 queries, using the LIMIT I have below, if I use $query_pag_data2 = "SELECT DISTINCT Whosendscard FROM Contacts WHERE ClientsAnniversary LIKE '%".$searchmonth."%' ORDER BY Whosendscard ASC LIMIT $start, $per_page"; $result_pag_data2 = mysql_query($query_pag_data2) or die('MySql Error' . mysql_error()); while ($contact_row2 = mysql_fetch_array($result_pag_data2)) { $Whosendscard = $contact_row2['Whosendscard']; $query_pag_data = "SELECT * FROM Contacts WHERE Whosendscard ='$Whosendscard' AND ClientsAnniversary LIKE '%".$searchmonth."%' ORDER BY Whosendscard ASC"; $result_pag_data = mysql_query($query_pag_data) or die('MySql Error' . mysql_error()); while ($contact_row = mysql_fetch_array($result_pag_data)) { //Blah code } } Then it'll need to display 15 Whosendscard before it shows another page, and at the same time, if one WhosendsCard has 10 queries and the next has 20, then all of those will show on the same page because it's only counting the "title" and if I put the LIMIT in the second SQL query, if the first query has 20 queries, and the 2nd has 10 queries, it counts these separately, so it will break up the first one and not do 15 of the next one on another page correctly.
  15. Anyone? Did I write it that confusing? All I need is to get all of the information in each group, and return those, but return the group once. I want it to display like the following basically. Joe:(with 3 record) 1st record 2nd record 3rd record Frank:(with 2 records) 1st record 2nd record Paul:(with 3record) 1st record 2nd record 3rd record But right now all I am getting is Joe:(with 3 record) 1st record Frank:(with 2 records) 1st record Paul:(with 3record) 1st record So they are grouping and I am writing the Names as titles in the groups, but I can't get the rest of the information from the groups.
  16. Ok, so I am trying to do a query where I group by "Whosendscard" and all the rest of the information then gets pulled in below each group. I have the following, which is working, but I only get one result per group I need to get all of the results per group. For instance, if I have Joe, and Frank in the Whosendscard then I have 3 queries for Joe and 1 for frank I should see 4 results, but I am only seeing 1 result for each. How do I get the 3 results to show under Joe and the 1 to show under Frank where the ClientsAnniversary is say in $searchmonth = August like I have below? And I have the Limit set because I am doing 15 results ber page, which also works because if I have 19 queries between Joe, Frank, and Paul and 15 of those queries are Joe and Franks, Joe and Frank show up on the front page and Paul shows up on the 2nd as expected but only 1 query per user shows up. Grrr. $query_pag_data = "SELECT * FROM ( SELECT * FROM Contacts WHERE ClientsAnniversary LIKE '%".$searchmonth."%' ORDER BY Whosendscard ASC LIMIT $start, $per_page ) as Contacts group by Whosendscard ";
  17. Ok, so I have a REALLY strange problem. So I am trying to delete an array of checkboxes with an input delete piece and I have used a bit of a tutorial on the deletion part. But, my form works fine in IE9 when I do this and doesn't work in firefox when I have it inside a <form> tag. <form name="deletecheckbox" method="post" action=""> <input name="delete" class="delete_button" type="submit" id="delete" value="Delete" /> //some checkboxes pulled in dynamically thru ajax inside a loop and I won't put the whole looping code just what the checkbox looks like <input name=\"checkbox[]\" type=\"checkbox\" id=\"checkbox[]\" value=\"$ID\"> <? $contact_query = "SELECT ID FROM Contacts ORDER BY ID ASC"; $contact_query_result = mysql_query($contact_query); $count=mysql_num_rows($contact_query_result); if($delete){ for($i=0;$i<$count;$i++){ $del_id = $checkbox[$i]; $sql = "DELETE FROM Contacts WHERE ID='$del_id'"; $result = mysql_query($sql); } } ?> </form> Now, if I do the same thing without the form part, it works in Firefox but not in IE <input name="delete" class="delete_button" type="submit" id="delete" value="Delete" /> //some checkboxes pulled in dynamically thru ajax inside a loop and I won't put the whole looping code just what the checkbox looks like <input name=\"checkbox[]\" type=\"checkbox\" id=\"checkbox[]\" value=\"$ID\"> <? $contact_query = "SELECT ID FROM Contacts ORDER BY ID ASC"; $contact_query_result = mysql_query($contact_query); $count=mysql_num_rows($contact_query_result); if($delete){ for($i=0;$i<$count;$i++){ $del_id = $checkbox[$i]; $sql = "DELETE FROM Contacts WHERE ID='$del_id'"; $result = mysql_query($sql); } } ?> Anyone know what's goin on here? I'm lost.
  18. I'm trying to write a piece that checks to see if something someone posts is a url or if it's just a url in a sentence. Basically, I want it so if someone puts in www.phpfreaks.com (then it does something) but if they put I am on www.phpfreaks.com where are you? (Then it does something else) Like the first one will get the dom of the page and post that, and the second one would just post the sentence with the url in it as a link. So I am getting my post $Post checking if there is a www or .com or .net or .gov in it $find2 = 'www.'; $find3 = '.com'; $find4 = '.net'; $find5 = '.gov'; if((strstr($Post, $find2) ==true)||(strstr($Post, $find3) ==true)||(strstr($Post, $find4) ==true)||(strstr($Post, $find5) ==true)){ then do I explode the whole thing, or what would I do in here with the $Post? some people might put in just phpfreaks.com others might put in http://www.phpfreaks.com and others might put in http://www.phpfreaks.com/forums/index.php?action=post;board=1.0 so I need to find the www. and or .com and find the first space before that, and after that and cut out the middle section, but I'm at a loss. }
  19. I fixed this, so a mod can close it, I had an error in my .php file, so it was echoing that instead of just the succes which is why it wasn't trying to do the refesh request.
  20. See, here's my return for the exact same pieces with the ID's pulling in, as you can see, each one is unique, and the first one won't work after it is pulled in thru the original ajax request, it just reloads the page once first, then after the page is reloaded and it has the same exact code as before, then it works, but it's like it doesn't do the ajax piece when it's pulled from the url: "../include_wall_front/likepost_ajax.php", because the document can't be ready I guess thru the DOM "$(document).ready(function()" since this is loaded thru ajax? Do you see any difference in Like80 to Like79? Because Like 79 works, but Like80 refreshes, then it works after the refresh, but if I make another Post, then it would ad another Like - Like81 but that one wouldn't work until it's reloaded. Does that make sence? <div class="Like"> <div id="Like80" class="flash_load"></div> <div id="loadLike80"></div> <div id="likehide" class="likehide80"> <form method="post" name="80" action=""> <input id="PostID80" value="80" type="hidden"> <input id="UserPostID80" value="1" type="hidden"> <input id="Friend80" value="0" type="hidden"> <input class="likepost" id="80" value="Like80" type="submit"> </form> </div> <div class="unlikehide80" style="display: none;"> <form method="post" name="80" action=""> <input id="PostID80" value="80" type="hidden"> <input id="Friend80" value="0" type="hidden"> <input id="UserPostID80" value="1" type="hidden"> <input class="unlikepost" id="80" value="Unlike" type="submit"> </form> </div> </div> <div class="Like"> <div id="Like79" class="flash_load"></div> <div id="loadLike79"></div> <div id="likehide" class="likehide79"> <form method="post" name="79" action=""> <input id="PostID79" value="79" type="hidden"><input id="Friend79" value="0" type="hidden"><input id="UserPostID79" value="1" type="hidden"> <input class="likepost" id="79" value="Like79" type="submit"> </form> </div><div class="unlikehide79" style="display: none;"> <form method="post" name="79" action=""><input id="Friend79" value="0" type="hidden"> <input id="PostID79" value="79" type="hidden"> <input id="UserPostID79" value="1" type="hidden"> <input class="unlikepost" id="79" value="Unlike" type="submit"> </form> </div> </div> and my ajax is $(document).ready(function() { $(".likepost").click(function(){ var element = $(this); var Id = element.attr("id"); var $PostID = $('#PostID'+Id).val(); var $UserPostID = $('#UserPostID'+Id).val(); var $Friend = $('#Friend'+Id).val(); var dataString = 'PostID=' + $PostID + '&UserPostID=' + $UserPostID + '&Friend=' + $Friend; $.ajax({ type: "POST", url: "../include_wall_front/likepost_ajax.php", data: dataString, cache: false, success: function(html){ $("#loadLike"+Id).append(html); $(".likehide"+Id).hide(), $(".unlikehide"+Id).show(); } }); return false; }); });
  21. Ok, so I have modified my code a little, so the php file now echo's success when t's complete, and I now want it to load the index page again. My cookies get set and everything, but when I try to use if(html == 'success'){ window.location.replace('http://www.thetrue1.com'); }else{ $("#log_res2").replaceWith(html); } it doesn't reload the page, it just sits there. but if I hit refresh, then the user is logged in correctly, so how do I use window.location.replace('http://www.thetrue1.com'); to refresh my page? My errors and everything else are working perfectly. Thanks
  22. But I can select them and view the source and they have unique ID's that I placed in the areas like the "Like". But yeah I have ran into that too with the id's being the same so they refresh, but with these I put new ID's in each id area using the ID from the databse, it just seems like anything I pull in from an ajax statement isn't useful as a <form> at that point if it's bult dynamically thru the ajax and appended or prepended to my other data.
  23. Ok, so how do I send the URL to a new page? Right now I understand the writing ajax to a div, replacing the contents of the div, appending it etc. But what about if I am using the below code, for like a login area, I can get the form to return wrong username etc based on the submitting, but if everything checks out as correct in my ajax-login.php file, the form doesn't follow the headers at the bottom of the page. What would I use to make it follow the headers from this page? Or is there a better way? Thanks ajax-login.php a bunch of code, grabbing the values from the form and checking if they are valid passwords and things like that like; if ($usernamecheck == ''){ echo "<div id=\"log_res2\">"; echo "<span class=\"error\">*Must enter a username.</span><br />"; echo "</div>"; }else{ header("location: /index.php"); } And my ajax is $(document).ready(function() { $("#Login").click(function(){ var $password = $("#password").val(); var $username = $("#username").val(); var dataString = 'username=' + $username + '&password=' + $password; $.ajax({ type: "POST", url: "../includeajax/ajax-login.php", data: dataString, cache: false, success: function(html){ $("#log_res2").replaceWith(html); } }); return false; }); }); I get the errors when I put in the wrong usernames or passwords, but how do I return that header to make it redirect to a new page? Thanks
  24. Ok, so I have a few ajax pieces on my site, and I am trying to include functionality when something is clicked. Basically, lets say like on facebook, when someone makes a comment, then that new comment is created using something like $.ajax({ type: "POST", url: "../include/comment_ajax.php", data: dataString, cache: false, success: function(html){ $("#Loadnewcomment"+Id).append(html); $(".oldcommenthide"+Id).hide(), $(".newcomment"+Id).show(); } }); Now in that comment_ajax.php let's say there is another like or comment input field, something like. <div class=\"Likecomment\"> <div id=\"likehide\" class=\"likehide$commentID$CommentIDLike\"> <form method=\"post\" name=\"$commentID$CommentIDLike\" action=\"\"> <input type=\"hidden\" id=\"PostID$commentID$CommentIDLike\" value=\"$PostID\" /> <input type=\"hidden\" id=\"UserPostID$commentID$CommentIDLike\" value=\"$PostUserID\" /> <input type=\"submit\" class=\"likepost\" id=\"$commentID$CommentIDLike\" value=\"Like\" /> </form> </div>"; How would I get this form to also use the ajax that is on the original page, because this is loaded in thru the ajax, so it doesn't know to use the normal ajax. My likes work perfectly, unless I create a new comment, then on that new comment, if I click "Like" on a comment, rather than it just changing, it reloads the page, then I can click like on it like normal and it changes using my ajax, but not until the page is reloaded.
  25. Whoops, this is sposed to be in the Ajax forum, not sure how I got into this one, I could've sworn I clicked Ajax, mods, can you move this? Thanks.
×
×
  • 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.