sorry for being a beginner but i could not locate your code that is why i am sending this code when i locate yours it gives errors
i really appreciate your help
thanks million times....
<head>
<title> The Internet Joke Database </title>
</head>
<body>
<?php
if (isset($addjoke)): // If the user wants to add a joke
?>
<form action="<?=$PHP_SELF?>" method="post">
<p>Type your joke here:<br />
<textarea name="joketext" rows="10" cols="40" wrap></textarea><br />
<input type="submit" name="submitjoke" value="SUBMIT" /></p>
</form>
<?php
else: // Default page display
// Connect to the database server
$dbcnx = @mysql_connect("localhost", "root", "6160333kut");
if (!$dbcnx) {
echo( "<p>Unable to connect to the " .
"database server at this time.</p>" );
exit();
}
// Select the jokes database
if (! @mysql_select_db("jokes") ) {
echo( "<p>Unable to locate the joke " .
"database at this time.</p>" );
exit();
}
// If a joke has been submitted,
// add it to the database.
if ($submitjoke == "SUBMIT") {
$sql = "INSERT INTO Jokes SET
JokeText='$joketext',
JokeDate=CURDATE()";
if (@($sql)) {
echo("<p>Your joke has been added.</p>");
} else {
echo("<p>Error adding submitted joke: " .
mysql_error() . "</p>");
}
}
echo("<p> Here are all the jokes in our database: </p>");
// Request the text of all the jokes
$result = @mysql_query("SELECT JokeText FROM Jokes");
if (!$result) {
echo("<p>Error performing query: " . mysql_error() . "</p>");
exit();
}
// Display the text of each joke in a paragraph
while ( $row = mysql_fetch_array($result) ) {
echo("<p>" . $row["JokeText"] . "</p>");
}
// When clicked, this link will load this page
// with the joke submission form displayed.
echo("<p><a href='$PHP_SELF?addjoke=1'>Add a Joke!</a></p>");
endif;
?>
</body>
biggus wrote:
there are 2 ways to do this. The way I'd choose is to add more joketext textareas and name them all joketext[]...
<textarea name="joketext[]" rows="10" cols="40" wrap></textarea>
Then loop thru the array $joketext in your PHP, performing an insert for each textarea to have a joke in it. Make sure to look for blank textareas.
<? if($joketext[0]!=""){
if ($joketext[$g]!=""){print $joketext[$g]."";}
print $joketext[$g]."";
}
}else{?>
<form action="<? echo $PHP_SELF;?>">
<textarea name="joketext[]" rows="10" cols="40" wrap></textarea>
<textarea name="joketext[]" rows="10" cols="40" wrap></textarea>
<textarea name="joketext[]" rows="10" cols="40" wrap></textarea>
<textarea name="joketext[]" rows="10" cols="40" wrap></textarea>
<input type=submit>
</form>
<?}?>
Then, instead of where I print them out, put your sql there...
for ($g=0;$g<count($joketext);$g++){
$jokedate=CURDATE();
if ($joketext[$g]!=""){
$sql = "INSERT INTO Jokes(Jok....