Shouldn't matter.
Did the code I pasted in work?
Yes, the code worked when I placed it as is. However, when I tried to plug in "$body" which is the field I am aiming to work with, it produced blank results. Here is my code. there are two pages needed. stories.php lists all records in the table and when you click on the "Edit" button you are directed to stories_update.php which will be the edit page for whichever item you select.
[PHP]
// stories.php
<?php include 'header.php'; ?>
<?php session_start();
header("Cache-control: private"); // IE6 fix for sessions
?>
<form method="POST" action="stories.php">
<table class=\"clear\">
<tr>
<td>Title:</td><td><input type="text" name="title"><input type="SUBMIT" value="Search!" style=\"display:inline; margin-top:0px; margin-bottom:0px;\"></td>
</tr>
</table>
</form>
<br>
<?php
session_destroy();
//Setting session variables
if( isset( $_POST[ 'title' ] ) )
{
$_SESSION['title'] = $_POST['title'];
}
//display search query
if ($title == ""){
echo("");
} else {
echo("
<table border=0 bgcolor=#ff6600><tr><td><font color=white>
You're searching for...<br>
");
}
if ($title != ""){ echo(" Title: ".$title."<br>");}
if ($title == ""){
echo("");
} else {
echo("
</font></td></tr></table>
<table cellpadding=0 cellspacing=0><tr><td>
<form method=POST action=stories.php>
<input type=hidden name=title value=\"\">
<input type=SUBMIT value=\"Clear Search Parameters\">
</form>
</td></tr></table><br>
");
}
// END of search query
// PHP Search Script
$username="***USERNAME***";
$password="***PASSWORD***";
$database="***DATABASE***";
mysql_connect("***SQL***",$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$sql = mysql_query("SELECT * FROM stories WHERE title LIKE '%$title%' ORDER BY title ASC") or die (mysql_error());
//Is displayed if there is no data to return
if(mysql_num_rows($sql) == 0){
echo("<br><br><br><b>No results found...</b><br><br>
Try widening your search a bit. :)
<br><br><br><br><br><br>");
}
// This reads the number of rows returned from the result above.
echo "
<table><tr><TD BACKGROUND=\"http://www.cheezylu.com/cheezylu/images/clear.gif\" align=\"center\">
<table cellpadding=\"1\" cellspacing=\"0\" bgcolor=\"#000000\" BORDER=0><TR><TD>
<table cellpadding=\"5\" cellspacing=\"0\" border=\"0\">
<tr bgcolor=\"#dee8f1\">
<td align=\"left\" colspan=\"4\">
<div class=\"txtTitle\" align=\"center\">Story Listing</div>
</td>
</tr>
";
$j=0;
while(list($id, $topic, $date, $author, $title, $blurb, $body, $imgTitle, $img, $imgType)=mysql_fetch_array($sql)){
if (is_int($j / 2)) {
echo "
<tr bgcolor=\"ffffff\">
<td nowrap>";
if ($img == "")
{
echo "no image";
} else
echo "<img src=\"stories_image.php?id=$id\" height=\"50\" width=\"50\">";
echo " </td>
<td>
<b>$title</b>
</td>
<td>
<form method=\"POST\" action=\"stories_update.php\">
<input type=\"hidden\" name=\"e_id\" value=\"$id\">
<input type=\"submit\" value=\"Edit\" style=\"display:inline; margin-top:0px; margin-bottom:0px;\">
</form>
</td>
<td>
<form method=\"POST\" action=\"stories_delete.php\">
<input type=\"hidden\" name=\"de_id\" value=\"$id\">
<input type=\"submit\" value=\"Delete\" style=\"display:inline; margin-top:0px; margin-bottom:0px;\">
</form>
</td>
</tr>
";
} else {
echo "
<tr bgcolor=\"#f2f2f2\">
<td nowrap>";
if ($img == "")
{
echo "no image";
} else
echo "<img src=\"stories_image.php?id=$id\" height=\"50\" width=\"50\">";
echo " </td>
<td>
<b>$title</b>
</td>
<td>
<form method=\"POST\" action=\"stories_update.php\">
<input type=\"hidden\" name=\"e_id\" value=\"$id\">
<input type=\"submit\" value=\"Edit\" style=\"display:inline; margin-top:0px; margin-bottom:0px;\">
</form>
</td>
<td>
<form method=\"POST\" action=\"stories_delete.php\">
<input type=\"hidden\" name=\"de_id\" value=\"$id\">
<input type=\"submit\" value=\"Delete\" style=\"display:inline; margin-top:0px; margin-bottom:0px;\">
</form>
</td>
</tr>
";
} //end of else
$j++;
} //end of while
echo "</table>
</td></tr></table>
</td></tr></table>";
?>
<?php include 'footer.php'; ?>
[/PHP]
[PHP]
// stories_update.php
<?php include 'header.php'; ?>
<?php session_start();
header("Cache-control: private"); // IE6 fix for sessionsÊÊ
?>
<form enctype="multipart/form-data" name="frmUploadFile" action="stories_updated.php" method="post">
<table border="0"><tr><TD BACKGROUND=\"http://www.cheezylu.com/cheezylu/images/clear.gif\" align=\"center\">
<table cellpadding=\"1\" cellspacing=\"0\" bgcolor=\"#000000\" BORDER=0><TR><TD>
<table cellpadding=\"5\" cellspacing=\"0\" border=\"0\">
<tr bgcolor="#cccccc">
<td colspan="2"><b>Update Story</b></td>
</tr>
<tr bgcolor="#f2f2f2">
<td>Topic:</td>
<td>
<input type="radio" name="topicType" size="20" value="new">New Topic <input type="text" name="ud_topicNew" size="20" maxlength="50"><br/>
<input type="radio" name="topicType" size="20" value="old" checked>Existing Topic
<select name="ud_topicOld">
<?php
// Database connection variables
$dbServer = "***SQL***";
$dbDatabase = "***DATABASE***";
$dbUser = "***USERNAME***";
$dbPass = "***PASSWORD***";
$sConn = mysql_connect($dbServer, $dbUser, $dbPass)
or die("Couldn't connect to database server");
$dConn = mysql_select_db($dbDatabase, $sConn)
or die("Couldn't connect to database $dbDatabase");
$dataPull = "SELECT topic FROM stories WHERE id LIKE '$e_id'";
//Pulls what we want from the database
$data = mysql_query($dataPull) or die("Couldn't get file list");
$j=0;
while(list($topic)=mysql_fetch_array($data)){
echo "
<option value=\"$topic\">$topic *</option>";
$j++;
} //end of while
$dataTopicPull = "SELECT DISTINCT topic FROM stories";
//Pulls what we want from the database
$dataTopic = mysql_query($dataTopicPull) or die("Couldn't get file list");
$j=0;
while(list($topic)=mysql_fetch_array($dataTopic)){
echo "
<option value=\"$topic\">$topic</option>";
$j++;
} //end of while
?>
</select>
</td>
</tr>
<?php
$dataContentPull = "SELECT * FROM stories WHERE id LIKE '$e_id'";
//Pulls what we want from the database
$dataContent = mysql_query($dataContentPull) or die("Couldn't get file list");
//$restored_text = str_replace("\n", "<br />", $body);
$m=0;
while(list($id, $topic, $date, $author, $title, $blurb, $body, $imgTitle, $img, $imgType)=mysql_fetch_array($dataContent)){
echo "
<tr bgcolor=\"#ffffff\">
<td>Date:</td>
<td>
<input type=\"text\" name=\"ud_date\" size=\"15\" maxlength=\"50\" value=\"$date\"> ex: 000-00-00
</td>
</tr>
<tr bgcolor=\"#f2f2f2\">
<td>Author:</td>
<td>
<input type=\"text\" name=\"ud_author\" size=\"30\" maxlength=\"50\" value=\"$author\">
</td>
</tr>
<tr bgcolor=\"#ffffff\">
<td>Story Title:</td>
<td>
<input type=\"text\" name=\"ud_title\" size=\"30\" maxlength=\"50\" value=\"$title\">
</td>
</tr>
<tr bgcolor=\"#f2f2f2\">
<td>Blurb:</td>
<td>
<input type=\"text\" name=\"ud_blurb\" size=\"30\" maxlength=\"100\" value=\"$blurb\">
</td>
</tr>
<tr bgcolor=\"#ffffff\">
<td valign=\"top\">Story:</td>
<td>
<textarea name=\"ud_body\" cols=\"30\" rows=\"10\">$body</textarea>
</td>
</tr>
<tr bgcolor=\"#f2f2f2\">
<td>File Description:</td>
<td>
<input type=\"text\" name=\"ud_imgTitle\" size=\"30\" maxlength=\"50\" value=\"$imgTitle\">
</td>
</tr>
<tr bgcolor=\"#ffffff\">
<td valign=\"top\">Update Image:</td>
<td>
<input type=\"radio\" name=\"imgUpdate\" value=\"clear\">Clear Image<br/>
<input type=\"radio\" name=\"imgUpdate\" value=\"n\" checked>No<br/>
<input type=\"radio\" name=\"imgUpdate\" value=\"y\">Yes
<input type=\"file\" name=\"fileUpload\" size=\"20\"><br/>
</td>
</tr>
<tr bgcolor=\"#f2f2f2\">
<td colspan=\"2\" align=\"center\">
<input type=\"hidden\" name=\"ud_id\" value=\"$id\">
<input type=\"submit\" value=\"Update Story\" name=\"cmdSubmit\">
</td>
</tr>
";
$m++;
} //end of while
?>
</table>
</td></tr></table>
</td></tr></table>
</form>
<?php include 'footer.php'; ?>
[/PHP]