Jump to content

Recommended Posts

Ok, I have a DB with some values for forms such as ID, name, etc.  I am trying to get it so if the entry in the db is empty, it wont display it. I think my problem is in the If statements. here is my code:

 

<?php
$get = $_GET['id'];
include ("dbinfo.php");
$sql = "SELECT * FROM admin WHERE ID = '$get'";
$result = mysql_query($sql); print mysql_error();
if(mysql_num_rows($result))
	{
	while($row = mysql_fetch_assoc($result))
		{
		$ID = $row['ID'];
		$dbname = $row['dbname'];
		$phpname = $row['phpname'];
		$textbox = $row['textbox'];
		$tb1id = $row['tb1id'];
		$tb1length = $row['tb1length'];
		$tb1name = $row['tb1name'];
		$tb2id = $row['tb2id'];
		$tb2length = $row['tb2length'];
		$tb2name = $row['tb2name'];
		$tb3id = $row['tb3id'];
		$tb3length = $row['tb3length'];
		$tb3name = $row['tb3name'];
		$tb4id = $row['tb4id'];
		$tb4length = $row['tb4length'];
		$tb4name = $row['tb4name'];
		$tb5id = $row['tb5id'];
		$tb5length = $row['tb5length'];
		$tb5name = $row['tb5name'];
		$textarea = $row['textarea'];
		$ta1id = $row['ta1id'];
		$ta1name = $row['ta1name'];
		$ta2id = $row['ta2name'];
		$ta2name = $row['ta2name'];
		$ta3id = $row['ta3id'];
		$ta3name = $row['ta3name'];
		$ta4id = $row['ta4id'];
		$ta4name = $row['ta4name'];
		$ta5id = $row['ta5id'];
		$ta5name = $row['ta5name'];
		$t = "1";
		$s = " ";
		echo ("<form id=\"$phpname\" name=\"$phpname\" method=\"post\" action=\"/admin_php/$phpname.php\">");

		if ($textbox == $t) {
			if ($tb1id != $s) {
				echo "<tr><td>$tb1name</td><td><input name=\"$tb1id\" type=\"text\" id=\"$tb1id\" size=\"$tb1length\" />");
				}
			if ($tb12id != $s) {
				echo "<tr><td>$tb12name</td><td><input name=\"$tb2id\" type=\"text\" id=\"$tb2id\" size=\"$tb2length\" />");
				}	
			if ($tb3id != $s) {
				echo "<tr><td>$tb3name</td><td><input name=\"$tb3id\" type=\"text\" id=\"$tb3id\" size=\"$tb3length\" />");
				}
			if ($tb4id != $s) {
				echo "<tr><td>$tb4name</td><td><input name=\"$tb4id\" type=\"text\" id=\"$tb4id\" size=\"$tb4length\" />");
				}
			if ($tb5id != $s) {
				echo "<tr><td>$tb5name</td><td><input name=\"$tb5id\" type=\"text\" id=\"$tb5id\" size=\"$tb5length\" />");
				}
			}

		if ($textarea == $t) {
			if ($ta1id != $s) {
				echo ("<tr><td>$ta1name</td></tr><tr><td><script type=\"text/javascript\">var oFCKeditor = new FCKeditor('$ta1id');oFCKeditor.BasePath = \"/fckeditor/\";oFCKeditor.Create();</script></td></tr>");
				}
			if ($ta2id != $s) {
				echo ("<tr><td>$ta2name</td></tr><tr><td><script type=\"text/javascript\">var oFCKeditor = new FCKeditor('$ta2id');oFCKeditor.BasePath = \"/fckeditor/\";oFCKeditor.Create();</script></td></tr>");
				}	
			if ($ta3id != $s) {
				echo ("<tr><td>$ta3name</td></tr><tr><td><script type=\"text/javascript\">var oFCKeditor = new FCKeditor('$ta3id');oFCKeditor.BasePath = \"/fckeditor/\";oFCKeditor.Create();</script></td></tr>");
				}
			if ($ta4id != $s) {
				echo ("<tr><td>$ta4name</td></tr><tr><td><script type=\"text/javascript\">var oFCKeditor = new FCKeditor('$ta4id');oFCKeditor.BasePath = \"/fckeditor/\";oFCKeditor.Create();</script></td></tr>");
				}	
			if ($ta5id != $s) {
				echo ("<tr><td>$ta5name</td></tr><tr><td><script type=\"text/javascript\">var oFCKeditor = new FCKeditor('$ta5id');oFCKeditor.BasePath = \"/fckeditor/\";oFCKeditor.Create();</script></td></tr>");
				}	
			}

		echo ("<input name=\"submit\" type=\"submit\" id=\"submit\" value=\"Submit $dbname\" />");	
		echo ("</form>");


		}
	}
?>

Link to comment
https://forums.phpfreaks.com/topic/88275-solved-need-some-simple-help/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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