alphadeltaviii Posted January 28, 2008 Share Posted January 28, 2008 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 More sharing options...
PHP Monkeh Posted January 28, 2008 Share Posted January 28, 2008 Ok that's a lot of if() statements for checking if they're empty, although, have you tried changing $s = " " to $s = "" Maybe that'll do what you like Small change that I'm hoping fixes everything Link to comment https://forums.phpfreaks.com/topic/88275-solved-need-some-simple-help/#findComment-451708 Share on other sites More sharing options...
pocobueno1388 Posted January 28, 2008 Share Posted January 28, 2008 Instead of your IF statements looking like if ($tb1id != $s) { Do it like this if (!empty($tb1id)) { Link to comment https://forums.phpfreaks.com/topic/88275-solved-need-some-simple-help/#findComment-451710 Share on other sites More sharing options...
alphadeltaviii Posted January 28, 2008 Author Share Posted January 28, 2008 I just tried that, didn't seem to work. I know my problem is in the If statements somewhere Link to comment https://forums.phpfreaks.com/topic/88275-solved-need-some-simple-help/#findComment-451711 Share on other sites More sharing options...
alphadeltaviii Posted January 28, 2008 Author Share Posted January 28, 2008 Instead of your IF statements looking like if ($tb1id != $s) { Do it like this if (!empty($tb1id)) { i'll try that, thanks Link to comment https://forums.phpfreaks.com/topic/88275-solved-need-some-simple-help/#findComment-451713 Share on other sites More sharing options...
alphadeltaviii Posted January 28, 2008 Author Share Posted January 28, 2008 ok,I got it working. thanks! Link to comment https://forums.phpfreaks.com/topic/88275-solved-need-some-simple-help/#findComment-451730 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.