how do i call this from another page?
Posted: Wed Nov 17, 2010 7:31 pm
$y is my variable that I increment by a for loop.
This variable determines the number of every row
..and then i'd concat'd $y with the name of
the textboxes of every column and row
name="orno<?php echo $y;?>"
now, i'm not sure if i'm supposed to concat with the name
or should it be with the id?
HOW DO i CALL THE NAME FROM ANOTHER PAGE?
this is what I did and I don't know if this is right
$orno= $_POST['orno'.$y];
and since I know I may not be
making much sense with my explaination above,
this is my add_content.php where it all starts
I've only included the part where the textboxes
are displayed by/within a loop and where the
names are concatenated with the variable $y.
I have dropdowns and textboxes for the date and
other elements above this.
then we go to add_save.php
this page is still very lacking because
I don't know how to evaluate then save
multiple rows yet since I've originally done
a page that saves one row at a time in which the
textboxes' names aren't from a loop and
were not concatenated.
thank you very much
This variable determines the number of every row
..and then i'd concat'd $y with the name of
the textboxes of every column and row
name="orno<?php echo $y;?>"
now, i'm not sure if i'm supposed to concat with the name
or should it be with the id?
HOW DO i CALL THE NAME FROM ANOTHER PAGE?
this is what I did and I don't know if this is right
$orno= $_POST['orno'.$y];
and since I know I may not be
making much sense with my explaination above,
this is my add_content.php where it all starts
I've only included the part where the textboxes
are displayed by/within a loop and where the
names are concatenated with the variable $y.
I have dropdowns and textboxes for the date and
other elements above this.
Code: Select all
<div id="slider">
<ul>
<?php
$num=$_GET['num'];//this here represents the number of rows
//of textboxes user wants to appear
//there are 5 textboxes in one row and 10 rows in one page
//this is a sliding page with jquery
$nump=$num / 10;
$y=1;//initializing y
for($j=1;$j<=$nump;$j++){//determines how many pages then loops accordingly
?>
<li>
<p>
<?php
for($i=1;$i<=10;$i++){//loops 10 times to return 10 rows in a pages
if(strlen($y)==1){
echo "0";
}
echo $y." ";
?>
<input name="orno<?php echo $y;?>" id="orno" type="text" size="3" maxlength="6" onKeyPress="return isNumberKey
(event)" value="<?php
if (isset($_POST['orno'])) {
echo htmlspecialchars($_POST['orno'], ENT_QUOTES);
}?>">
<input name="billnmbr<?php echo $y;?>" id="billnmbr" type="text" size="16" maxlength="17" value="<?php
if (isset($_POST['billnmbr'])) {
echo htmlspecialchars($_POST['billnmbr'], ENT_QUOTES);
}?>">
<input name="payor<?php echo $y;?>" id="payor" type="text" size="35" maxlength="50" value="<?php
if (isset($_POST['payor'])) {
echo htmlspecialchars($_POST['payor'], ENT_QUOTES);
}?>">
<input name="arrastre<?php echo $y;?>" id="arrastre" type="text" size="7" maxlength="8" onKeyPress="return isMoneyKey
(event)" value="<?php
if (isset($_POST['arrastre'])) {
echo htmlspecialchars($_POST['arrastre'], ENT_QUOTES);
}?>">
<input name="wharfage<?php echo $y;?>" id="wharfage" type="text" size="7" maxlength="8" onKeyPress="return isMoneyKey
(event)" value="<?php
if (isset($_POST['wharfage'])) {
echo htmlspecialchars($_POST['wharfage'], ENT_QUOTES);
}?>"><br />
<?php $y++; }?>
</p>
</li>
<?php $y=$y; } ?>
</ul>
</div>
this page is still very lacking because
I don't know how to evaluate then save
multiple rows yet since I've originally done
a page that saves one row at a time in which the
textboxes' names aren't from a loop and
were not concatenated.
Code: Select all
[php]<?php
//please take a look at how I am calling the $_POSTs from the prev page
//what is the right way of calling concatenated names?
//or if there is a better way of calling these please let me know..
$year=$_POST['year'];
$month=$_POST['month'];
$day=$_POST['day'];
$date=$year."-".$month."-".$day;
$billnmbr=$_POST['billnmbr'.$y];
$orno= $_POST['orno'.$y];
$payor=$_POST['payor'.$y];
$arrastre=$_POST['arrastre'.$y];
$wharfage=$_POST['wharfage'.$y];
$total=$arrastre + $wharfage;
$tcl=$_POST['tcl'];
$preparedby=$_POST['preparedby'];
$notedby=$_POST['notedby'];
$addedby=$_POST['addedby'];
$office=$_POST['office'];
if($_POST['btnadd']){
if($billnmbr=="" or $orno=="" or $payor=="" or $arrastre=="" or $wharfage=="" or $year=="" or $month=="" or $day==""
or $tcl=="" or $preparedby=="" or $notedby=="" or $addedby=="" or $date=='2010-01-01'){
?>
<script>
alert ('At least one field was left blank!');
</script>
<?php
}
else{
$query = mysql_query("select * from `arrastre` WHERE `billnmbr`='$billnmbr'");
$count = mysql_num_rows($query);
if($count==1){//existing billnmbr
echo "This billnumber is already in the database.";
}
else{
$bll = strtoupper($billnmbr);
$explode_bill=explode("-",$bll);
$bill1 = 0;
$bill2 = 0;
$bill1 = $explode_bill[0];
$bill2 = $explode_bill[1];
if(strlen($bill2)<6 && strlen($bll)!=17){
if(strlen($bill2)==1){
$rep = "00000";
$bll = $bill1."-".$rep."".$bill2;
}
elseif(strlen($bill2)==2){
$rep = "0000";
$bll = $bill1."-".$rep."".$bill2;
}
elseif(strlen($bill2)==3){
$rep = "000";
$bll = $bill1."-".$rep."".$bill2;
}
elseif(strlen($bill2)==4){
$rep = "00";
$bll = $bill1."-".$rep."".$bill2;
}
elseif(strlen($bill2)==5){
$rep = "0";
$bll = $bill1."-".$rep."".$bill2;
}
}
$payr = strtoupper($payor);
$query="insert into `arrastre`
values ('0', '$orno', '$bll','$payr', '$arrastre', '$wharfage', '$total', '$date', '$tcl', '$preparedby',
'$notedby', '$addedby', '$office')";
$result=mysql_query($query);
?>
<?php
}}}
?>