每次点击提交按钮(提交新值)时如何打印所有提交的值而不会被覆盖

时间:2017-10-09 08:50:18

标签: php html

当我创建表单和提交按钮时,然后我使用-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath]; [cell setSelectionStyle:UITableViewCellSelectionStyleNone]; UILabel *title = (UILabel*)[cell viewWithTag:80]; UILabel *description = (UILabel*)[cell viewWithTag:81]; UIView *innerView = (UIView *)[cell viewWithTag:82]; innerView.layer.borderColor=[[UIColor colorWithRed:229/255.0f green:229/255.0f blue:229/255.0f alpha:1.0] CGColor]; innerView.layer.borderWidth = 2.0f; NSDictionary *displayDict = scenarioListsArray[indexPath.row]; title.text =[displayDict objectForKey:@"name"]; description.text = [displayDict objectForKey:@"description"]; UISwitch *myswitch = [[UISwitch alloc]initWithFrame:CGRectMake(cell.contentView.frame.size.width-60, (cell.contentView.frame.size.height/2)-20 , 100, 100)]; myswitch.onTintColor = [UIColor colorWithRed:25/255.0f green:122/255.0f blue:66/255.0f alpha:1]; [cell.contentView addSubview:myswitch]; myswitch.tag = indexPath.row; [myswitch addTarget:self action:@selector(cellButtonClickAction:) forControlEvents:UIControlEventValueChanged]; if ([[displayDict objectForKey:@"status"] isEqualToString:@"ACTIVE"]) { [myswitch setOn:YES animated:YES]; } else { [myswitch setOn:NO animated:YES]; } return cell; } 打印输入,并且它有效。问题是每次我提交一个新值时,都会覆盖打印的旧值。如何将它们打印在一起,无论新旧?每次单击“提交”按钮时,如何打印所有提交的值而不会被覆盖?

一个例子:

如果我输入新名称(例如:echo),则会删除Garry并写入Johny。如何在不被覆盖的情况下打印名称?

以下是代码:

enter image description here

1 个答案:

答案 0 :(得分:0)

您可以将名称保存在会话变量中的数组中。例如:

<?php

session_start();

if(!isset($_SESSION['names'])) {
    $_SESSION['names'] = array(); // create empty array
}

$_SESSION['names'][] = $_POST['name']; // append item to array

?>

这应该会给你一个想法。