Jump to content

Help , i am at a lost


DeanWhitehouse

Recommended Posts

I have not asked for help in coding for a while now , but i am really stuck on this one.

 

I have the below code which checks each submitted checkbox against the database , then if there is a conflict (where the person already booked time in that area in that time) they get redirected, but the problem i am having is that i dont know how to work with checkboxes.

 

This is the code, i explained quite badly , so you will probably work out more from the code.

 

<?php
if(isset($_POST['submit2']))
{
$price = $_POST["grandtotal"];

if(isset($_SESSION["email"]))
{
	$frmemail = $_SESSION["email"];
}
else
{
	echo "Error. Please login again.";
	header("Location:home-pub.php?logout");
}
$now = date("d/m/Y");
$next = date('d/m/y', strtotime("+1 year"));

if($price == 0 || strlen($price) == 0)
{
	echo "Invalid price";
}
else
{
	$county = array();
	$county = array(150);
	$m = 0;
	for($i=0;$i<120;$i++) 
	{
   		$checkbx = isset($_POST['countybox' . $i]);
		if ($checkbx != '') 
		{
			  $county[$m] = $checkbx;
			  $m++;
		}
	}	
$now = date("d/m/Y");
$next = date('d/m/Y', strtotime("+1 year"));
	foreach($county as $count)
	{
		$query = "SELECT * FROM Payments WHERE Region='".$count."' AND location='WEBSITE'";
		$mysql = mysql_query($query);
		echo $count;
		while($rw = mysql_fetch_assoc($mysql))
		{
			$startdate = date("d/m/Y",strtotime($rw['periodstart']));
			echo $startdate;
			$enddate = date("d/m/Y",strtotime($rw['periodend']));
			//if($startdate =< $now
		}
	}
      }	
}
?>

 

Then the form

<form method="post" action="" name="timereg" onSubmit="return verifyRegister(this.form)">
<?php
$now = date("d/m/Y");
$next = date('d/m/Y', strtotime("+1 year"));
?>
<p class="para">Please choose the areas you would like to appear in below, for a one year listing period (<?php echo $now." - ".$next;?>).</p>
<input type="hidden" value="<?php echo $now;?>" name="1yrstartdate">
<input type="hidden" value="<?php echo $next; ?>" name="1yrenddate">
<input value="<?php echo $rows['companyname'];?>" type="hidden">

<table border="1" cellpadding="4" cellspacing="0" width="440" style="border-collapse:collapse; BORDER: 1px #aa9498; border-style: solid; margin-top: 0px; margin-bottom: 16px;margin-left: 4px;"><tr><td style="BORDER: 1px #aa9498; border-style: solid; padding: 6pt;" bgcolor="#ffffe1">

<input type="checkbox" name="countyboxENGLAND" value="NA" onClick="englandCheck()"> <b>England</b><br><br>
<input type="checkbox" name="countybox1" value="Bedfordshire" onClick="countyCount(this)"> Bedfordshire<br>
<input type="checkbox" name="countybox2" value="Berkshire" onClick="countyCount(this)"> Berkshire<br>
<input type="checkbox" name="countybox3" value="Buckinghamshire" onClick="countyCount(this)"> Buckinghamshire<br>
<input type="checkbox" name="countybox4" value="Cambridgeshire" onClick="countyCount(this)"> Cambridgeshire<br>
<input type="checkbox" name="countybox5" value="Cheshire" onClick="countyCount(this)"> Cheshire<br>
<input type="checkbox" name="countybox6" value="Cornwall" onClick="countyCount(this)"> Cornwall<br>
<input type="checkbox" name="countybox7" value="Cumberland" onClick="countyCount(this)"> Cumberland<br>
<input type="checkbox" name="countybox8" value="Derbyshire" onClick="countyCount(this)"> Derbyshire<br>
<input type="checkbox" name="countybox9" value="Devon" onClick="countyCount(this)"> Devon<br>
<input type="checkbox" name="countybox10" value="Dorset" onClick="countyCount(this)"> Dorset<br>
<input type="checkbox" name="countybox11" value="Durham" onClick="countyCount(this)"> Durham<br>
<input type="checkbox" name="countybox12" value="Essex" onClick="countyCount(this)"> Essex<br>
</td>
<td style="BORDER: 1px #aa9498; border-style: solid; padding: 6pt;" bgcolor="#ffffe1" valign="top">
<input type="checkbox" name="countybox13" value="Gloucestershire" onClick="countyCount(this)"> Gloucestershire<br>
<input type="checkbox" name="countybox14" value="Hampshire" onClick="countyCount(this)"> Hampshire<br>
<input type="checkbox" name="countybox15" value="Herefordshire" onClick="countyCount(this)"> Herefordshire<br>
<input type="checkbox" name="countybox16" value="Hertfordshire" onClick="countyCount(this)"> Hertfordshire<br>
<input type="checkbox" name="countybox17" value="Huntingdonshire" onClick="countyCount(this)"> Huntingdonshire
<br>
<input type="checkbox" name="countybox19" value="Lancashire" onClick="countyCount(this)"> Lancashire<br>
<input type="checkbox" name="countybox20" value="Leicestershire" onClick="countyCount(this)"> Leicestershire<br>
<input type="checkbox" name="countybox21" value="Lincolnshire" onClick="countyCount(this)"> Lincolnshire<br>
<input type="checkbox" name="countybox22" value="Middlesex" onClick="countyCount(this)"> Middlesex<br>
<input type="checkbox" name="countybox23" value="Norfolk" onClick="countyCount(this)"> Norfolk<br>
<input type="checkbox" name="countybox24" value="Northamptonshire" onClick="countyCount(this)"> Northamptonshire<br>
<input type="checkbox" name="countybox25" value="Northumberland" onClick="countyCount(this)"> Northumberland<br>
<input type="checkbox" name="countybox26" value="Nottinghamshire" onClick="countyCount(this)"> Nottinghamshire<br>
</td>
<td style="BORDER: 1px #aa9498; border-style: solid; padding: 6pt;" bgcolor="#ffffe1" valign="top">
<input type="checkbox" name="countybox27" value="Oxfordshire" onClick="countyCount(this)"> Oxfordshire<br>
<input type="checkbox" name="countybox28" value="Rutland" onClick="countyCount(this)"> Rutland<br>
<input type="checkbox" name="countybox29" value="Shropshire" onClick="countyCount(this)"> Shropshire<br>
<input type="checkbox" name="countybox30" value="Somerset" onClick="countyCount(this)"> Somerset<br>
<input type="checkbox" name="countybox31" value="Staffordshire" onClick="countyCount(this)"> Staffordshire<br>
<input type="checkbox" name="countybox32" value="Suffolk" onClick="countyCount(this)"> Suffolk<br>
<input type="checkbox" name="countybox33" value="Surrey" onClick="countyCount(this)"> Surrey<br>
<input type="checkbox" name="countybox34" value="Sussex" onClick="countyCount(this)"> Sussex<br>
<input type="checkbox" name="countybox35" value="Warwickshire" onClick="countyCount(this)"> Warwickshire<br>
<input type="checkbox" name="countybox36" value="Westmorland" onClick="countyCount(this)"> Westmorland<br>
<input type="checkbox" name="countybox37" value="Wiltshire" onClick="countyCount(this)"> Wiltshire<br>
<input type="checkbox" name="countybox38" value="Worcestershire" onClick="countyCount(this)"> Worcestershire<br>
<input type="checkbox" name="countybox39" value="Yorkshire" onClick="countyCount(this)"> Yorkshire<br>
</td></tr></table>


<table border="1" cellpadding="4" cellspacing="0" width="440" style="border-collapse:collapse; BORDER: 1px #aa9498; border-style: solid; margin-top: 0px; margin-bottom: 16px;margin-left: 4px;"><tr><td style="BORDER: 1px #aa9498; border-style: solid; padding: 6pt;" bgcolor="#ffffe1" valign="top">
<input type="checkbox" name="countyboxSCOTLAND" value="NA" onClick="scotlandCheck()"> <b>Scotland</b><br><br>
<input type="checkbox" name="countybox40" value="Aberdeenshire" onClick="countyCount(this)"> Aberdeenshire<br>
<input type="checkbox" name="countybox41" value="Angus" onClick="countyCount(this)"> Angus<br>
<input type="checkbox" name="countybox42" value="Argyll" onClick="countyCount(this)"> Argyll<br>
<input type="checkbox" name="countybox43" value="Ayrshire" onClick="countyCount(this)"> Ayrshire<br>
<input type="checkbox" name="countybox44" value="Banffshire" onClick="countyCount(this)"> Banffshire<br>
<input type="checkbox" name="countybox45" value="Berwickshire" onClick="countyCount(this)"> Berwickshire<br>
<input type="checkbox" name="countybox46" value="Bute (islands of Arran and Bute)" onClick="countyCount(this)"> Bute (islands of Arran and Bute)<br>
<input type="checkbox" name="countybox47" value="Caithness" onClick="countyCount(this)"> Caithness<br>
<input type="checkbox" name="countybox48" value="Clackmannanshire" onClick="countyCount(this)"> Clackmannanshire<br>
<input type="checkbox" name="countybox49" value="Dumfriesshire" onClick="countyCount(this)"> Dumfriesshire<br>
<input type="checkbox" name="countybox50" value="Dunbartonshire" onClick="countyCount(this)"> Dunbartonshire<br>
<input type="checkbox" name="countybox51" value="East Lothian" onClick="countyCount(this)"> East Lothian<br>
</td>
<td style="BORDER: 1px #aa9498; border-style: solid; padding: 6pt;" bgcolor="#ffffe1" valign="top">
<input type="checkbox" name="countybox52" value="Fife" onClick="countyCount(this)"> Fife<br>
<input type="checkbox" name="countybox53" value="Forfarshire (see Angus)" onClick="countyCount(this)"> Forfarshire (see Angus)<br>
<input type="checkbox" name="countybox54" value="Inverness-shire (includes Lewis (part), Uist & Skye)" onClick="countyCount(this)"> Inverness-shire<br>(includes Lewis (part), Uist & Skye)<br>
<input type="checkbox" name="countybox55" value="Kincardineshire" onClick="countyCount(this)"> Kincardineshire<br>
<input type="checkbox" name="countybox56" value="Kinross-shire" onClick="countyCount(this)"> Kinross-shire<br>
<input type="checkbox" name="countybox57" value="Kirkcudbrightshire" onClick="countyCount(this)"> Kirkcudbrightshire<br>
<input type="checkbox" name="countybox58" value="Lanarkshire" onClick="countyCount(this)"> Lanarkshire<br>
<input type="checkbox" name="countybox59" value="Midlothian" onClick="countyCount(this)"> Midlothian<br>
<input type="checkbox" name="countybox60" value="Moray" onClick="countyCount(this)"> Moray<br>
<input type="checkbox" name="countybox61" value="Nairnshire" onClick="countyCount(this)"> Nairnshire<br>
<input type="checkbox" name="countybox62" value="Orkney" onClick="countyCount(this)"> Orkney<br>
<input type="checkbox" name="countybox63" value="Peeblesshire" onClick="countyCount(this)"> Peeblesshire<br>
</td>
<td style="BORDER: 1px #aa9498; border-style: solid; padding: 6pt;" bgcolor="#ffffe1" valign="top">
<input type="checkbox" name="countybox64" value="Perthshire" onClick="countyCount(this)"> Perthshire<br>
<input type="checkbox" name="countybox65" value="Renfrewshire" onClick="countyCount(this)"> Renfrewshire<br>
<input type="checkbox" name="countybox66" value="Ross & Cromarty (includes part of Lewis)" onClick="countyCount(this)"> Ross & Cromarty<br>(includes part of Lewis)<br>
<nobr><input type="checkbox" name="countybox67" value="Roxburghshire" onClick="countyCount(this)"> Roxburghshire</nobr><br>
<input type="checkbox" name="countybox68" value="Selkirkshire" onClick="countyCount(this)"> Selkirkshire<br>
<input type="checkbox" name="countybox69" value="Shetland" onClick="countyCount(this)"> Shetland<br>
<input type="checkbox" name="countybox70" value="Stirlingshire" onClick="countyCount(this)"> Stirlingshire<br>
<input type="checkbox" name="countybox71" value="Sutherland" onClick="countyCount(this)"> Sutherland<br>
<input type="checkbox" name="countybox72" value="West Lothian" onClick="countyCount(this)"> West Lothian<br>
<input type="checkbox" name="countybox73" value="Wigtownshire" onClick="countyCount(this)"> Wigtownshire<br><br>
</td></tr></table>

<table border="1" cellpadding="4" cellspacing="0" width="440" style="border-collapse:collapse; BORDER: 1px #aa9498; border-style: solid; margin-top: 0px; margin-bottom: 16px;margin-left: 4px;"><tr><td style="BORDER: 1px #aa9498; border-style: solid; padding: 6pt;" bgcolor="#ffffe1" valign="top">
<input type="checkbox" name="countyboxWALES" value="NA" onClick="walesCheck()"> <b>Wales</b><br><br>
<input type="checkbox" name="countybox74" value="Anglesey" onClick="countyCount(this)"> Anglesey<br>
<input type="checkbox" name="countybox75" value="Breconshire" onClick="countyCount(this)"> Breconshire<br>
<input type="checkbox" name="countybox76" value="Caernarvonshire" onClick="countyCount(this)"> Caernarvonshire<br>
<input type="checkbox" name="countybox77" value="Cardiganshire" onClick="countyCount(this)"> Cardiganshire<br>
<input type="checkbox" name="countybox78" value="Carmarthenshire" onClick="countyCount(this)"> Carmarthenshire<br>
<input type="checkbox" name="countybox79" value="Denbighshire" onClick="countyCount(this)"> Denbighshire<br>
<input type="checkbox" name="countybox80" value="Flintshire" onClick="countyCount(this)"> Flintshire<br>
<input type="checkbox" name="countybox81" value="Glamorgan" onClick="countyCount(this)"> Glamorgan<br>
</td><td style="BORDER: 1px #aa9498; border-style: solid; padding: 6pt;" bgcolor="#ffffe1" valign="top">
<input type="checkbox" name="countybox82" value="Merionethshire" onClick="countyCount(this)"> Merionethshire<br>
<input type="checkbox" name="countybox83" value="Monmouthshire" onClick="countyCount(this)"> Monmouthshire<br>
<input type="checkbox" name="countybox84" value="Montgomeryshire" onClick="countyCount(this)"> Montgomeryshire<br>
<input type="checkbox" name="countybox85" value="Pembrokeshire" onClick="countyCount(this)"> Pembrokeshire<br>
<input type="checkbox" name="countybox86" value="Radnorshire" onClick="countyCount(this)"> Radnorshire<br>

<br><br>
<input type="checkbox" name="countyboxCHANNEL" value="NA" onClick="channelCheck()"> <b>Channel Islands</b><br><br>
<input type="checkbox" name="countybox87" value="Channel Islands" onClick="countyCount(this)"> Channel Islands<br>
</td></tr></table>

<table border="1" cellpadding="4" cellspacing="0" width="440" style="border-collapse:collapse; BORDER: 1px #aa9498; border-style: solid; margin-top: 0px; margin-bottom: 16px;margin-left: 4px;"><tr><td style="BORDER: 1px #aa9498; border-style: solid; padding: 6pt;" bgcolor="#ffffe1" valign="top">
<input type="checkbox" name="countyboxIRELAND" value="NA" onClick="irelandCheck()"> <b>Ireland</b><br><br>
<input type="checkbox" name="countybox88" value="Antrim" onClick="countyCount(this)"> Antrim<br>
<input type="checkbox" name="countybox89" value="Armagh" onClick="countyCount(this)"> Armagh<br>
<input type="checkbox" name="countybox90" value="Carlow" onClick="countyCount(this)"> Carlow<br>
<input type="checkbox" name="countybox91" value="Cavan" onClick="countyCount(this)"> Cavan<br>
<input type="checkbox" name="countybox92" value="Clare" onClick="countyCount(this)"> Clare<br>
<input type="checkbox" name="countybox93" value="Cork" onClick="countyCount(this)"> Cork<br>
<input type="checkbox" name="countybox94" value="Donegal" onClick="countyCount(this)"> Donegal<br>
<input type="checkbox" name="countybox95" value="Down" onClick="countyCount(this)"> Down<br>
<input type="checkbox" name="countybox96" value="Dublin" onClick="countyCount(this)"> Dublin<br>
<input type="checkbox" name="countybox97" value="Fermanagh" onClick="countyCount(this)"> Fermanagh<br>
<input type="checkbox" name="countybox98" value="Galway" onClick="countyCount(this)"> Galway<br>
<input type="checkbox" name="countybox99" value="Kerry" onClick="countyCount(this)"> Kerry<br>
<input type="checkbox" name="countybox100" value="Kildare" onClick="countyCount(this)"> Kildare<br>
<input type="checkbox" name="countybox101" value="Kilkenny" onClick="countyCount(this)"> Kilkenny<br>
<input type="checkbox" name="countybox102" value="Londonderry" onClick="countyCount(this)"> Londonderry<br>
</td><td style="BORDER: 1px #aa9498; border-style: solid; padding: 6pt;" bgcolor="#ffffe1" valign="top">
<input type="checkbox" name="countybox103" value="Leitrim" onClick="countyCount(this)"> Leitrim<br>
<input type="checkbox" name="countybox104" value="Leix" onClick="countyCount(this)"> Leix<br>
<input type="checkbox" name="countybox105" value="Limerick" onClick="countyCount(this)"> Limerick<br>
<input type="checkbox" name="countybox106" value="Longford" onClick="countyCount(this)"> Longford<br>
<input type="checkbox" name="countybox107" value="Louth" onClick="countyCount(this)"> Louth<br>
<input type="checkbox" name="countybox108" value="Mayo" onClick="countyCount(this)"> Mayo<br>
<input type="checkbox" name="countybox109" value="Meath" onClick="countyCount(this)"> Meath<br>
<input type="checkbox" name="countybox110" value="Monaghan" onClick="countyCount(this)"> Monaghan<br>
<input type="checkbox" name="countybox111" value="Offaly" onClick="countyCount(this)"> Offaly<br>
<input type="checkbox" name="countybox112" value="Roscommon" onClick="countyCount(this)"> Roscommon<br>
<input type="checkbox" name="countybox113" value="Sligo" onClick="countyCount(this)"> Sligo<br>
<input type="checkbox" name="countybox114" value="Tipperary" onClick="countyCount(this)"> Tipperary<br>
<input type="checkbox" name="countybox115" value="Tyrone" onClick="countyCount(this)"> Tyrone<br>
<input type="checkbox" name="countybox116" value="Waterford" onClick="countyCount(this)"> Waterford<br>
<input type="checkbox" name="countybox117" value="Westmeath" onClick="countyCount(this)"> Westmeath<br>
<input type="checkbox" name="countybox118" value="Wexford" onClick="countyCount(this)"> Wexford<br>
<input type="checkbox" name="countybox119" value="Wicklow" onClick="countyCount(this)"> Wicklow<br>
</td></tr></table>

<p class="para">
<input type="text" name="multicountybox" value="Choose 2 or more regions for a £100 discount" style="border:0px;cursor:default;background:#f5d5da;width:360"><br><br>
Total Price: £<input name="grandtotal" type="text" onFocus="this.blur()" size="12" value="0" style="text-align:center;cursor:default">
<nobr><input name="truepricebox" type="text" size="6" style="border:0px;text-align:right;cursor:default;background:#f5d5da" value="(£0"> per county)</nobr></p>

<img src="img/blank.gif" name="regionmap" alt="">

<p class="para"><input type="checkbox" name="terms"> Please tick this box to verify that you agree to our standard <a href="javascript:void(0);" onClick="popTerms()">terms & conditions</a>.<br> <br>
<input type="submit" value="Submit entry" class="inputbox" name="submit2">
</p>

</form>

 

When i echo out the the $count , it just says 1 for each one , not the value.

 

Any help please..

Link to comment
Share on other sites

Not sure if the below will help.

 

Not sure if you noticed on you code you have not commented out one of the "&" next 160.

 

The Code below may not be the most elegant but this is how I would do your form and pick the checked boxes back up.

 

<?php
$now = date("d/m/Y");
$next = date('d/m/Y', strtotime("+1 year"));

$Country = mysql_query("SELECT DISTINCT Country FROM My_Country_Table") or trigger_error("SQL", E_USER_ERROR);
$CountryArray = mysql_fetch_assoc($Country);
?>

<form method="post" action="" name="timereg" onSubmit="return verifyRegister(this.form)">
<p class="para">Please choose the areas you would like to appear in below, for a one year listing period (<?php echo $now." - ".$next;?>).</p>
<input type="hidden" value="<?php echo $now;?>" name="1yrstartdate">
<input type="hidden" value="<?php echo $next; ?>" name="1yrenddate">
<input value="<?php echo $rows['companyname'];?>" type="hidden">

<table border="1" cellpadding="4" cellspacing="0" width="440" style="border-collapse:collapse; BORDER: 1px #aa9498; border-style: solid; margin-top: 0px; margin-bottom: 16px;margin-left: 4px;"><tr><td style="BORDER: 1px #aa9498; border-style: solid; padding: 6pt;" bgcolor="#ffffe1">

<? $myCountry = $CountryArray['Country'];
do { 
$i = 0; ?>
<input type="checkbox" name="countybox[]" id="countrybox[]" value="<? echo $myCountry; ?>" onClick="england"> <b><? echo $myCountry; ?></b><br><br>
<?
$County = mysql_query("SELECT DISTINCT County WHERE Country_Column = '$myCountry' FROM My_Country_Table") or trigger_error("SQL", E_USER_ERROR);
$CountyArray = mysql_fetch_assoc($County);
do { ?>
<input type="checkbox" name="countybox1[]" id="countrybox[]" value="Bedfordshire" onClick="<? echo $CountyArray['County']; ?>"> <? echo $CountyArray['County']; ?><br><? $i++; if($i % 13 == 0) { ?>
</td>
<td style="BORDER: 1px #aa9498; border-style: solid; padding: 6pt;" bgcolor="#ffffe1" valign="top"> <? }
} while($CountyArray = mysql_fetch_assoc($County)); ?>
</td></tr></table>
<? } while($CountryArray = mysql_fetch_assoc($Country)); ?>

<p class="para">
<input type="text" name="multicountybox" value="Choose 2 or more regions for a £100 discount" style="border:0px;cursor:default;background:#f5d5da;width:360"><br><br>
Total Price: £<input name="grandtotal" type="text" onFocus="this.blur()" size="12" value="0" style="text-align:center;cursor:default">
<nobr><input name="truepricebox" type="text" size="6" style="border:0px;text-align:right;cursor:default;background:#f5d5da" value="(£0"> per county)</nobr></p>

<img src="img/blank.gif" name="regionmap" alt="">

<p class="para"><input type="checkbox" name="terms"> Please tick this box to verify that you agree to our standard <a href="javascript:void(0);" onClick="popTerms()">terms & conditions</a>.<br> <br>
<input type="submit" value="Submit entry" class="inputbox" name="submit2">
</p>

</form>

##########################################################################

This is where I then would pick up the checked boxes

##########################################################################

<?
$cou = 0;
$county =0;
foreach($_POST['Country'] = $SelectedCountry){
$cou++;
foreach($_POST['County'] = $SelectedCounty){
### assuming you have a cart table
mysql_query("INSERT INTO Cart SET (SelectedCountry, SelectedCounty, cust_id) Values ('$SelectedCountry', '$SelectedCounty', '$Cust_Id')") or trigger_error("SQL", E_USER_ERROR);
$county++;
}

echo "Number of Countries = "$cou;
echo "Number of Counties = "$county;

?>

 

Hope it helps (sorry I used short "<? rathee than <?php")

 

 

Link to comment
Share on other sites

Thanks for the try , but thats not where the problem is i beleive, the problem is getting the value from the checkbox in the code i think.

 

Here is the updated code, php only bits , this now does work kindoff,

<?php
	$county = array();
	$county = array(150);
	$m = 0;
	for($i=0;$i<120;$i++) 
	{
   		if(isset($_POST['countybox' . $i]))
		{
			$checkbx = $_POST['countybox' . $i];
		}
		if (isset($checkbx) && $checkbx != '') 
		{
			  $county[$m] = $checkbx;
			  $m++;
		}
	}	
	print_r ($county);
$now = date("d/m/Y");
$next = date('d/m/Y', strtotime("+1 year"));
	foreach($county as $count)
	{
		$query = "SELECT * FROM Payments WHERE Region='".$count."' AND location='WEBSITE'";
		$mysql = mysql_query($query);
		echo $count."<br>";
		/*$type = $rows['service_type'];
		$area = $rows['county'];
		$name = $rows['companyname'];
		$sql_pay = "INSERT INTO Payments (company_type,email,location,Price,Region,companyname,created) VALUES ('$type','$frmemail','WEBSITE','$price','$area','$name',NOW())";
		mysql_query($sql_pay) or die(mysql_error());
		header("Location:https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=grant.deller%40allabout-weddings%2ecom&item_name=1%20year%20listing%20on%20All%20About%20Weddings%20(".$m."%20counties)&amount=".$price. "%2e00&no_shipping=0&no_note=1&currency_code=GBP&bn=PP%2dBuyNowBF&charset=UTF%2d8");
*/
		/*while($rw = mysql_fetch_assoc($mysql))
		{
			$startdate = date("d/m/Y",strtotime($rw['periodstart']));
			echo $startdate;
			$enddate = date("d/m/Y",strtotime($rw['periodend']));
			if($startdate =< $now)
			{
			?>
			<script>alert("Error, conflicting bookings please check the booking slots and try again");</script>
			<?php
			header("Location:webbook.php");
			}	
			else
			{
			}
		}*/
	}

}	
?>

 

My problem is this

Array ( [0] => Bedfordshire [1] => Berkshire [2] => Buckinghamshire [3] => Cambridgeshire [4] => Cheshire [5] => Cornwall [6] => Cumberland [7] => Derbyshire [8] => Devon [9] => Dorset [10] => Durham [11] => Essex [12] => Gloucestershire [13] => Hampshire [14] => Herefordshire [15] => Hertfordshire [16] => Huntingdonshire [17] => Huntingdonshire [18] => Huntingdonshire [19] => Huntingdonshire [20] => Huntingdonshire [21] => Huntingdonshire [22] => Huntingdonshire [23] => Huntingdonshire [24] => Huntingdonshire [25] => Huntingdonshire [26] => Huntingdonshire [27] => Huntingdonshire [28] => Huntingdonshire [29] => Huntingdonshire [30] => Huntingdonshire [31] => Huntingdonshire [32] => Huntingdonshire [33] => Huntingdonshire [34] => Huntingdonshire [35] => Huntingdonshire [36] => Huntingdonshire [37] => Huntingdonshire [38] => Huntingdonshire [39] => Huntingdonshire [40] => Huntingdonshire [41] => Huntingdonshire [42] => Huntingdonshire [43] => Huntingdonshire [44] => Huntingdonshire [45] => Huntingdonshire [46] => Huntingdonshire [47] => Huntingdonshire [48] => Huntingdonshire [49] => Huntingdonshire [50] => Huntingdonshire [51] => Huntingdonshire [52] => Huntingdonshire [53] => Huntingdonshire [54] => Huntingdonshire [55] => Huntingdonshire [56] => Huntingdonshire [57] => Huntingdonshire [58] => Huntingdonshire [59] => Huntingdonshire [60] => Huntingdonshire [61] => Huntingdonshire [62] => Huntingdonshire [63] => Huntingdonshire [64] => Huntingdonshire [65] => Huntingdonshire [66] => Huntingdonshire [67] => Huntingdonshire [68] => Huntingdonshire [69] => Huntingdonshire [70] => Huntingdonshire [71] => Huntingdonshire [72] => Huntingdonshire [73] => Huntingdonshire [74] => Huntingdonshire [75] => Huntingdonshire [76] => Huntingdonshire [77] => Huntingdonshire [78] => Huntingdonshire [79] => Huntingdonshire [80] => Huntingdonshire [81] => Huntingdonshire [82] => Huntingdonshire [83] => Huntingdonshire [84] => Huntingdonshire [85] => Huntingdonshire [86] => Huntingdonshire [87] => Huntingdonshire [88] => Huntingdonshire [89] => Huntingdonshire [90] => Huntingdonshire [91] => Huntingdonshire [92] => Huntingdonshire [93] => Huntingdonshire [94] => Huntingdonshire [95] => Huntingdonshire [96] => Huntingdonshire [97] => Huntingdonshire [98] => Huntingdonshire [99] => Huntingdonshire [100] => Huntingdonshire [101] => Huntingdonshire [102] => Huntingdonshire [103] => Huntingdonshire [104] => Huntingdonshire [105] => Huntingdonshire [106] => Huntingdonshire [107] => Huntingdonshire [108] => Huntingdonshire [109] => Huntingdonshire [110] => Huntingdonshire [111] => Huntingdonshire [112] => Huntingdonshire [113] => Huntingdonshire [114] => Huntingdonshire [115] => Huntingdonshire [116] => Huntingdonshire [117] => Huntingdonshire [118] => Huntingdonshire )

As you can see it does this on the last result , any one see what im doing wrong?

Link to comment
Share on other sites

soz for posting another kinda bump , but the code looks wrong in the previous post, so here it is

<?php
	$county = array();
	$county = array(150);
	$m = 0;
	for($i=0;$i<120;$i++) 
	{
    		if(isset($_POST['countybox' . $i]))
		{
			$checkbx = $_POST['countybox' . $i];
		}
		if (isset($checkbx) && $checkbx != '') 
		{
			  $county[$m] = $checkbx;
			  $m++;
		}
	}	
	print_r ($county);
$now = date("d/m/Y");
$next = date('d/m/Y', strtotime("+1 year"));
	foreach($county as $count)
	{
		$query = "SELECT * FROM Payments WHERE Region='".$count."' AND location='WEBSITE'";
		$mysql = mysql_query($query);
		echo $count."<br>";
		/*$type = $rows['service_type'];
		$area = $rows['county'];
		$name = $rows['companyname'];
		$sql_pay = "INSERT INTO Payments (company_type,email,location,Price,Region,companyname,created) VALUES ('$type','$frmemail','WEBSITE','$price','$area','$name',NOW())";
		mysql_query($sql_pay) or die(mysql_error());
		header("Location:https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=grant.deller%40allabout-weddings%2ecom&item_name=1%20year%20listing%20on%20All%20About%20Weddings%20(".$m."%20counties)&amount=".$price. "%2e00&no_shipping=0&no_note=1&currency_code=GBP&bn=PP%2dBuyNowBF&charset=UTF%2d8");
*/
		/*while($rw = mysql_fetch_assoc($mysql))
		{
			$startdate = date("d/m/Y",strtotime($rw['periodstart']));
			echo $startdate;
			$enddate = date("d/m/Y",strtotime($rw['periodend']));
			if($startdate =< $now)
			{
			?>
			<script>alert("Error, conflicting bookings please check the booking slots and try again");</script>
			<?php
			header("Location:webbook.php");
			}	
			else
			{
			}
		}*/
	}

}	
?>

Link to comment
Share on other sites

Yeah sorry an explination would have helped, when I do this i put the checked boxes value into an array using [] e.g.name="countybox1[]" then I can just cycle throung them using foreach($_POST['Countybox1'] = $SelectedCounty), and then for ease I put it into a table to read back later.

 

It then gives me the ID / name of the checked box from the value.

 

Hope this makes more sence and helps.

Link to comment
Share on other sites

database is fine , and that javascript function just works out the price i beleive

 

 

function countyCount(obj) {

if (obj.checked) { supercount+=1 }
if (obj.checked == false) { supercount-=1 }

supercountChecker()
}

function supercountChecker(obj) {
if (supercount==1) { valueholder=0 }
if (supercount==2) { valueholder=30 }
if (supercount==3) { valueholder=60 }
if (supercount==4) { valueholder=90 }
if (supercount==5) { valueholder=120 }
if (supercount==6) { valueholder=150 }
if (supercount==7) { valueholder=180 }
if (supercount== { valueholder=210 }
if (supercount==9) { valueholder=240 }
if (supercount==10) { valueholder=270 }
if (supercount==11) { valueholder=300 }
if (supercount==12) { valueholder=330 }
if (supercount==13) { valueholder=360 }
if (supercount==14) { valueholder=390 }
if (supercount==15) { valueholder=410 }
if (supercount==16) { valueholder=440 }
if (supercount==17) { valueholder=470 }
if (supercount==18) { valueholder=500 }
if (supercount==19) { valueholder=530 }
if (supercount==20) { valueholder=560 }
if (supercount==21) { valueholder=590 }
if (supercount==22) { valueholder=620 }
if (supercount==23) { valueholder=650 }
if (supercount==24) { valueholder=680 }
if (supercount==25) { valueholder=710 }
if (supercount==26) { valueholder=740 }
if (supercount==27) { valueholder=770 }
if (supercount==28) { valueholder=800 }
if (supercount==29) { valueholder=830 }
if (supercount==30) { valueholder=860 }
if (supercount==31) { valueholder=890 }
if (supercount==32) { valueholder=920 }
if (supercount==33) { valueholder=950 }
if (supercount==34) { valueholder=980 }
if (supercount==35) { valueholder=1010 }
if (supercount==36) { valueholder=1040 }
if (supercount==37) { valueholder=1070 }
if (supercount==38) { valueholder=1100 }
if (supercount==39) { valueholder=1130 }
if (supercount==40) { valueholder=1160 }
if (supercount==41) { valueholder=1190 }
if (supercount==42) { valueholder=1220 }
if (supercount==43) { valueholder=1250 }
if (supercount==44) { valueholder=1280 }
if (supercount==45) { valueholder=1310 }
if (supercount==46) { valueholder=1340 }
if (supercount==47) { valueholder=1370 }
if (supercount==48) { valueholder=1400 }
if (supercount==49) { valueholder=1430 }
if (supercount==50) { valueholder=1460 }
if (supercount==51) { valueholder=1490 }
if (supercount==52) { valueholder=1520 }
if (supercount==53) { valueholder=1550 }
if (supercount==54) { valueholder=1580 }
if (supercount==55) { valueholder=1620 }
if (supercount==56) { valueholder=1650 }
if (supercount==57) { valueholder=1680 }
if (supercount==58) { valueholder=1710 }
if (supercount==59) { valueholder=1740 }
if (supercount==60) { valueholder=1770 }
if (supercount==61) { valueholder=1800 }
if (supercount==62) { valueholder=1830 }
if (supercount==63) { valueholder=1850 }
if (supercount==64) { valueholder=1880 }
if (supercount==65) { valueholder=1910 }
if (supercount==66) { valueholder=1940 }
if (supercount==67) { valueholder=1970 }
if (supercount==68) { valueholder=2000 }
if (supercount==69) { valueholder=2030 }
if (supercount==70) { valueholder=2060 }
if (supercount==71) { valueholder=2090 }
if (supercount==72) { valueholder=2120 }
if (supercount==73) { valueholder=2150 }
if (supercount==74) { valueholder=2180 }
if (supercount==75) { valueholder=2210 }
if (supercount==76) { valueholder=2240 }
if (supercount==77) { valueholder=2270 }
if (supercount==78) { valueholder=2300 }
if (supercount==79) { valueholder=2330 }
if (supercount==80) { valueholder=2360 }
if (supercount==81) { valueholder=2390 }
if (supercount==82) { valueholder=2420 }
if (supercount==83) { valueholder=2450 }
if (supercount==84) { valueholder=2480 }
if (supercount==85) { valueholder=2510 }
if (supercount==86) { valueholder=2540 }
if (supercount==87) { valueholder=2570 }
if (supercount==88) { valueholder=2600 }
if (supercount==89) { valueholder=2630 }
if (supercount==90) { valueholder=2660 }
if (supercount==91) { valueholder=2690 }
if (supercount==92) { valueholder=2720 }
if (supercount==93) { valueholder=2750 }
if (supercount==94) { valueholder=2780 }
if (supercount==95) { valueholder=2810 }
if (supercount==96) { valueholder=2840 }
if (supercount==97) { valueholder=2870 }
if (supercount==98) { valueholder=2900 }
if (supercount==99) { valueholder=2930 }
if (supercount==100) { valueholder=2960 }
if (supercount==101) { valueholder=2990 }
if (supercount==102) { valueholder=3020 }
if (supercount==103) { valueholder=3050 }
if (supercount==104) { valueholder=3080 }
if (supercount==105) { valueholder=3110 }
if (supercount==106) { valueholder=3140 }
if (supercount==107) { valueholder=3170 }
if (supercount==108) { valueholder=3200 }
if (supercount==109) { valueholder=3230 }
if (supercount==110) { valueholder=3260 }
if (supercount==111) { valueholder=3290 }
if (supercount==112) { valueholder=3320 }
if (supercount==113) { valueholder=3350 }
if (supercount==114) { valueholder=3380 }
if (supercount==115) { valueholder=3410 }
if (supercount==116) { valueholder=3440 }
if (supercount==117) { valueholder=3470 }
if (supercount==118) { valueholder=3500 }
if (supercount==119) { valueholder=3530 }
// NON working condensed checker to replace the above code
// var moretimeCounter
// for (moretimeCounter=4; moretimeCounter==119; moretimeCounter++)
//   {
//   if (supercount==moretimeCounter) { valueholder=(moretimeCounter * 35) }
//   }

// FOLLOWING TWO LINES GIVE OR TAKE 100 QUID DISCOUNT FOR MULTICOUNTY
if (obj=='nowMinus100') { valueholder-=100 }
if (obj=='nowAdd100') { +valueholder + 100 }

document.timereg.grandtotal.value=valueholder

trueprice=valueholder/(supercount-1)

if (isNaN(trueprice)) { trueprice=0; }
// if (isUndefined(trueprice)) { trueprice=0; }
trueprice=trueprice.toFixed(2)
document.timereg.truepricebox.value='(£'+trueprice

}

Link to comment
Share on other sites

try

<?php
if(isset($_POST['submit2']))
{
$price = $_POST["grandtotal"];
if(isset($_SESSION["email"]))
{
	$frmemail = $_SESSION["email"];
}
else
{
	// you can't use echo before header() echo "Error. Please login again.";
	header("Location:home-pub.php?logout");
}
$now = date("d/m/Y");
$next = date('d/m/y', strtotime("+1 year"));

if($price == 0 || strlen($price) == 0)
{
	echo "Invalid price";
}
else
{
	$county = array();
	//$county = array(150);
	$m = 0;
	for($i=0;$i<120;$i++) 
	{
 		$checkbx = isset($_POST['countybox' . $i]);
		if (isset($_POST['countybox' . $i])) 
		{
			$county[$m] = $_POST['countybox' . $i];
			$m++;
		}
	}	
$now = date("d/m/Y");
$next = date('d/m/Y', strtotime("+1 year"));
print_r($county); //for debuging
}
}

?>

Link to comment
Share on other sites

No difference, although all i changed was the bits you echoed out, my current code is:

 

<?php
if(isset($_POST['submit2']))
{
$price = $_POST["grandtotal"];

if(isset($_SESSION["email"]))
{
	$frmemail = $_SESSION["email"];
}
else
{
	echo "<script>alert('Error. Please login again.');</script>";
	header("Location:home-pub.php?logout");
}
$now = date("d/m/Y");
$next = date('d/m/y', strtotime("+1 year"));

if($price == 0 || strlen($price) == 0)
{
	echo "Invalid price";
}
else
{
	$county = array();
	$m = 0;
	for($i=0;$i<120;$i++) 
	{
    		if(isset($_POST['countybox' . $i]))
		{
			$checkbx = $_POST['countybox' . $i];
		}
		if (isset($checkbx) && $checkbx != '') 
		{
			  $county[$m] = $checkbx;
			  $m++;
		}
	}	
	print_r ($county);
$now = date("d/m/Y");
$next = date('d/m/Y', strtotime("+1 year"));
	foreach($county as $count)
	{
		$query = "SELECT * FROM Payments WHERE Region='".$count."' AND location='WEBSITE'";
		$mysql = mysql_query($query);
		echo $count."<br>";
		/*$type = $rows['service_type'];
		$area = $rows['county'];
		$name = $rows['companyname'];
		$sql_pay = "INSERT INTO Payments (company_type,email,location,Price,Region,companyname,created) VALUES ('$type','$frmemail','WEBSITE','$price','$area','$name',NOW())";
		mysql_query($sql_pay) or die(mysql_error());
		header("Location:https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=grant.deller%40allabout-weddings%2ecom&item_name=1%20year%20listing%20on%20All%20About%20Weddings%20(".$m."%20counties)&amount=".$price. "%2e00&no_shipping=0&no_note=1&currency_code=GBP&bn=PP%2dBuyNowBF&charset=UTF%2d8");
*/
		/*while($rw = mysql_fetch_assoc($mysql))
		{
			$startdate = date("d/m/Y",strtotime($rw['periodstart']));
			echo $startdate;
			$enddate = date("d/m/Y",strtotime($rw['periodend']));
			if($startdate =< $now)
			{
			?>
			<script>alert("Error, conflicting bookings please check the booking slots and try again");</script>
			<?php
			header("Location:webbook.php");
			}	
			else
			{
			}
		}*/
	}

}	
}
?>

 

And this still produces the same problem.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.