Jump to content


savagenoob

Member Since 19 Dec 2008
Offline Last Active Dec 02 2012 08:05 PM

Topics I've Started

2 Part Problem

02 December 2012 - 01:08 PM

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

Print each array element on new line

20 February 2012 - 06:06 PM

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.

JQuery: Cant Find Error with Code

13 February 2012 - 02:33 PM

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.

Array foreach skipping every other entry

10 February 2012 - 02:35 PM

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.

stdClass Object Multi Dimensional Array

29 January 2012 - 11:46 PM

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.

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com