Search the Community
Showing results for tags 'clean'.
-
I've always found the task difficult. I use includes and functions wherever I can, but sometimes it seems impossible. Take this code for example: <div> <?php $gotContents = printContents($linkDB, 'home'); foreach($gotContents as $k){ echo "<div class = \"catContents\">"; echo "<div class = \"contentTitle\">".contentTitle($linkDB, $k)[0]."</div>"; echo cutContent($k); echo "</div>"; } ?> </div> Here, there's no way (that I can see) to separate the HTML from the PHP; I can't divide the code into different files since I need parts of it to be encased in DIVs. So, is this type of code acceptable, or is there a better way to handle it? If so, how? Thanks in advance for any replies. EDIT: Also, I'm not interested in using any third-party software/add-on- just raw PHP and HTML please.
-
I'm letting the admin users be able to create tables for polls and this is the query i have: $aquery = $con->prepare("ALTER TABLE `$table` ADD `$field` $enum DEFAULT '$def' NOT NULL"); the $table and $enum fields are both coming from another table so they are safe, but the $def and $field variables are both coming from the user. How can i check to be sure they are safe to use. I've tried this $aquery->bindParam(':field', $field); $aquery->bindParam(':def', $def); but that doesn't work