Jump to content

mcmuney

Members
  • Posts

    358
  • Joined

  • Last visited

Everything posted by mcmuney

  1. I'm using the code below, which displays the most recent 15 results. I'd like to modify it so that it displays the most recent 15 results in random order. How can I achieve this within the code below without having to use another query? SELECT mem_id,type_id,date_added,value FROM sc_coins_asset WHERE value<>'0' ORDER BY date_added DESC LIMIT 0,15
  2. What I'm trying to do involves 3 tables: Table1: id, status Table2: id, value Table3: id, value1, value2 Step1: Pull all unique id numbers where status=1 from Table1 Step2: For each id pulled in Step1, insert a value=(random number between 1-5; important: the random number should be different for each insert for each id) into Table2 Step3: For each id and value inserted in Step2, update in Table3 where Table3.id=Table2.id set value1=(existing value +1) and value2=(existing value +the random value inserted in Step2 Any guidance would be greatly appreciated. Thanks.
  3. On a single page, I have 2 functions: 1) one is similar to a FB wall, where users click to post a comment and the textarea appears on click and posts on submission 2) it's a modal window that opens on click and users enter text and submits, and on submit, the modal window closes and the page refreshes automatically The below code is what's at the very top of the page, which are lines 1-7. When line 5 is in its current position, option 1 above works as expected, but option 2 does not work properly. On submit, the modal window does not close and the page doesn't refresh automatically. However, if I move line 5 and place it on line 1, option 2 works as expected, but on option 1, the textarea does not appear on click and users can't post. What could be the conflict? Thanks. <script type="text/javascript" src="ajax/modal_window/js/ajax.js"></script> <script type="text/javascript" src="ajax/modal_window/js/modal-message.js"></script> <script type="text/javascript" src="ajax/modal_window/js/ajax-dynamic-content.js"></script> <script type="text/javascript" src="ajax/prototype.js"></script> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> <script type="text/javascript" src="js/jquery.oembed.js"></script> <script type="text/javascript" src="js/wall.js"></script>
  4. That's all the code. This executes when the page has.. example.php?ft=1 (anytime ft>0). It's the insert portion that's executing twice.
  5. I'm using the code below to insert data into my DB, but it's executing twice. Not as a duplicate, but with it's own unique line. How can I fix this? if($ft>0) { $ft="UPDATE sc_member SET mem_feature_flag='1' WHERE scm_mem_id='$ft'"; $res=$db->update($ft); // SEND MESSAGE $time=time(); $ft=$_GET['ft']; $txt_sb_body="Hey ".$fname.", You have been featured! Keep up your activity! {automated message}"; $sql="INSERT INTO sc_messages (`smg_from`, `smg_to`, `smg_subject`, `smg_body`, `smg_sent_del`, `smg_postdate`, `scm_bulletin`, `send_cron`) VALUES ('1','$ft','Featured Alert','$txt_sb_body','1','$time', '6', 'N')"; $result = mysql_query($sql); }
  6. I need to use in/then statements using PHP. For example, if($width>1280){ //do X }else{ //do Y. Even though it's displaying the right width, it's not seeing the value as a number; therefore, treating it as a 0.
  7. I'm pulling the resolution by using java and displaying it via php, which works. However, when I want to add/substract, it treats to value ($width) as zero. In the example below, I need "echo $width+1" to = 1281 (currently = 1). How can I make that happen? <?php $width='<SCRIPT language="JavaScript"> <!-- width = screen.width; document.write(width); //--> </SCRIPT>'; echo $width; //this shows resolution, ie 1280 echo $width+1; //this shows 1 ?>
  8. It's a mysql database. It's a text field, but I'm not sure why the ? would be an issue.
  9. I have the code below in a script where descriptions can be added to an image, which is referenced in the code as a comment. Everything seems to work fine, EXCEPT when there is a "?" in the comment, in which case, the second update doesn't execute. Any idea why and any solution to this problem? $db->update("UPDATE `sc_member_images` SET ordering=-1 WHERE scm_mem_id='{$social_mem_id}'"); for($i=0;$i<count($_POST['p']);$i++) { $q="UPDATE `sc_member_images` SET ordering='".($i+1)."',sci_caption='".addslashes($_POST['p'][$i][comment])."' WHERE sci_id='{$_POST['p'][$i][image]}'"; $db->update_data($q)or die(mysql_error()); }
  10. I recently had a domain change and I have many posts that reference the old domain. What would be the easiest way to do a edit replace, where if "xyz.com" exist, replace it with "abc.net". Nothing else should change. Thanks.
  11. I'm using this piece of code: <script> function window_open(passed_value) { if(confirm("Confirm?")) { window.open('view_full_image.php?imgid='+passed_value+'&mem_id=<?=$_GET['scm_mem_id']?>','','top=50,left=50,width=600,height=600,scrollbars=yes'); window.opener.location.href=window.opener.location.href; // refresh the main page window.opener.focus(); // focus on the main page return false; } return false; } </script> It's basically supposed to do 2 things when the alert is confirmed or "Ok" is pressed: -let's say that this code is on "domain.com/view_image.php" 1) opens a popup window (view_full_image.php) and.. 2) refresh the page that it's on, which is domain.com/view_image.php This works fine on Firefox; however, on IE, #2 doesn't work properly. Instead of refreshing the page, it goes to the root domain. For example, instead of refreshing domain.com/view_image.php, it'll refresh to domain.com. What's causing this compatibility issue?
  12. Yes, I'm reloading the <div> section via ajax, which loads a new image. But after a reload, the image load on the fancybox stops working, even though the java is outside of the <div> that's reloading withing the page.
  13. I have a scenario where the javascript stops working once a section of a page is reloaded. For example: <javascript> some java code to open an image usina a fancy window </script <div id="reload_section"> <a href="image" id="java-fancy-window" onclick="java-fancy-windo"><img src="image"></a> </div> <a href="reload_section_page">RELOAD SECTION</a> I'm using something like this and when I click on the image, it opens the image in a nice popup window; however, when the <div> section is reloaded, the same function stops to work. I've even tried placing the java code again inside the page that's reloaded inside the <div>, but it still does not work. Any ideas?
  14. I'm trying to pull a certain number of characters after a specific character. For example: $data="x=1234567" I'd like to pull 7 characters after "x=". So the result whould be "1234567". I couldn't use strpos because the 7 characters will NOT always begin from the 3rd character. For example, it could be "x=" or "tyx=" or "1x=", etc. I only want what's after "x=". Thanks.
  15. Ok, I almost have what I want. I've written this so far, which is working; however, only when the button type="button". It does not work when the type="submit". I need the form to submit the data. What am I missing here? <script type="text/javascript"> function submitForm() { // submits form document.getElementById("ismForm").submit(); } function btnSearchClick() { if (document.getElementById("ismForm")) { document.getElementById('searchx').style.display = 'none'; document.getElementById('loading').style.display = 'block'; setTimeout("submitForm()", 5000); // set timout } } </script> <form method="post" id="ismForm" name="ismForm" action="test3.php?x" class=""> <input type="hidden" name="amount" value="100" /> <div id="loading" style="display:none;"><img src="http://article.onlinewebtool.com/wp-content/images/loading.gif" alt="" />Loading!</div> <input class="button" onclick="btnSearchClick();" type="button" id="searchx" name="searchx" value="Search" autocomplete="off"> </form>
  16. The javascript is right there on my last reply. Here it is again: <script type="text/javascript"> (function (d) { d.getElementById('form').onsubmit = function () { d.getElementById('submit').style.display = 'none'; d.getElementById('loading2').style.display = 'block'; }; }(document)); </script> What I'm asking for is probably about 2-3 lines of additional code. Hardly requiring hiring a professional. If you can't help, no worries.
  17. No java currently. On submit, it just executes the form, which is a php calculation and insert to the DB. I'm hoping to add java. Here's something I found online, which does #1 of what I'm looking to do, but I need help with applying #2 to it: <script type="text/javascript"> (function (d) { d.getElementById('form').onsubmit = function () { d.getElementById('submit').style.display = 'none'; d.getElementById('loading2').style.display = 'block'; }; }(document)); </script> <form id="form" action=""> <div id="loading2" style="display:none;"><img src="loading.gif" alt="" />Loading!</div> <input id="submit" value="Click!" type="submit" /> </form>
  18. I have a form and what I want is for it to do 2 things when the form button is clicked: 1) replace the Submit button with a "loading..." image or text 2) show the image/text above for about 5 seconds, then actually submit the form Here's my form: <form method="post" action=""> <input type="hidden" name="amount" value="<?=$raid;?>" /> <input class="btn" type="submit" name="raid" value="Submit" /> </form>
  19. I'm using ajax on multiple functions on the same page and I'm running into some issues in terms of where the code is placed. For example: For function1, I need this on the header: <link href="css/wall.css" rel="stylesheet" type="text/css"> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> <script type="text/javascript" src="js/jquery.oembed.js"></script> <script type="text/javascript" src="js/wall.js"></script> And this for function2: <script type="text/javascript" src="ajax/modal_window/js/ajax.js"></script> <script type="text/javascript" src="ajax/modal_window/js/modal-message.js"></script> <script type="text/javascript" src="ajax/modal_window/js/ajax-dynamic-content.js"></script> <script type="text/javascript" src="ajax/prototype.js"></script> <link rel="stylesheet" href="ajax/modal_window/css/modal-message.css" type="text/css"> Here's my issue. One seems to conflict with the other. If I place it this way, one function will work as expected, but the other won't. If I reverse the order, meaning function2 first, then function1, then the reverse will be true, the second function will work as expected, but not the other. Is there a solution for this?
  20. I'd like to use the unlink function in php to delete all files within a folder that does NOT END WITH "... enlarged.jpg or enlarged.gif or enlarged.png". Files with any other ending should be deleted. Thanks.
  21. I could be wrong, but it seems that both the 'date' and 'id' would serve the same purpose in determining the first. You can take the lowest id for each to_id or the earliest date.
  22. There's no "first" indicator on the DB. It has to be determined by the 'id' i'm guessing? For example: 3,lkd,9,7 (7 is first) 4,ljf,9,6 If this is grouped by to_id and somehow pull the count based on the lowest id, is that possible? I also have a date field if that's of any help.
  23. I'm not sure where to begin on this one. I'm working with a comment table and trying to determine who is writing the most "first" comment. For example, the table would have the followin fields: id, comment, to_id, from_id So what I need is to determine which 'from_id' is writing the most very first comment. For example: id, comment, to_id, from_id 1,abc,5,6 (6 is first) 2,bcd,5,7 3,lkd,9,7 (7 is first) 4,ljf,9,6 5,lsj,4,6 (6 is first) 6,lds,4,5 (5 is first) In this example, from_id 6 would have a count of 2; 7 count of 1, 5 count of 1. How would I write this statement?
  24. There's no error. I think the issue is that both updates are affecting the same rows, one is overwriting the other. As I said, if I switch positions, it appears that the top one is executing fine. Is there a way to set order, to run this first, then run the second?
  25. Why won't the second update execute? I've tried swapping the two and only the first one always executes, but the not second. What am I missing? $mtp="UPDATE sc_member_images SET sci_main='1' WHERE sci_id='$mtp'"; $res=$db->update($mtp); $mtp2="UPDATE sc_member_images SET sci_main='0' WHERE scm_mem_id='$scm_mem_id' AND sci_id!='$mtp'"; $res2=$db->update($mtp2); 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.