
ted_chou12
Members-
Posts
1,488 -
Joined
-
Last visited
Everything posted by ted_chou12
-
Hi, I am wishing to add a row just by query such that it returns the queried row as if it was in the table: suppose the db has two rows: [id][name] 1test1 2test2 However, i want to added another entry: id 3, name test3 while returning the result so it appears like [id][name] 1test1 2test2 3test3 the row id3 is not actually in the db. Can you actually put something in the query so it appears like its fetching another row: SELECT * FROM album ADD (id='3' name='test3') Something like this? (I have checked join and leftjoin, i think those are joining two physical tables together, not actually adding a row.) Thanks, Ted
-
Hi, I found this code from a website, the point that I am trying to make here is to drag the image within a certain div, for example a 300 x 500px box, and the image can not be dragged outside this box. The current thing that this script allows me to do is to drag it all over the page, but not within a box that is limited to size: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><!-- saved from url=(0070)http://luke.breuer.com/tutorial/javascript-drag-and-drop-tutorial.aspx --><style type="text/css">.drag {border: 1px solid black; background-color: rgb(240, 240, 240); position: relative; padding: 0.5em; margin: 0 0 0.5em 1.5em; cursor: move;}</style> <div id="ttt" width="300px" height="500px"> <img class="drag" src="./JavaScript Drag and Drop Tutorial_files/drag_image.png" alt="drag image" style="left: 469px; top: 36px; "> </div> <pre id="debug">NON-draggable element clicked</pre><script language="JavaScript" type="text/javascript"><!--// this is simply a shortcut for the eyes and fingersfunction $(id){return document.getElementById(id);}var _startX = 0; // mouse starting positionsvar _startY = 0;var _offsetX = 0; // current element offsetvar _offsetY = 0;var _dragElement; // needs to be passed from OnMouseDown to OnMouseMovevar _oldZIndex = 0; // we temporarily increase the z-index during dragvar _debug = $('debug'); // makes life easierInitDragDrop();function InitDragDrop(){document.onmousedown = OnMouseDown;document.onmouseup = OnMouseUp;}function OnMouseDown(e){// IE is retarded and doesn't pass the event objectif (e == null) e = window.event; // IE uses srcElement, others use targetvar target = e.target != null ? e.target : e.srcElement;_debug.innerHTML = target.className == 'drag' ? 'draggable element clicked' : 'NON-draggable element clicked';// for IE, left click == 1// for Firefox, left click == 0if ((e.button == 1 && window.event != null || e.button == 0) && target.className == 'drag'){ // grab the mouse position _startX = e.clientX; _startY = e.clientY; // grab the clicked element's position _offsetX = ExtractNumber(target.style.left); _offsetY = ExtractNumber(target.style.top); // bring the clicked element to the front while it is being dragged _oldZIndex = target.style.zIndex; target.style.zIndex = 10000; // we need to access the element in OnMouseMove _dragElement = target; // tell our code to start moving the element with the mouse document.onmousemove = OnMouseMove; // cancel out any text selections document.body.focus(); // prevent text selection in IE document.onselectstart = function () { return false; }; // prevent IE from trying to drag an image target.ondragstart = function() { return false; }; // prevent text selection (except IE) return false;}}function ExtractNumber(value){var n = parseInt(value);return n == null || isNaN(n) ? 0 : n;}function OnMouseMove(e){if (e == null) var e = window.event; // this is the actual "drag code"_dragElement.style.left = (_offsetX + e.clientX - _startX) + 'px';_dragElement.style.top = (_offsetY + e.clientY - _startY) + 'px';_debug.innerHTML = '(' + _dragElement.style.left + ', ' + _dragElement.style.top + ')'; }function OnMouseUp(e){if (_dragElement != null){ _dragElement.style.zIndex = _oldZIndex; // we're done with these events until the next OnMouseDown document.onmousemove = null; document.onselectstart = null; _dragElement.ondragstart = null; // this is how we know we're not dragging _dragElement = null; _debug.innerHTML = 'mouse up';}}//--></script></body></html> Thanks, Ted
-
ajax is a type of coding within javascript that allows the clientside to pass info to the serverside WITHOUT refreshing the page, this is usually not possible. So you can make dynamic webpages, such as a chat, editing data without refreshing the page, makes ur page looks much nicer.
-
Hi, I wish to have multiple ajax requests at the same time, but passing different variables, how would I combine them so they are in the same function ajaxSwitchChat(); //Ajax Switch Chat function ajaxSwitchChat(user) { var ajaxRequest; //The variable that makes Ajax possible! try{ // Opera 8.0+, Firefox, Safari ajaxRequest = new XMLHttpRequest(); } catch (e) { // Internet Explorer Browsers try{ ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try{ ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { // Something went wrong alert("Your browser broke!"); return false; } } } //Create a function that will receive data sent from the server ajaxRequest.onreadystatechange = function() { if(ajaxRequest.readyState == 4) { document.getElementById('upper').innerHTML = ajaxRequest.responseText; } } ajaxRequest.open("GET", "notices.php?ajax=switchchat&user=" + user, true); ajaxRequest.send(null); //Create a function that will receive data sent from the server ajaxRequest.onreadystatechange = function() { if(ajaxRequest.readyState == 4) { document.getElementById('log').innerHTML = ajaxRequest.responseText; } } ajaxRequest.open("GET", "notices.php?ajax=switchchat2&user=" + user, true); ajaxRequest.send(null); //Create a function that will receive data sent from the server ajaxRequest.onreadystatechange = function() { if(ajaxRequest.readyState == 4) { document.getElementById('textarea').innerHTML = ajaxRequest.responseText; } } ajaxRequest.open("GET", "notices.php?ajax=switchchat3&user=" + user, true); ajaxRequest.send(null); } Thanks
-
thanks
-
Hi, I made a textfield that is made to do a certain thing when a key is pressed as onKeydown="event.keycode==13...", so that's when the enter key is pressed, but I am not sure how you can terminate the onKeyUp function such that when the key is released, the "enter" key does not effect the textarea: <<the textarea skips a line eventhough func is passed successfully Ted Chou
-
Hi, this isn't working and is annoying me, i don't see why it doesnt work function ajaxChat(user) { alert("\""+document.getElementById("message").value.length+"\"");//HERE I CHECKED THE STRING LENTH, IT SHOWS UP "0" var ajaxRequest; // The variable that makes Ajax possible! try{ // Opera 8.0+, Firefox, Safari ajaxRequest = new XMLHttpRequest(); } catch (e) { // Internet Explorer Browsers try{ ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try{ ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { // Something went wrong alert("Your browser broke!"); return false; } } } // Create a function that will receive data sent from the server ajaxRequest.onreadystatechange = function() { if(ajaxRequest.readyState == 4) { document.getElementById('chatlog').innerHTML = ajaxRequest.responseText; var objDiv = document.getElementById("chatlog"); objDiv.scrollTop = objDiv.scrollHeight; } } if (document.getElementById("message").value.length != 0) {//EVENTHOUGH THE SHOWED UP STRING LENGTH IS 0, THIS STILL PASSES TRU. ajaxRequest.open("POST", "notices.php?ajax=chat", true); ajaxRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); ajaxRequest.setRequestHeader("Connection", "close"); ajaxRequest.send("user=" + user + "&text=" + document.getElementById("message").value); document.getElementById("message").value = "";} Thanks Ted
-
this is an individual nas system, that has a usb hdd 320G mounted to it, but I think all of the system files are within the memory of the nas system (if you unplug the hdd, still can turn the machine on and off). so i don't think the hdd matters in this case. Thanks again
-
# cat /etc/fstab /dev/ram0 / ext2 defaults 0 0 none /proc proc defaults 0 0 none /dev/pts devpts defaults 0 0 # system initialisation ::sysinit:/usr/share/snake/rc.sysinit # setup serial console ttyS0::askfirst:/bin/sh # stuff to do before rebooting ::ctrlaltdel:/usr/share/snake/rc.reboot ::shutdown:/usr/share/snake/rc.reboot
-
I don't know what the distro means, but this is the code: # cat /etc/smb.conf #======================= Global Settings ===================================== [global] server string = nas smb passwd file = /etc/smbpasswd security = SHARE workgroup = WORKGROUP encrypt passwords = true short preserve case = yes preserve case = yes guest account = ftp guest ok = yes force user = root force group = root socket options = SO_KEEPALIVE TCP_NODELAY SO_RCVBUF=16384 SO_SNDBUF=16384 character set = utf8 client code page = 950 #============================ Share Definitions ============================== [main] comment = main path = /usb/sda1 writeable = yes original charset is ISo----something and 850, im trying to change it to unicode and t chinese. Thanks, Ted
-
Hi, as my subject, machine resets the etc folder after reboot, so the changes that I made to httpd.conf,smb.conf is changed back to original, and the changes become useless, how would i go about forcing the changes to apply after system reboots? Thanks,
-
Hi, I am looking for some simple linux OS system that can be installed onto xp, I don't want it to be too big and user friendly interface, just simple command lines like dos would be good enough for me, because I want to execute some files with linux. I am not very familiar with linux, please give me some names of freewares that may be ones that I am looking for, Thanks! Ted C.
-
Hi, I wish to redirect a subdomain to a variable, such that it turns: test.domain.com => domain.com/?lan=test test.domain.com/randompage.php => domain.com/randompage.php?lan=test ... i am not very familiar with this mod, so i am not sure what is actually going to happen to a page that already has some variables like this one: test.domain.com/rdp.php?user=123 => domain.com/rdp.php?user=123&lan=test should this be the logical way of it or something else? I have tried this so far: RewriteCond %{HTTP_HOST} !^test\.domain\.com RewriteRule (.*) http://domain.com [r=Permanent] thanks! Ted
-
Thank you! I got it, and I learnt a new function too.
-
Hi, I am trying to replace each frame number with a larger number: $content = "<frame> [b]0[/b] .... pic: 0 state: 0 wait: 9 next: [b]1[/b] dvx: 0 dvy: 0 dvz: 0 ... <frame_end> <frame> [b]1[/b] ... pic: 1 state: 0 wait: 3 next: [b]2[/b] dvx: 0 dvy: 0 dvz: 0 centerx: 26 centery: 77 hit_a: 0 hit_d: 0 hit_j: 0 hit_Fa: 260 hit_Da: 240 .............. ................ <frame_end>"; $content = preg_replace("\\<frame\>\s(*.?)\s", "$1+1", $content); the line at the bottom is what I have tried so far, the number in bold is what I want to add 1 on to, ... represents any content. Thanks!
-
Hi, I have multiple content that i wish to capture, so im using preg match all: $content1 = '......<a href="/users/blog.php?user=ted_chou12&id=48" class="readmore">Read more</a> <a href="/users/blog.php?user=ted_chou12&id=48#comments" class="comments">Comments (0)</a> ....<a href="/users/blog.php?user=ted_chou12&id=47" class="readmore">Read more</a> <a href="/users/blog.php?user=ted_chou12&id=47#comments" class="comments">Comments (0)</a>... <a href="/users/blog.php?user=ted_chou12&id=46" class="readmore">Read more</a> <a href="/users/blog.php?user=ted_chou12&id=46#comments" class="comments">Comments (0)</a>........... preg_match_all("/<a\shref=\"\/users\/blog\.php\?user=ted_chou12\&id=(.*?)\"\sclass=\"readmore\">Read\smore<\/a>/s", $content1, $pagearray, PREG_PATTERN_ORDER); I wish to get the id numbers into an array, but this code only seems to get one: ideal output: 48,47,46... real 48 (only) so how should I change it to output all the id numbers in the content, Thanks, Ted
-
Hi, I was wondering how I can detect the browser to see whether if or not the machine is a pocket pc or smartphone thus to display the page otherwise. I tried searching it in Google, but the first results don't seem to be very relavent at all. I am thinking to catch it by useragents php curl useragent function or something, but i searched for ppc useragent strings, there are tonnes of them, so i don't think that this is a very effective way, as well as that, there doesn't seem to be a generic term at all. And wat if the browser includes some random string thats called "ppc" or "smartphone" on the computer, it would probably look weird. So I am wondering if there are other approaches with higher accuracy and more efficiency. Thanks, Ted
-
thanks!
-
hi, if i have two tables: idtitledate 1atoday 2[b today numbertitledate 1cyesterday 2dtoday if i want to echo out a table like: titledate atoday btoday dtoday only entries that are from "today" and the columns of two tables are not necessary the same or the same no. or columns. So far I tried join and left join, but things seems to come out as multiples, dont know why, if you need more inforamtion, please let me know, thanks, Ted
-
[SOLVED] TIMESTAMP to get results more than two days
ted_chou12 replied to ted_chou12's topic in MySQL Help
yeap, i think that's exactly what im looking for -
Hi, I wish to grab data that is greater than two days, but the query i attempted doesn't seem to be correct: select * from table where TIMESTAMP(signupdate) < TIMESTAMP(-2days) Thanks, Ted
-
Thanks, I see, then ill stick with explode() and use count ps. im trying to read the directory file, cause this file has two extensions, so i was thinking if strstr could give a better result then multiple functions combined, thanks
-
Hi, I seem to be confused about the strstr function, eg. i have a string like: "a.b.c.d.e.f" "a.b.c.d.e" I always want it to split at the second "." from the end, so resulting in: "e.f" "d.e" respectively etc... Please feel free to ask me if you don't understand. Thanks,
-
nope thanks, i found out it is a weird problem of chrome, they do not display the font less than 12px correctly.
-
Hi, I have a script that works in ie, ff when you change the font size but not in chrome, i wonder if other people have experienced it too: <div class="menu"> <ul id="nav"> <li class="first" style="width:53px;"> <a href="/users/index.php">INDEX<!--[if IE 7]><!--></a><!--<![endif]--> <!--[if lte IE 6]><table><tr><td><![endif]--> <ul> <li><a href="/users/profiles.php?user=<?php echo $username;?>">View My Profile</a></li> <li><a href="/users/editprofile.php">Edit My Profile</a></li> <li><a href="/users/editaccount.php">Edit My Account</a></li> <li><a href="/users/editpreference.php">Edit Preferences</a></li> <li><a href="/users/friends.php">My Friends Lists</a></li> </ul>...//continues on and the css code is here: <style type="text/css"> */ .menu { width: 770px; font-size: 11px;//changing this.********** position: relative; z-index: 100; white-space: nowrap; padding: 1px 0px 1px 0px; } /* remove all default list styling */ .menu ul { padding: 0px; margin: 0px; list-style-type: none; } .menu ul#nav { margin: 15px 0 0 0; } /* float the list to make it horizontal relative positon so that you can control the dropdown menu positon */ .menu li { float:left; position: relative; /* space between buttons */ margin-left: 2px; } .menu .first { margin-left: 0px; } .menu .last { margin-right: 0px; } /* FIRST-LEVEL NORMAL *********************************************************/ .menu a, .menu a:visited { display: block; font-size: 11px;// and changing this ***** text-decoration: none; text-align: center; font-weight: bold; background-image: url('nav_top_backg_off.gif'); background-color: #B6D3F7; color: #2B449C; height: 15px; padding-left:5px; padding-right:5px; padding-top:3px; padding-bottom:2px } Changing them changes the font size in all other browsers except for chrome, i dont understand why, please let me know if these pieces of the code is not enough. Ted