plugnz Posted May 17, 2010 Share Posted May 17, 2010 I have a content management script set up so that the main body of the page can be modified by the website administrator. Basically when the administrator first arrives at the page I want them to see empty text boxes to fill the info and then submit to the database. Once the info has been stored the same page should then show the info in the text boxes and a save changes button now shows and any changes made ti the text then updates the info. What I haven't been able to acheive is to get the script to check the database to see if the info exists, and then show the empty text boxes. I know its probably a real simple thing to do.... but ..help. heres my go at it... // request info from content number '0' and show in text boxes with save changes button if ($_REQUEST['content_type_id']== 0 ) { $sql1 = "SELECT title, body, main_header, content_type_id, author_id, page_id " . "FROM cms_content " . "WHERE page_id= 'about' AND content_type_id= '0'"; $result1 = mysql_query($sql1,$conn) or die(mysql_error()); while ($row = mysql_fetch_array($result1)) { extract($row); echo ' <h2>Change main header here</h2> '; //etc etc echo ' <input type="submit" class="submit" name="action" ' . "value=\"Save Changes\">\n"; //if empty then show empty boxes and submit button. } } else if ($_REQUEST['content_type_id']<'0' ) { echo ' <h2>Add main header here</h2> '; //etc etc echo ' <input type="submit" class="submit" name="action" ' . "value=\"Submit New Content\">\n"; } // otherwise if user non-admin just show info as should be displayed } else{ $sql2 = "SELECT title, body, main_header, content_type_id, author_id, page_id " . "FROM cms_content " . "WHERE page_id= 'about' AND content_type_id= '0'"; $result2 = mysql_query($sql2,$conn) or die(mysql_error()); while ($row = mysql_fetch_array($result2)) { extract($row); //etc etc I think the issue is in the... } else if ($_REQUEST['content_type_id']<'0' ) { bit. any thoughts? Quote Link to comment https://forums.phpfreaks.com/topic/202032-if-database-tables-empty-then-do-this/ Share on other sites More sharing options...
trq Posted May 17, 2010 Share Posted May 17, 2010 Take a look at mysql_num_rows. Quote Link to comment https://forums.phpfreaks.com/topic/202032-if-database-tables-empty-then-do-this/#findComment-1059441 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.