Jump to content

help with array output


shotos

Recommended Posts

Hi,

designed a form that allows a user to input data.

the data inputted are stored in an array until all data have

been inputted.

Problem is when i recall the array after the data input, all

earlier inputs are displayed as "array" except for the last

input.

 

any form of help will be appreciated as i would want all data dispayed.

 

<?php
session_start();
ob_start();

if($_POST['check_item'] == '') {header("location:come.php");}
if($_POST['element'] == '') {header("location:come.php");}
if($_POST['labels'] == '') {header("location:come.php");}

/*$items[] = $_POST['check_item'];
$items[] = $_POST['element'];
$items[] = $_POST['labels'];*/
$items = array($_POST['check_item'],$_POST['element'],$_POST['labels']);

$title = $_POST['title'];
$num_items = $_POST['num_items'];
$count = $_POST['count'];

$check[] = $_POST['result'];
$result = array_merge($check,$items);
if($count< $num_items)
{
?>

<div id="container">
<head>
<link rel="stylesheet" type="text/css" href="new.css" />
<title>Checklist System</title>
</head>
<body>
<div id="banner">
<h1>Checklist System</h1> 
</div>

<div id="nav"color="backgrounds/blue01">
Welcome <?php echo $_SESSION['user'] ?><br><br><br>
<a href="view_users.php">View Users</a><br><br><a href="create_User.php">Create User Accounts</a><br><br><a href="edit_delete_user.php">Edit/Delete User</a><br><br><a href="end.php">Generate Checklist</a><br><br><a href="login_success.php">View all Checklists</a><br><br><br><a href="log_out.php">Sign Out</a>
</div>

<div id="content">
<h2>Enter Check Item and its Properties </h2>
<form method="POST" action="<?php $_SERVER['PHP_SELF']?>">
<input type="hidden" id="title" name="title" value="<?php echo $title;?>">
<input type="hidden" id="num_items" name="num_items" value="<?php echo $num_items;?>">
<input type="hidden" id="count" name="count" value="<?php echo $count + 1;?>">
<table border="0" align="center" cellpadding="10" cellspacing="10">
<tr>
<td>Check Item: <input type="text" name="check_item"></td></tr>
<tr><td><h3>Select Check Item's Corresponding Checklist Element</h3></td></tr>
<tr>
<td><input type="radio" name="element" value="radio">Radio Button<br></td>
</tr>
<tr>
<td><input type="radio" name="element" value="checkbox">Checkbox<br></td>
</tr>
<tr>
<td><input type="radio" name="element" value="text">Textbox<br></td>
</tr> 
<tr><td>&nbsp</td></tr>
<tr><td><h4>Enter Labels for the chosen checklist element</h4></td></tr>
<td><FONT color="red" size="1">***enter labels seperated by underscores (_)***</FONT></td></tr>
<tr>
<td>Label : <input type="text" name="labels" size="50"></td></tr>

<tr><td>&nbsp</td></tr>

<tr>
<td ><input type="hidden" id="result" name="result" value="<?php echo $result;?>">
</td></tr>
<tr>
<td align="center"><input type="submit" name="submit" value="Submit">
</td></tr>
</table>
</form>
</div>

</body>	
</div>
<?php
}
else
{
/*for($row=0;$row<($num_items*3);$row++)
{
	print("$result[$row]<br>");
}*/
//print_r($result);
foreach ($result as $value)
{
echo "$value\n";
}
}
ob_flush();
?>



Link to comment
https://forums.phpfreaks.com/topic/116318-help-with-array-output/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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