Search the Community
Showing results for tags 'separate'.
-
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've got the following code below and it works great. It's list all the entrys in the database that meet those specifications and it's sorted by the title of need and the ID. My question is is there a way to put a space between the different titled groups. Right now it looks like this: Title1 Title1 Title1 Title2 Title3 Title3 But I'd like for it to look like this: Title1 Title1 Title1 Title2 Title3 Title3 I'm not sure how to go about it. Thanks for the help! $query = mysql_query("SELECT * FROM needs WHERE status !='hidden' AND status !='denied' AND status !='deleted' AND status !='expired' AND (workerfoldername IS NULL OR workerfoldername='') AND (needsusername='$username' OR workerusername='$username') ORDER BY titleofneed, ID"); echo "<table border='1'><tr><th><center>Title of Need</center></th><th><center> Organization </center></th><th><center>Needs Username</center></th><th><center>Worker Username</center></th><th><center>City, State</center></th></tr>"; while ($rows = mysql_fetch_array($query)) { $id = $rows['ID']; $status = $rows['status']; $firstname = $rows['firstname']; $city = $rows['city']; $state = $rows['state']; $phone = $rows['phone']; $email = $rows['email']; $typeofneed = $rows['typeofneed']; $description = $rows['description']; $workername = $rows['workername']; $workeremail = $rows['workeremail']; $workerphone = $rows['workerphone']; $completiondate = $rows['completiondate']; $needsusername = $rows['needsusername']; $workerusername = $rows['workerusername']; $howmanypeopleneeded = $rows['howmanypeopleneeded']; $howmanypeoplesignedup = $rows['howmanypeoplesignedup']; $titleofneed = $rows['titleofneed']; $theneedsfoldername = $rows['needsfoldername']; $theworkerfoldername = $rows['workerfoldername']; if (($needsusername == $username && $theneedsfoldername == '') || ($workerusername == $username && $theworkerfoldername == '')) { $orgname = $rows['orgname']; $expiredate = $rows['expiredate']; echo " <tr><td>$titleofneed</td><td>$orgname</td><td>$needsusername</td><td>$workerusername</td><td>$city, $state</td><td>view more</td></tr> "; } }