Jump to content

savagenoob

Members
  • Posts

    332
  • Joined

  • Last visited

Everything posted by savagenoob

  1. OK, fixed the "C" problem, just changed $class[] = $_POST['class'][0][0]; to $class[] = $_POST['class'][0]; Still not searching via dates correctly.
  2. I have a set of checkboxes on a form that I pass to php using an array as the name such as: <input name="class[]" type="checkbox" value="C-15" /> Flooring I then loop through this array, and modify the database based on the selections and the date range. Part 1 Problem: the first loop shows the value correctly as "C-15", but second loop and further only shows "C" and cuts off the "-15"; $user = $session->username; if(isset($_POST['carrier'])){ $carrier = $_POST['carrier']; $class[] = $_POST['class'][0][0]; $date1 = $_POST['date1']; $date1 = date("Y-m-d 00:00:00", strtotime($date1)); $date2 = $_POST['date2']; $date2 = date("Y-m-d 23:59:59", strtotime($date2)); foreach( $class as $key){ $query = "SELECT * FROM leads WHERE class1 = '$key' OR class2 = '$key' OR class3 = '$key' OR class4 = '$key' OR class5 = '$key' OR class6 = '$key' OR class7 = '$key' OR class8 = '$key' OR class9 = '$key' OR class10 = '$key' OR class11 = '$key' OR class12 = '$key' AND user = '' AND wccompcode = '$carrier' AND wcxdate BETWEEN '$date1' AND '$date2' LIMIT 100"; $sellead = mysql_query($query)or die(mysql_error()); echo $query; while($leads = mysql_fetch_array($sellead)){ $rowid = $leads['ID']; $update = mysql_query("UPDATE leads SET user = '$user' WHERE ID = '$rowid'")or die(mysql_error()); } } } Problem 2: it is ignoring my between date and modifying rows with a wcxdate of anything. Any ideas? This is my echo: SELECT * FROM leads WHERE class1 = 'C-8' OR class2 = 'C-8' OR class3 = 'C-8' OR class4 = 'C-8' OR class5 = 'C-8' OR class6 = 'C-8' OR class7 = 'C-8' OR class8 = 'C-8' OR class9 = 'C-8' OR class10 = 'C-8' OR class11 = 'C-8' OR class12 = 'C-8' AND user = '' AND wccompcode = '25' AND wcxdate BETWEEN '2013-01-01 00:00:00' AND '2013-01-01 23:59:59' LIMIT 100SELECT * FROM leads WHERE class1 = 'C' OR class2 = 'C' OR class3 = 'C' OR class4 = 'C' OR class5 = 'C' OR class6 = 'C' OR class7 = 'C' OR class8 = 'C' OR class9 = 'C' OR class10 = 'C' OR class11 = 'C' OR class12 = 'C' AND user = '' AND wccompcode = '25' AND wcxdate BETWEEN '2013-01-01 00:00:00' AND '2013-01-01 23:59:59' LIMIT 100
  3. I am trying to break down an array to make it easier to read. An array that looks like Array ( [0] => 0 [1] => 0 [2] => 0 [3] => 0012844 1 [4] => 37 [5] => 1 etc...) I want to display it like: [0] => 0 [1] => 0 [2] => 0 etc... how can this be accomplished.
  4. Nevermind. I see it. Dummy.
  5. I wrote this: <script type="text/javascript" charset="utf-8"> function getFiles(){ var agencyid = "<?php echo $agencyid;?>"; var carrier = "<?php echo $carrier;?>"; $.ajax({ type: "POST", url: "ajax/getfiles.php", data: "carrier="+ carrier + "&agencyid="+agencyid, success: function(html){ $("#filelist").append(html); } }); } $(document).ready(function(){ setInterval(getFiles(), 30000); } </script> and am getting firebug error that says: "missing ) after argument list", which points to the closing of the Ajax call, }); Dont know what I am doing wrong.
  6. damn, thats wierd, the ajax is returning all the data correctly. Now what?
  7. And I do strip_tags() on all the data and values prior to the foreach loop...
  8. Thats where its a bit complicated. I cant view source, I am using jQuery ajax with a jQuery paginator/search table. I am stripping tags on the table rows as they display I just omitted for ease of read.
  9. Yeah, it looks as it should.
  10. I have this code: $data = array_combine($data4, $addfinal); foreach( $data as $key => $value){ ?> <tr> <td><?php echo $key;?></td><td><?php echo $value; ?></td><td></td><td>Safeco</td><td><a href="ajax/map.php?address=<?php echo urlencode($value);?>">Map It</a></td> </tr> <?php } That uses an array that looks like this (but longer): Array ( [business Name 1] => Business Address 1 [business Name 2] => Business Address 2 [business Name 3] => Business Address 3) But it skips every other array entry? Any ideas? So its displaying Business Name 1, Business Name 3, etc.
  11. I have a stdClass Object Multi Dimensional Array that I need to dissassemble into variables but dont know how to pull the data. The array looks like this: stdClass Object ( [results] => Array ( [0] => stdClass Object ( [address_components] => Array ( [0] => stdClass Object ( [long_name] => 1600 [short_name] => 1600 [types] => Array ( [0] => street_number ) ) [1] => stdClass Object ( [long_name] => Pennsylvania Ave NW [short_name] => Pennsylvania Ave NW [types] => Array ( [0] => route ) ) [2] => stdClass Object ( [long_name] => Northwest Washington [short_name] => Northwest Washington [types] => Array ( [0] => neighborhood [1] => political ) ) [3] => stdClass Object ( [long_name] => Washington [short_name] => Washington [types] => Array ( [0] => locality [1] => political ) ) [4] => stdClass Object ( [long_name] => District of Columbia [short_name] => DC [types] => Array ( [0] => administrative_area_level_1 [1] => political ) ) [5] => stdClass Object ( [long_name] => United States [short_name] => US [types] => Array ( [0] => country [1] => political ) ) [6] => stdClass Object ( [long_name] => 20500 [short_name] => 20500 [types] => Array ( [0] => postal_code ) ) ) [formatted_address] => 1600 Pennsylvania Ave NW, Washington, DC 20500, USA [geometry] => stdClass Object ( [location] => stdClass Object ( [lat] => 38.8987149 [lng] => -77.0376555 ) [location_type] => ROOFTOP [viewport] => stdClass Object ( [northeast] => stdClass Object ( [lat] => 38.900063880291 [lng] => -77.036306519708 ) [southwest] => stdClass Object ( [lat] => 38.897365919709 [lng] => -77.039004480291 ) ) ) [partial_match] => 1 [types] => Array ( [0] => street_address ) ) ) [status] => OK ) Really I need to start with pulling the lat and lng from the location. No clue how to get to this data.
  12. I am doing a jQuery autocomplete and based on the click of the user would like to call another function using that value. Here is my jQuery: $(function() { function log( message ) { $( "<div/>" ).text( message ).prependTo( "#inputString" ); $( "#inputString" ).scrollTop( 0 ); } $( "#inputString" ).autocomplete({ source: "ajax/search.php", minLength: 1, select: function( event, ui ) { log( ui.item ? "Selected: " + ui.item.value : "Nothing selected, input was " + this.value ); } }); }); and once the user clicks on a selection from the autocomplete use that value to call a function called showCar(value); Ive tried placing this function in the above code and it messes up the autocomplete.
  13. I have an address in a variable, I pass this address to a google maps page/function that geocodes it and returns the street view. Heres an example of a link: <a href="mapget.php?address=<?php echo urlencode(strip_tags($comaddress));?>" name="mapit">Map It</a> The address' come from either a curl or dom request so I have been trying to strip and trim them as much as possible but the urls come out looking like... www.mysite.com/mapget.php?address=7855+N+SOMESTREET+AVE+SOMECITY++++++++++++++++++++++%2C+CA+11111 My maps only seem to be getting the street... I am using urldecode($address) on the receiving page and when I echo $address on the receiving page it looks completely correct. Any ideas?
  14. I read the json_encode manual (duh) and saw there is a JSON_FORCE_OBJECT option that removes the square brackets, but when I run it against my array it doesnt display at all... any help? <?php require_once ('includes/config.php'); require_once ('includes/connect.php'); $agency= mysql_query("SELECT agencyname, busphone FROM agency WHERE status ='Prospect' ORDER BY agencyname DESC")or die(mysql_error()); while($ageinfo = mysql_fetch_assoc($agency)) { $output[] = $ageinfo; } print(json_encode($output, JSON_FORCE_OBJECT)); ?>
  15. Yeah, I figured. I was wondering if there was a way to remove the brackets before the print.
  16. Using Java... import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import java.util.HashMap; import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; import org.apache.http.client.HttpClient; import org.apache.http.client.entity.UrlEncodedFormEntity; import org.apache.http.client.methods.HttpPost; import org.apache.http.impl.client.DefaultHttpClient; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import android.util.Log; public class JSONfunctions { public static JSONObject getJSONfromURL(String url){ InputStream is = null; String result = ""; JSONObject jArray = null; //http post try{ HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost(url); HttpResponse response = httpclient.execute(httppost); HttpEntity entity = response.getEntity(); is = entity.getContent(); }catch(Exception e){ Log.e("log_tag", "Error in http connection "+e.toString()); } //convert response to string try{ BufferedReader reader = new BufferedReader(new InputStreamReader(is,"iso-8859-1"),; StringBuilder sb = new StringBuilder(); String line = null; while ((line = reader.readLine()) != null) { sb.append(line + "\n"); } is.close(); result=sb.toString(); }catch(Exception e){ Log.e("log_tag", "Error converting result "+e.toString()); } try{ jArray = new JSONObject(result); }catch(JSONException e){ Log.e("log_tag", "Error parsing data "+e.toString()); } return jArray; } }
  17. I am writing a simple connector for an android application and my json_encode is outputting enclosing the array with []. This is throwing an error during the decode process because the array needs to start with a {. I know this has to do with the $output[] in the loop, but I dont know how to pass the values into the array any other way. I even tried to trim after doing the encode. Here is my code: <?php require_once ('includes/config.php'); require_once ('includes/connect.php'); $agency= mysql_query("SELECT agencyname FROM agency WHERE status ='Prospect' ORDER BY agencyname DESC")or die(mysql_error()); while($ageinfo = mysql_fetch_assoc($agency)) { $output[] = $ageinfo; } print(json_encode($output)); ?>
  18. OK, I am displaying text fields from entries in a database, and want to update all the fields within the loop if the user hits Update. <table class="tablesorter"> <form action="<?php echo $_SERVER['PHP_SELF'];?>" method="POST"> <input type="hidden" value="<?php echo $agencyid; ?>" name="agencyid" /> <tr><h2>Appointments</h2></tr> <?php $select = mysql_query("SELECT * FROM appointment WHERE agencyid = '$agencyid'")or die(mysql_error()); while($appinfo = mysql_fetch_array($select)){ ?> <input type="hidden" value="<?php echo $appinfo['ID']; ?>" name="<?php echo $appinfo['ID']; ?>" /> <tr> <th>Carrier: </th><td><?php echo $appinfo['carrier'];?></td><th>Agency Code: </th><th><input type="text" value="<?php echo $appinfo['agentcode'];?>" size="15" maxlength="20" name="agencycode<?php echo $appinfo['ID']; ?>" tabindex="1" /></th> </tr> <?php } ?> <tr><th><input type="submit" value="Update" name="updateapp" tabindex="2" /></th></tr> </form> </table> I cant figure out an easy way to build a query off of the data once its submitted. Maybe a foreach loop on the POST then update as necessary? I cant wrap my mind around it.
  19. I know that, but thats not the issue at hand. It is correct on my side but the second word is still getting truncated.
  20. I am passing an array to an option list but if a value has two words, the second word doesnt get sent via POST. So if the value should be THE ONE, the word ONE doesnt get sent via POST. Kinda wierd, wondered if there is an easy explanation for this? <?php echo '<SELECT name=carrier>'; foreach ($allcar as $key => $value) { echo '<OPTION value=' . $value . '> ' . $value . ''; } echo '</select>'; ?>
  21. Damn, your right, so like the 15th then do - 1 month.
  22. OK, since today is the 31st, I guess I figured out that strtotime("-1 Month') really only goes back 30 days, so where I think it should be September, its registering October 1st. Is there a fix for this? $month = date('F Y', strtotime("-1 month")); $month1 = date('F Y', strtotime("-2 month")); $month2 = date('F Y', strtotime("-3 month")); $month3 = date('F Y', strtotime("-4 month")); $month4 = date('F Y', strtotime("-5 month")); $month5 = date('F Y', strtotime("-6 month"));
  23. Oh sweet, thanks bud.
  24. Hm, can I put a wildcard after Fax: ? It will list the fax number after Fax: and I believe this is explicitly looking for "Fax:" not "Fax: (111) 111-1111"
×
×
  • 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.