user1022585

1

votes
0

answer
38

views

Python - Sorting huge array into multiples

I'm working with a map of which is split up into 750 x 750 numbered tiles. These are stored in a JSON file. My aim is to pull the data and split each tile into separate arrays / chunks. I already have it working, but I'm a python beginner and the code is really slow (it is handling 500,000+ numbers)...
user1022585
17

votes
4

answer
116.8k

views

javascript popup alert on link click

I need a javascript 'OK'/'Cancel' alert once I click on a link. I have the alert code: But how do I make it so this only runs when clicking a certain link?
user1022585
5

votes
3

answer
12.7k

views

jquery add onmouseover attribute

in jquery, how do I add an 'onmouseover' event to an element. eg becomes
user1022585
5

votes
2

answer
31.6k

views

jquery background color change on button click

Why doesnt this work? jquery $("#button").click(function(){ $("go").css("background-color","yellow"); }); html hello
user1022585
2

votes
2

answer
1.6k

views

jquery span tag

In my code I have this: which displays the data in the screen id, obviously. But when I change it to: or it shows nothing. Go easy on me i'm a rookie. additional info this is in my script tag in the head section: function update() { $.post("chat_new_serv.php", {}, function(data){ $("#screen").val(da...
user1022585
2

votes
3

answer
2.7k

views

php check if array values are consecutive

I have an array $dice (4,7,3,6,7) I need a way of checking if each of the values in that array are consecutive numbers. Is there an easy method of doing this?
user1022585
2

votes
2

answer
107

views

mysql select based on a SUM

I need to do a mysql query but Im not sure how to go about it. I want to select rows that are greater than the php value of $x, by adding 2 of the table fields together (after dividing them). The pseudo code: SELECT * FROM table WHERE (field_a/50 + field_b/20) > $x The $x is a php value, its just t...
user1022585
2

votes
1

answer
49

views

Css - Need 'triple' border

I have this css: border: 2px solid #00ff60; outline: 1px solid #000; outline-offset: 0px; Which produces this: How can I adjust it to also have an inner black border like at the bottom? EDIT: sorry forgot to add, I want to apply this style to an image.
user1022585
3

votes
4

answer
7.4k

views

javascript onclick repeat

I have a form button with an onclick event that runs a simple javascript function (adds 1 to a value). I have to click the mouse button each time for this to run, is there any way of making it so if the mouse button is held down it runs it too, but every half a sec? CURRENT CODE function incrementVa...
user1022585
5

votes
7

answer
105k

views

javascript onclick increment number

With javascript, how can I do it so when i click a form button it adds 1 to a number? The number it increments could be in a form text field or something. Obviously it'd be on onclick but I'm not sure of the code.
user1022585
2

votes
2

answer
9.7k

views

mysql now() function

What's the SQL way of doing this: $now = date('Y-m-d H:i:s', time()) SELECT * FROM table WHERE '$now' > time Is it: SELECT * FROM table WHERE now() > time
user1022585
2

votes
3

answer
220

views

php sql drop rate system

This question might seem a bit bizarre, but... I run a mafia style game site scripted in PHP. When players do crimes, theres a chance they'll get a 'drop', lets say a new weapon. How I have it working at the moment is each crime they do, I run a rand() out of 10, and if it hits 10 then I randomly s...
user1022585
2

votes
1

answer
846

views

php find out if array contains values of over 0?

Without looping through each value in an array, is there any shortcut to checking whether it contains values over 0? Eg array(3,0,0) would be TRUE array(0,0,0) would be FALSE array(-2,0,-3) would be FALSE
user1022585
6

votes
2

answer
9.9k

views

jquery variable in function

On pageload I set a variable $(document).ready(function() { var inv_count = 3; }); When I try to refer to that variable inside functions though, it doesn't work. function blah(a,b) { alert (inv_count); } Why is this? And how can I get around it? (rookie here)
user1022585
2

votes
3

answer
4.7k

views

mySql join - multiple records from same table

Im looping through a list of forum posts, pulling the data from 2 tables, posts and members. I'm using a LEFT JOIN like SELECT m.name, p.title FROM posts LEFT JOIN members m ON p.poster=m.id That all works fine. But I also need to pull a different record from the members table, that of the p.lastpos...
user1022585
2

votes
1

answer
87

views

sql combine 2 queries with JOIN

I know it's not a good idea to loop SQL queries, so I would like to change these two queries into one. Not being too great at JOINs, I'm struggling to figure how to merge these two, with it having that DISTINCT in there. $sql_result2 = mysql_query("SELECT DISTINCT gang FROM turfs WHERE city='$city'"...
user1022585
2

votes
3

answer
70

views

Working with array value instances

I'm making a simple yahtzee script in PHP, I've got up the final point where it checks the 5 dice for a result at the end. The 5 dice sides are stored in an array, example $dice (2,5,2,7,8) I'm not that experienced in working with arrays, but is there easier ways to compare each number, to like find...
user1022585
2

votes
4

answer
244

views

SQL query exclude phrasing

I'm having trouble with a SQL query, I can't think how to phrase it. It's to pull a count of events from a log since you last checked it. Currently I have this: SELECT COUNT(*) AS alertcount, date AS alertdate FROM alerts WHERE to_id = '$id' AND date > '$lastcheck' But, I want it to exclude all fi...
user1022585
2

votes
3

answer
638

views

jquery popup find true top

I have a jquery popup script, and to center the popup on the screen the code is this: function centerPopup(){ var windowWidth = document.documentElement.clientWidth; var windowHeight = document.documentElement.clientHeight; var popupHeight = $(".popupContent").height(); var popupWidth = $(".popupCon...
user1022585
1

votes
4

answer
6.7k

views

CSS for disabled form input

I have this in my CSS file that styles input fields in a form: input,textarea,input,select,input,checkbox { font-size:12px; font-family:Verdana,Arial,Helvetica,sans-serif; color:#98925C; background-color:#000; border:1px solid #413E22; } When I use a disabled on the form though (eg the submit button...
user1022585
4

votes
4

answer
29.8k

views

HTML flashing text colors

This is quite an unusual request, but.. Is there anyway to make some text alternate between 2 colors every second? So it appears as though it's flashing between say... red and grey? I don't mean background color, I mean the actual font color. I'm assuming it would need javascript or something. Is th...
user1022585
2

votes
4

answer
2.3k

views

php convert number into minutes

Say i have a variable like $speed = 5.5, what formula would I use to convert that into minutes, so in this case it would be 5 and a half minutes. I need it to work in this: date("Y-m-d H:i:s", strtotime("$now - $speed mins")); Other examples, 2.25 would convert to 2 mins 15 secs, 7:75 to 7 mins 45...
user1022585
3

votes
3

answer
48

views

php array - search for random key where value is over 0

I have a php array that's made up of random numbers from 0-100. I'm trying to figure out the cleanest and simplest method of picking a random key from that array that is greater than zero. Ultimately I'm looping through the array, subtracting a value from random keys each loop Pseudo code: $num_arra...
user1022585
3

votes
5

answer
34.1k

views

javascript redirect to new window

I have this code that redirects to a page based on the value of a dropdown list: function goto(form) { var index=form.select.selectedIndex if (form.select.options[index].value != "0") { location=form.select.options[index].value;}} //--> How do I make that open in a new window?
user1022585
1

votes
4

answer
154

views

mysql php security

On my php pages, at the top i connect to the database like this $db = mysql_connect("mysql.site.com","thedb", "pass"); mysql_select_db("dbase",$db); Is this secure? Could someone somehow scan and view my code, therefore get access to the database? UPDATE Reason I ask is because a user was able to...
user1022585
14

votes
6

answer
52.7k

views

jquery function on dropdown select

I need to run a jquery function if a certain dropdown option is selected. option 1 option 2 I have the commands in the function ready, Im just not sure on how to make it so if option 2 is currently active in the dropdown, then run the function. (dropdown doesnt have a submit button, i want it ran wh...
user1022585
1

votes
1

answer
18

views

mySQL get row twice if field = this

I'm pulling a list of names from a mySQL table called users with the layout something like this; id name anon -------------------------------- 1 Roger 0 2 Craig 1 3 LOL 0 For users where anon=1 I want to pull them twice, so the records I'd get from the above table would be...
user1022585
5

votes
2

answer
1.6k

views

mysql sort field increment value

Say I have a table name rank ----------------------- John 1 Tit 3 Bernard 4 Rank 2 is missing, could have been deleted or whatever. I need a query to increment the rank field. So John would be number 1, but Tit would now be number 2, and Bernard 3. There...
user1022585
3

votes
2

answer
211

views

UPDATE mysql max value

I have a field in my database that I don't want to exceed 100. Is there something in a query I can add to make sure it doesn't? I usually end up doing this: UPDATE table SET field = field + $x UPDATE table SET field = 100 WHERE field > 100 Does anything like this exist?
user1022585
2

votes
5

answer
5.8k

views

image darken/opacity

A quickie, is it possible to have an image darkened using javascript or something? I don't need it on mouseovers or anything, just for the image to appear disabled (could I change the opacity of it using a style tag even?). How would I do?
user1022585
48

votes
18

answer
92.9k

views

php random x digit number

I need to create a random number with x amount of digits. So lets say x is 5, I need a number to be eg. 35562 If x is 3, then it would throw back something like; 463 Could someone show me how this is done?
user1022585
4

votes
5

answer
465

views

php remove one item from array

Say I have an array: $before = array(1,2,3,3,4,4,4,5) How would I remove just one occurence of eg '3' ? $after = array(1,2,3,4,4,4,5) (I don't know where in the array that number will be)
user1022585
3

votes
1

answer
70

views

php/javascript user info collecting

I believe some users on my site are using IP masks to create more than one account. Due to the nature of my site/game it's against the rules and I need to remove players like this. I currently track their IP, host, browser type and such with PHP, I also use javascript/jquery to get their screen size...
user1022585
63

votes
7

answer
75.6k

views

Find records with a date field in the last 24 hours [duplicate]

This question already has an answer here: MYSQL Datetime getting a date extract one month back 4 answers In my SQL query how do i make it find the records in the last 24 hours? Eg SELECT * FROM news WHERE date < 24 hours I usually do it by setting a variable to date() - 1 day and comparing it to th...
user1022585
2

votes
0

answer
252

views

browser game map

I'm making a browser based game, and need to have a map page where a player can move around and go to different locations. Currently it loads each tile in your view (about 8x8) from the database, each time you move. It's probably not a good way. I want a map about 2000x2000 pixels, but in a small w...
user1022585
4

votes
3

answer
7.6k

views

PHP sql security

I use mysql_real_escape_string() on my variables, but looking through my logs I noticed a stream of input from someone with entries like this: ${@print(md5(acunetix_wvs_security_test))} 1\" or (sleep(4)+1) limit 1 -- and so on. A huge list of them. Is he just attempting and nothing happening? Or is...
user1022585
1

votes
1

answer
57

views

Global var editing from another script in Python

I'm trying to increment a python global var from another script, but it doesn't seem to be updating. Am I doing something wrong here? I run func() multiple times during the script execution and it never seems to update globVal script 1: def func(): from script2 import globVal global globVal print "g...
user1022585
1

votes
3

answer
352

views

dict changed size during iteration, but not editing it in Python

I'm getting the dict changed size during iteration error in Python even though I'm not altering the nested dict. I'm deleting from the original, not the copy that I'm looping through test = arr.copy() for map in test: for mID in test[map]: #here is dictionary changed size during iteration v = test[...
user1022585
2

votes
1

answer
65

views

PHP / Math - Getting grid values

So this might be quite bizarre, but... Imagine a grid of 10x10, each numbered left to right, top to down, starting at 1 and ending in 100. I want to input a grid number ($plot) and get each grid number that surrounds it. I started by making an array: $plot = 45; $arr = array( $plot-11, $plot-10, $pl...
user1022585
1

votes
4

answer
396

views

Javascript increment value faster with mouse hold [duplicate]

This question already has an answer here: Incrementing value continuously on mouse hold 4 answers I have this script that adds 1 to a value every time I click on a button: function incrementValue(id) { var value = parseInt(document.getElementById(id).innerHTML); value = value + 1; document.getEleme...
user1022585

View additional