Jump to content

SharkBait

Members
  • Posts

    845
  • Joined

  • Last visited

    Never

Everything posted by SharkBait

  1. Cool, is there a way to delete the duplicate items without deleting all of it?
  2. [code] <?php $str = "SELECT list, count( * ) AS n FROM $table GROUP BY list HAVING ( n > 1 )"; $query = msyql_query($str); while($result = mysql_fetch_array($query, MYSQL_ASSOC)) {   echo "{$result['list']} {$reseult['count(*)'} <br />"; } ?> [/code] Try that :)
  3. Is it possible to do a query to find out all the duplicates in a table? I need to change a field to a unique and if I do that and it finds some duplicates is just stops at the first duplicate. I need to get rid of the duplicates and there are roughly 176,000 records to go through :)
  4. I'll look into that as well. Thanks Obsidian, thanks others too :)
  5. So i would have to turn the entire folder that the file sits in to writable?  geesh that seems a bit of a security issue... Or is it best to put it into a subdirectory of its own and 777 that subdir?
  6. I am having issues. I use the following: [code] <?php $filename = "testfile.txt"; if(!$handle = fopen($filename, 'a+')) {   echo "Cannot open file"; } ?> [/code] Now I get an Permission Denied warning and the Cannot open file error when I try to open/write a file. It seems (if the file exists) the file that is to be written to needs to be 777 for it to work.  Isn't the a+ argument supposed to create the file and open it if its not there??  The script itself has 777 permissions. What I want to do is if the file doesn't exists, create it and change the permission so that I can write to it properly. What am I doing wrong?
  7. If someone is interesting in what it looks like these are the scripts: [code] function checkMenuState() { var aMenus = Array("leftMainMenu", "leftSearchMenu", "counterTable", "failureTable"); for (x in aMenus) { //alert(aMenus[x]); ob = document.getElementById(aMenus[x]).style; ob.display = getCookie(aMenus[x]); } } [/code] [code] function toggleMenu(objID) { var ob = document.getElementById(objID).style; //ob.display = (ob.display == 'block')? 'none' : 'block'; if(ob.display == 'block') { ob.display = 'none'; } else { ob.display = 'block'; } setCookie(objID, ob.display) } [/code] [code] function setCookie(cookieName, cookieValue, cookieExp) { // Set the cookie information if(cookieExp != null) { // Cookie has a duration / date object is expected document.cookie=cookieName + "=" + escape(cookieValue) + ";path=/;expires=" + cookieExp.toGMTString(); } else { document.cookie=cookieName + "=" + escape(cookieValue) +";path=/"; } } [/code] [code] function getCookie(cookieName) { var cookieValue; // Obtain the Cookie information cookieString = document.cookie // Get each element in the cookie cookieArray = cookieString.split(";"); if(cookieString.length > 0) { // A cookie is present - loop through them for (x in cookieArray) { // Split the cookie value into name/value cookieValues = cookieArray[x].split("="); // trim any extra whitespaces from the value cookieValues[0] = trim(cookieValues[0]); if(cookieName == cookieValues[0]) { // Found a Match - get the value cookieValue = cookieValues[1]; } } // return the value of the cookie return unescape(cookieValue); } else { return null; } } [/code] Now in the HTML  in my header page I use: [code] <body OnLoad="javascript:checkMenuState();"> [/code] To ensure the menu's load their state correctly on page-refreshes etc In the menu sections I just do a simple OnClick call to toggleMenu(): [code] <a href="javascript:void(0);" OnClick="toggleMenu('failureTable')">+</a> [/code] And voila, it works nicely :)
  8. I got it working nicely. I just made an array of my menus IDs and loop through them to insert them into my getCookie function :) Thanks
  9. Thanks for the link.  I can now set and get cookies, I just gota figure out how OnLoad() works now because I believe that is what I need when I load the menus?  To check what state they should be loaded in?
  10. I have this little bit of code: [code] function toggleMenu(objID) { //if(!document.getElementByID) return; //alert(objID); var ob = document.getElementById(objID).style; ob.display = (ob.display == 'block')? 'none' : 'block'; } [/code] This is the sample HTML [code] <div class="navcontainer"> Main Menu <span><a href="javascript:void(0);" onclick="toggleMenu('leftMainMenu')">+</a></span> <div id="leftMainMenu" class="navsub" style="display: none;"> <ul> <li><a href="index.php">Home</a></li> <li><a href="profile.php">Profile</a></li> <!-- <li><a href="search.php">Search</a></li> --> <li><a href="view_notes.php">View Notes</a></li> <li><a href="javascript:OpenWindow('avgs.php')">Averages</a></li> <?php if($USERLEVEL >= $TESTER) { echo "<li><a href=\"test.php\">Test Units</a></li>\n"; } ?> <li><a href="prev_counter.php">Check Build Totals</a></li> <!-- <li><a href="faq.php">Testing Help</a></li> --> </ul> </div> </div> [/code] To help me expand and collapse menus.  How would I go about saving the state with a cookie or session so that when the page refreshes the menu blocks don't close?
  11. Ah thank you, the setTimeout() works perfectly. :)
  12. Hi, I read from a MySQL database using PHP and I am curious how can I delay displaying the lines by lines of information with Javascript? Output: You age slowly [wait 2 secs] You age slowly some more [wait 2 secs] You age really slow now [wait 2 secs] So that it outputs the first line, waits 2 seconds, then outputs the 2nd line, waits 2 sec, etc. I've seen this done, but not sure how they do it. Thanks.
  13. When I use a table to do this with images and I want to break at the end of 4 images I keep a counter and then check the Modulus to make sure there is no remainder and then break on that. [code] <?php // Images in an array or database whatever) $images = aray("pic1", "pic2", "pic3", "pic4", "pic5"); echo "<table border=\"1\">"; $i = 1; // Loop through the array for images foreach($images as $filename) {   // If i did this right, then if there is not a remainer then add the TR tags to drop to a new row.   if($i % 4 <> 0) echo "</tr><tr>\n";   // Display the image in a table cell   echo "<td><img sr=\"{$filename}\" /></td>";   // Increment counter   $i++; } ?> [/code] Now I might have it a bit wrong, but the idea is there :)
  14. Ah thats what I thought. But I've never seen it before until today. Thank you
  15. [code] <?php while (!feof($handle)) { # Checks the File pointer integer returned by fopen.               $buf = fgets($handle, 1096); # Returns a String from config, 1098 bytes long.               list($k,$v)=split('=', $buf); # Create a list of variables and assign string values by splittin$               $v = trim($v); #Remove Whitespace from $V             if ( $k ) {                       $config{$k} = "$v";             }     #      echo "#" .$k .$v ."<br>";     #      echo $config } ?> [/code] Well the part I have not seen before is the line [code=php:0] $config{$k} = "$v";[/code]  I've never seen curley braces used on a variable. What is it for? The rest of it I do understand. Thanks.
  16. Most people use some sorta javascript to make expanding menus without having to refresh the page.  Well its all javascript/css etc (DHTML).
  17. There is a WYSIWYG editor I use that is javascript based.  Would that effect the popup window I am trying to do with JS?
  18. Firefox runs this bit of code fine with no errors in the javascript console, but IE fails and doesn't want to execute it: [code] function ShowImage(URL, WIDTH, HEIGHT) { // Get URL and image size from PHP // Get width of currently open window var w = document.body.clientWidth; var h = document.body.clientHeight; // Center Window var leftPos = (w - WIDTH)/2, topPos = (h - HEIGHT) /2; // Add to the width and height to show images properly WIDTH = WIDTH + 25; HEIGHT = HEIGHT + 25; // Create a somewhat unique ID number for the window id = <?php echo rand(900, 999);?> // Open up a window and display the image. eval("page" + id + " = window.open(URL, '" + id + "','toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=' + WIDTH + ',height=' + HEIGHT + ',left = ' + leftPos + ',top = '+ topPos + '')"); } [/code] It is called via: [code] <?php echo "<a href=\"javascript:ShowImage('photos/{$photos['filename']}', $width, $height);\"><img src=\"photos/thumb_{$photos['filename']}\" alt=\"{$photos['filename']}\" border=\"=\" /></a> "; ?> [/code] All the parameters get passed, so I am not sure what is wrong.  On http://www.tingram.ca the IE javascript error window says [code] Line: 1 Char: 1 Error: Object Expected Code: 0 URL: http://tingram.ca [/code]
  19. Ah both of those make sense. I forgot I could do comparisons in the cases. Thanks :)
  20. If I need toa  large range of values in a switch what is the best way? [code] <?php $value = 192; switch($value) {   case 1 to 400:       // Do something       break;     case 401 to 601:       // Do something else       break; } ?> [/code] Its similar to VB.NET with 1 to 400, not sure if PHP can do the same thing.
  21. So I'll look into AJAX then.  Thank you
  22. I am assuming its javascript I want but I'm a noob when it comes to javascript so hopefully someone can point me in the right direction. I want to be able to create a sorta 'on the fly' type mysql queries. I'll have a dropdown box with 'table' names in it. When a user selects a table name it will update a block beside it with the information based on a MySQL Query. dropdown boxes would hold something like: Pear Apple Plum I would then create the MySQL query like SELECT * FROM fruit WHERE name = '{$userselectedoption}' Then I would have a <div> block to the left of the dropdown menu that would show me the results.  Would javascript allow me to do this (along with php to do the query) or should I look into AJAX since that is JS that can pull information from a server without refreshing the page? I'd perfer not to have to $_POST the information and reload the page...
  23. [code] SELECT T0.DocNum, T0.TrnspCode, T2.ItemCode, T2.U_MODELNUM, T2.Quantity, T2.Price, T2.Weight1, T2.Length1, T2.Width1, T2.Height1 FROM OQUT T0 INNER JOIN OCRD T1 ON T0.CardCode = T1.CardCode INNER JOIN QUT1 T2 ON T0.DocEntry = T2.DocEntry INNER JOIN CRD1 T3 ON T1.CardCode = T3.CardCode WHERE T0.DocNum = '1667' AND T3.AdresType = 'S' [/code] How do modify the above query to GROUP BY T2.U_MODELNUM ?  I tack on GROUP BY T2.U_MODELNUM at the end of the query and it doesn't allow for it.  Something about agregated functions?
  24. I dont know, I just thought it would look better ;) I like how the ads aren't in your face and take me 6 yrs of scrolling to get to the content. So I thank you for that
  25. I just check to see if the form is is submited via $_POST and then I got into checking the form's elements to see if they have been posted.  *shrug*
×
×
  • 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.