/    Sign up×
Community /Pin to ProfileBookmark

formating with divs

Hi

Below is a loop that lists enteries in my data base. I’m trying to add divs that will place a box around each entery with some formating using css.

I cannot get it to work it will dispay the box but each item is placed withing each other inside another box

any help is great

[code=php]
$i=0;

while ($i < $num) {
echo ‘<div id= “formmessage”>’;
$fistname = mysql_result($result,$i,”childfirstname”);
$lastname = mysql_result($result,$i,”childlastname”);
$dob = mysql_result($result,$i,”childdob”);

echo “First Name: $fistname<br>
Last Name: $lastname<br>
DOB: $dob
<br>”;
echo ‘<br>’;
echo ‘<div>’;
$i++;

}
echo ‘<div>’;
?>

[/code]

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@aussie_girlJul 26.2006 — I can see open <div> brackets but no closed ones </div> try putting

echo '<div id= "formmessage">'; after the variables
Copy linkTweet thisAlerts:
@NogDogJul 26.2006 — Assigning the same ID to multiple HTML elements is invalid. Try using a class instead (and remember to change the "#" to a "." in the relevant style sheet selector).
Copy linkTweet thisAlerts:
@kprocauthorJul 26.2006 — thanks for the replys.

I have it working somewhat. the boxes are correct but I want a space bewteen each entery

New php

[code=php]
while ($i < $num) {
echo '<div class= "cildright">';
$fistname = mysql_result($result,$i,"childfirstname");
$lastname = mysql_result($result,$i,"childlastname");
$dob = mysql_result($result,$i,"childdob");


echo "<p>First Name: $fistname<br>
Last Name: $lastname<br>
DOB: $dob</p><br>";

echo '<div>';
$i++;

}

?>
[/code]


CSS

<i>
</i>
.cildright {
background-color:F1F7FA;
border:1px solid #AEC7D2;
color: #12527A;
width:200px;


Copy linkTweet thisAlerts:
@NogDogJul 26.2006 — You really don't need a DIV:
[code=php]
while ($row = mysql_fetch_assoc($result)) {
$fistname = $row["childfirstname"];
$lastname = $row["childlastname"];
$dob = $row["childdob"];
echo "<p class='cildright'>First Name: $fistname<br>
Last Name: $lastname<br>
DOB: $dob</p>";
}
[/code]

CSS:
<i>
</i>.cildright {
background-color:F1F7FA;
border:1px solid #AEC7D2;
color: #12527A;
width:200px;
margin: 10px 0; /* adjust as desired */
padding: 10px; /* adjust as desired */
}
×

Success!

Help @kproc 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 6.17,
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: @nearjob,
tipped: article
amount: 1000 SATS,

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

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...