/    Sign up×
Community /Pin to ProfileBookmark

Two Problems: SS Structure and a Link

[code=php]<?php

require_once(“path”);

require_once(“path”);

require_once(“path”);

$conn = access;

$query = “SELECT `a`.`post_id`, `a`.`author_id`, `a`.`author_name`, DATE_FORMAT(`a`.`date_posted`, ‘%W, %M %d %Y %l:%i %p’), `a`.`category_id`, `c`.`category_name`, `a`.`title`, `a`.`post_body` FROM `posts` `a` INNER JOIN `categories` `c` ON `a`.`category_id` = `c`.`category_id` ORDER BY `a`.`date_posted` DESC LIMIT 4”;

?>

<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN” “http://www.w3.org/TR/html4/loose.dtd”>
<html>

<head>

<title>Rebirth Test Page</title>

<meta name=”keywords” content=”harry potter,hogwarts,hogwarts rpg,hogwarts online,jk rowling”>
<meta http-equiv=”content-type” content=”text/html; charset=utf-8″>
<meta http-equiv=”cache-control” content=”no-cache”>

<link href=”/css/test.css” rel=”stylesheet” type=”text/css”>

<style type=”text/css”>

#news td
{

padding: 0px 5px 0px 5px;

}

</style>

</head>

<body>

<div id=”wrapper”>

<div id=”headers”>

<div id=”header1″></div>

<div id=”header2″>

</div>

</div>

<div id=”navigation”>

<!– Begin Navigation Menu –>

<?php // include the navigation menu

include(“../includes/navigation2.html”); ?>

<!– End Navigation Menu –>

</div>

<div id=”right”>

<p>Hello!</p>

</div>

<div align=”center” id=”center”>

<div id=”welcome”>

<p>Welcome to Ultimate Hogwarts: The Rebirth! Ultimate Hogwarts is an online Hogwarts Role Playing Game where fans
of the Harry Potter books can create their own character, attend Hogwarts, visit the Ministry of Magic, or just
interact with other characters in our story! If you would like to know more about this site, please visit the Rules
page and FAQ page. Once you’re ready to enroll, you can go to the Character Applications forum at our message board
and begin getting your character approved.</p>

</div>

<p><table id=”news”>

<?php

if ($stmt = $conn->prepare($query))
{

if ($stmt->execute()) {

$stmt->bind_result($postID, $authorID, $author, $date, $catID, $category, $title, $body);

while ($stmt->fetch())
{

echo “<p><tr><td><b>” . strip_tags($title, ‘<p><br><a><b><i>’) . “</b></td></tr>”;
echo “<tr><td><b>Posted By: ” . strip_tags($author, ‘<p><br><a><b><i>’) . ” on ” . $date . ” in ” . strip_tags($category, ‘<p><br><a><b><i>’) . “</b></td></tr>”;
echo “<tr><td>” . BBCOdE(truncate(strip_tags($body, ‘<p><br><a><b><i>’))) . “</td></tr></p>”; } $stmt->close(); } else { echo “Statement doesn’t execute”; } } else { echo “Statement isn’t prepared.”; } $conn->close();

/*var_dump($query);*/ ?>

</table></p>

</div>

</div>

</div>

</body>

</html>[/code]

First, I’m trying to add some blank lines between my news posts to make it easier to read. So far, I have been unsuccessful.

Next, I’m trying to write it where $title is echoed out as a link to another page. How would I do this?

to post a comment
PHP

11 Comments(s)

Copy linkTweet thisAlerts:
@scragarDec 03.2008 — [code=php] echo "<tr class='title'><td><a href='URL'>" . strip_tags($title, '<p><br><a><b><i>') . "</a></td></tr>";
echo "<tr><td><b>Posted By: " . strip_tags($author, '<p><br><a><b><i>') . " on " . $date . " in " . strip_tags($category, '<p><br><a><b><i>') . "</b></td></tr>";
echo "<tr><td>" . BBCOdE(truncate(strip_tags($body, '<p><br><a><b><i>'))) . "</td></tr>"; } $stmt->close(); } else { echo "Statement doesn't execute"; } } else { echo "Statement isn't prepared."; } $conn->close();
[/code]


CSS:
<i>
</i> tr.title
{
margin-top: 20px;
}
tr.title a
{
font-weight: bold;
}
give it a go.
Copy linkTweet thisAlerts:
@Joseph_WitchardauthorDec 04.2008 — Thanks? The link worked, by tr.title didn't really work like I wanted it to. I'm not trying to create any space between the title and its post, I'm trying to create space between whole news posts. So for exampe:

[code=php]echo "<p><tr class='title'><td><a href='/test/show_news" . "/" . $postID . "/" . $title . "'>" . strip_tags($title, '<p><br><a><b><i>') . "</a></td></tr>";
echo "<tr><td><b>Posted By: " . strip_tags($author, '<p><br><a><b><i>') . " on " . $date . " in " . strip_tags($category, '<p><br><a><b><i>') . "</b></td></tr>";
echo "<tr><td>" . BBCOdE(truncate(strip_tags($body, '<p><br><a><b><i>'))) . "</td></tr></p>"; } $stmt->close(); } else { echo "Statement doesn't execute"; } } else { echo "Statement isn't prepared."; } $conn->close();[/code]


needs to be a couple of lines above the news post under it?
Copy linkTweet thisAlerts:
@scragarDec 04.2008 — You can't put paragraphs in the middle of a table, but if you drop the table you can do it with less work:
[code=php]
<div id="news">

<?php


if ($stmt = $conn->prepare($query))
{


if ($stmt->execute()) {

$stmt->bind_result($postID, $authorID, $author, $date, $catID, $category, $title, $body);





while ($stmt->fetch())
{

echo "<div><h2><a href='/test/show_news" . "/" . $postID . "/" . $title . "'>" . strip_tags($title, '<p><br><a><b><i>') . "</a></h2>
<cite><b>Posted By: " . strip_tags($author, '<p><br><a><b><i>') . " on " . $date . " in " . strip_tags($category, '<p><br><a><b><i>') . "</cite>
<blockquote>" . BBCOdE(truncate(strip_tags($body, '<p><br><a><b><i>'))) . "</blockquote></div>"; } $stmt->close(); } else { echo "Statement doesn't execute"; } } else { echo "Statement isn't prepared."; } $conn->close();

/*var_dump($query);*/ ?>

</div>

[/code]
Give that a try then, if need be you can set and adjust padding between the divs:
#news div{
margin-bottom: 20px;
}
Personally I'd offset this by giving a negative margin to cancel this out for the bottom:
#news{
margin-bottom: -20px;
}


Again, give it a go, let me know what you think.
Copy linkTweet thisAlerts:
@Joseph_WitchardauthorDec 04.2008 — [code=php]<table id="news">

<?php


if ($stmt = $conn->prepare($query))
{


if ($stmt->execute()) {

$stmt->bind_result($postID, $authorID, $author, $date, $catID, $category, $title, $body);





while ($stmt->fetch())
{

echo "<div class='extra'>";

echo "<tr class='title'><td><a href='/test/show_news" . "/" . $postID . "/" . $title . "'>" . strip_tags($title, '<p><br><a><b><i>') . "</a></td></tr>";
echo "<tr><td><b>Posted By: " . strip_tags($author, '<p><br><a><b><i>') . " on " . $date . " in " . strip_tags($category, '<p><br><a><b><i>') . "</b></td></tr>";
echo "<tr><td>" . BBCOdE(truncate(strip_tags($body, '<p><br><a><b><i>'))) . "</td></tr></div>"; } $stmt->close(); } else { echo "Statement doesn't execute"; } } else { echo "Statement isn't prepared."; } $conn->close();

/*var_dump($query);*/ ?>

</table>[/code]


CSS:
[CODE]#news
{ margin-bottom: 20px;
}

div.extra
{ margin-bottom: 20px;
}[/CODE]


That's my current code. I took your suggestion and switched to a div and those other tags instead of a table, but I didn't like how the structure was output, so I switched it back to a table. For some reason though, it's like the extra class for my div tags don't even exist. I have Aardvark for Firefox, and it didn't even show up under that.
Copy linkTweet thisAlerts:
@scragarDec 04.2008 — You know if you didn't like the styling that's what CSS is for, it's structure made a lot more sense than a table, also means one nasty piece of content won't break the structure for your entire content.

If you insist on the table you might be able to get away with inserting a few dud TR's, dropping them out for the last row, I'm not sure how that will change your loop though...
Copy linkTweet thisAlerts:
@Joseph_WitchardauthorDec 04.2008 — Is it not a good idea to use tables at all anymore?
Copy linkTweet thisAlerts:
@scragarDec 04.2008 — You're throwing one item in per row, it's not a table if there's no columns, it's a list.

Tables would be good if you broke it up differently, but with only 1 item per row it doesn't suit a table at all.
Copy linkTweet thisAlerts:
@Joseph_WitchardauthorDec 04.2008 — You can view how the structure looks now at this link. However, I am unsure as to how to get the same look using divs and CSS. Can you help me out?:o
Copy linkTweet thisAlerts:
@scragarDec 04.2008 — First, I'd use the [url=http://meyerweb.com/eric/thoughts/2007/05/01/reset-reloaded/]ultimate CSS reset[/url] to get rid of the default styling, then you should be able to make your own adjustments as needed(if you let me know what exactly the problem is I'll be able to help).
Copy linkTweet thisAlerts:
@Joseph_WitchardauthorDec 04.2008 — Would that reset the other CSS I have written in the page (including external stylesheets)?
Copy linkTweet thisAlerts:
@scragarDec 04.2008 — if you put it first the odds are it won't do much, but you don't even need the whole thing, just the bits for the elements annoying you:
#news *{
margin: 0;
padding: 0;
border: 0;
outline: 0;
font-weight: inherit;
font-style: inherit;
font-size: 100&amp;#37;;
font-family: inherit;
vertical-align: baseline;
}
blockquote:before, blockquote:after, q:before, q:after {
content: "";
}
blockquote, q {
quotes: "" "";
}
×

Success!

Help @Joseph_Witchard spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...