mikepuerto
Members-
Posts
13 -
Joined
-
Last visited
Never
Everything posted by mikepuerto
-
and rtrim worked PERFECTLY! Thank for the help guys!
-
Yes, the file exists... Just using a querystring to get it... The file looks like: [code] 1068 1092 1093 1097 1098 1099 1147 1220 1326 1386 [/code] and yes, $lines is correct... The script appears to run flawlessly, i get no errors! And to answer your question about my echo's out put, yes it looks perfect! This is what the output looks like: [code] 1068 deleted 0 1092 deleted 1 1093 deleted 2 1097 deleted 3 1098 deleted 4 1099 deleted 5 1147 deleted 6 1220 deleted 7 1326 deleted 8 1386 deleted 9 [/code] The first number is obviously the "id" that identifies the row i want to disappear. At first i thought i actually removed a record... But it's actually not doing anything at all... Could this be some sort of mysql config parameter that only allows for a single DELETE to be used at once or something?
-
Can anyone tell me why this code will only delete 1 row? there are about 2000 lines in the "$file" that i'm cross referencing to delete the rows... Please help! this is driving me nuts! [code] $file = $_GET['file']; $lines = file($file); $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to the database'); mysql_select_db($dbname); foreach ($lines as $line_num => $line) { $query = "DELETE FROM largo1 WHERE id='$line'"; $result = mysql_query($query); echo "$line deleted $line_num<br>"; } mysql_close($conn); [/code]
-
anyone have any idea?
-
The id column contains an auto_increment id. Each line of the file contains an ID that exists in the table. Therefore $line is the ID that I'm trying to delete. Not thinking about it very much i changed id="$line_num" resulting in the deletion of a a bunch of rows that i did not want to delete. I have figured out that the script works. but it does not actually loop. It only deletes one.
-
i took your suggestion on the db connection and select but... actually $line_num is the row number. $line is the data that i'm trying to use to delete the row...
-
Can anyone give me an idea as to why this does not work? I dont get any errors and it seems to run fine but does not delete the rows... [code] $file = $_GET['file']; $lines = file($file); foreach ($lines as $line_num => $line) { $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to the database'); mysql_select_db($dbname); $query = "DELETE FROM largo1 WHERE id='$line'"; $result = mysql_query($query); echo "$line deleted<br>"; } mysql_close($conn); [/code]
-
trying to show how many users are in each zip code that was plotted on the map.... everything work PERFECTLY! thank you VERY, VERY MUCH!
-
GROUP BY z.zip worked perfectly. I just cant figure out how to tell how many times a zip code was present(in each "group")... I tried using COUNT but nothing(probably incorrect syntax) this is what i tried: [code] $result = mysql_query("SELECT COUNT(lt.zip), z.lon, z.lat FROM $listTable lt, zipcode z WHERE lt.redeemed = 'Y' AND z.zip = lt.zip GROUP BY z.zip"); echo "$row['COUNT(zip)']'; [/code] Again, THANKS FOR THE HELP!
-
That worked beautifully! ;D one more question thing(sorry)... As you could probably see from before i am using the google maps API to plott these things on a map... Some of the users have the same zip code, so i dont want to have to plot the same zip more than once. is there an easy way to prevent this but at the same time use something like "mysql_num_rows" to determine how man rows that zip code was present? So that i could then replace: [code]echo "var marker = createMarker(point, '<div id=\"infowindow\" style=\"white-space: nowrap;\">" . addslashes($row['zip']) . "</div>');\n";[/code] with something like: [code]echo "var marker = createMarker(point, '<div id=\"infowindow\" style=\"white-space: nowrap;\">" . addslashes($row['zip']) . "appeard $numOfRowsZipAppeared</div>');\n";[/code] thanks for all of your help! :) -mike
-
and you were right: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in i dont understand this... what it "lt."? "z." etc? is this a join? SELECT lt.*, lt.zip as lzip, z.* FROM $listTable lt, zipcode z WHERE lt.redeemed = 'Y' AND z.zip=lt.lzip
-
This code is terrible... i know. i just can't figure out how to do it with one loop. [code] $result = mysql_query("SELECT * FROM $listTable WHERE redeemed = 'Y'"); while ($row = mysql_fetch_array($result)) { $resultZipcode = mysql_query("SELECT * FROM zipcode WHERE zip = " . $row['zip']); $row2 = mysql_fetch_array($resultZipcode); } foreach ($row2 as $key => $value) { echo "var point = new GPoint(-" . $row['lon'] . "," . $row['lat'] . ");\n"; echo "var marker = createMarker(point, '<div id=\"infowindow\" style=\"white-space: nowrap;\">" . addslashes($row['zip']) . "</div>');\n"; echo "map.addOverlay(marker);\n"; echo "\n"; } } [/code]
-
Hello! Hoping for a little help! I have a table that has user information(name, addr, zip, etc) stored in it and if a user has completed somthing a value of "Y" gets added to their row in the column "redeemed". I have another table that houses only zip codes and lattitude/longitude for every us zip code. what i am trying to do is query the database for any user that has a "Y" using: [code]$result = mysql_query("SELECT * FROM $listTable WHERE redeemed = 'Y'");[/code] and then load the zip code for each user into an array. I then want to query the database to get the lattitude/longitude for every zip code in the array from the zipcode table using: [code]$resultZipcode = mysql_query("SELECT * FROM zipcode WHERE zip = " . $row['zip'] ."LIMIT 1");[/code] and display something like: [code]echo "the lattiitude and longitude for the zip code $zip is $lat $lon";[/code] I have tried using using a foreach and a while loop, i can get the zip code to output with the while loop but can not get the lat/long - it's driving me crazy! thanks in advance! -mike