0

i need to Build a form textarea where someone enters a list of books (comma seperated). Use explode to populate an array of the book titles. Loop through and show the book titles on new lines.

any help will be gladly appriacated !

2
Contributors
5
Replies
8
Views
6 Years
Discussion Span
Last Post by Shanti C
0

use explode function..
Assume $_POST is your form textarea name.
see this:

$names = explode(",", $_POST['textareaname']);
print_r($names );
foreach($names as $key=>$value)
{
echo $value;
}
0

thanks shanti :)

up to now my code is like this

<div class="wrapper">
<?php include("includes/header.php"); ?>
<?php include("includes/menu.php"); ?>
<div class="content">
<?php
if ($_POST)
	{
		$names = explode(",", $_POST['textareaname']);
		print_r($names );
		foreach($names as $key=>$value)
		{
		echo $value;
		}
	}
	else
	{
?>
<form method="post" action="">
Insert List of Books:<br />
<textarea name="textareaname" cols="60" rows="5"></textarea>
<input type="submit" value="submit"/>
</form>
<?php } ?>
</div>

what i need to do no is loop the array and show the entries on new lines, can you help me out one last bit ?

use explode function..
Assume $_POST is your form textarea name.
see this:

$names = explode(",", $_POST['textareaname']);
print_r($names );
foreach($names as $key=>$value)
{
echo $value;
}
0

Try this:

echo "Book Names:<br>";
foreach($names as $key=>$value)
{
echo $value."<br>";
}

try this and tel me what printed on browser after submit button clicked..

Edited by Shanti C: n/a

0

works like a charm :D thanks alot for your kind help!

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.