/    Sign up×
Community /Pin to ProfileBookmark

Using CSS with an SQL querri and Using Links in a database

Howdy folks, Below is the code i want to add some detail to!

[code=php]
if (!$result) {
exit(‘<p>Error performing query: ‘ . mysql_error() . ‘</p>’);
}
$num = mysql_num_rows($result);
echo “<div id=”alldetails”>”;
for ($i=0; $i<$num; $i++)
{
$row = mysql_fetch_row($result);
echo “<p id=”person$i”>
$row[1]<br>n
$row[2]<br>n”;

}
echo “</div>”;
[/code]

Ok Row 1 is the Headline title (This is for a news page) and Row 2 is the story! I would like to be able to have a different font and color for both of these becuase at momment they are just the page defaults… So Headline could be arial and bold whilst the story is just arial…

Scot

to post a comment
PHP

7 Comments(s)

Copy linkTweet thisAlerts:
@JDM71488Jan 02.2006 — css will manipulate (x)html... not php, or sql...

use php and sql to print out structured (x)html, and then use css to design your html.
Copy linkTweet thisAlerts:
@chazzyJan 02.2006 — Howdy folks, Below is the code i want to add some detail to!

Ok Row 1 is the Headline title (This is for a news page) and Row 2 is the story! I would like to be able to have a different font and color for both of these becuase at momment they are just the page defaults... So Headline could be arial and bold whilst the story is just arial...

Scot[/QUOTE]


I don't see a row 1 or row 2 in your code. I see an outer div and some number of nested div's.

Also, using a for loop to go through the the array isn't always the best idea. It could generate areas that are blank, it's best to use the while syntax.
Copy linkTweet thisAlerts:
@scottyrobauthorJan 02.2006 — Sorrym

[code=php]
$row[1]<br>n
$row[2]<br>n";
[/code]


This is the output, is there a way of just adding a tag infront of it to say produce this in arial
Copy linkTweet thisAlerts:
@bokehJan 02.2006 — [code=php]echo '<p id="person'.$i.'">
<span style="font-family:arial;">
<span style="font-weight:bold;">
'.$row[1].'</span><br>n
'.$row[2].'</span><br>n';[/code]
Copy linkTweet thisAlerts:
@scottyrobauthorJan 02.2006 — [code=php] if (!$result) {
exit('<p>Error performing query: ' . mysql_error() . '</p>');
}
$num = mysql_num_rows($result);
echo "<div id="alldetails">";
for ($i=0; $i<$num; $i++)
{
$row = mysql_fetch_row($result);
echo "<p id="person$i">
<span style="font-family:arial;font-weight:bold;font-size: 20px;color:#339966;"> $row[1]<br>n </span>
<span style="font-family:helvetica;font-size: 10px;"> $row[2]<br>n </span>"

}
echo "</div>";
[/code]


First line works great, but the second gives me parse errors!

If i have <span style="font-family:helvetica;font-size: 10px;"> $row[2]<br>n </span>" i get a parse error on that line

but if i have <span style="font-family:helvetica;font-size: 10px;"> $row[2]<br>n" </span>

I also get a parse error on that line.. know how to fix it? ( I think its something to do with where the last " is places)
Copy linkTweet thisAlerts:
@chazzyJan 02.2006 — what happens with this code? I don't really see any errors...
[code=php]
if (!$result) {
exit('<p>Error performing query: ' . mysql_error() . '</p>');
}
$num = mysql_num_rows($result);
echo "<div id="alldetails">";
for ($i=0; $i<$num; $i++)
{
$row = mysql_fetch_row($result);
echo "<p id="person$i">";
echo "<span style="font-family:arial;font-weight:bold;font-size:20px;color:#339966;">".$row[1]."<br>n</span>";
echo "<span style="font-family:helvetica;font-size: 10px;">".$row[2]."<br>n </span>";
}
echo "</div>";
[/code]


I think you were missing the semicolon on the end...
Copy linkTweet thisAlerts:
@scottyrobauthorJan 02.2006 — ... Adding a a ; onto the end of mine didnt work and neither did changing it to the code you gave me.. any ideas?
×

Success!

Help @scottyrob 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.16,
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,
)...