PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 10th, 1999, 12:48 AM
tucats
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
I can't seem to get a background color in the tables that are created from output by mySQL using PhP3... sample output table...:

printf("<tr><td>%s</td><td>%s</td><td>%s</tr>n", $myrow["Name"], $myrow["Location"], $myrow["Cost"]);


I am brand new at this, it is part of my first script...

thank you

Reply With Quote
  #2  
Old December 10th, 1999, 09:47 AM
rod k
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
I don't see any background definitions in your HTML. How are you trying to do it? That's an HTML function, has nothing to do with PHP.

Reply With Quote
  #3  
Old December 10th, 1999, 11:57 AM
tucats
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
I have tried to input the bgcolor everywhere... example...:

printf("<tr><td bgcolor="ff0000">%s</td><td>%s</td><td>%s</tr>n", $myrow["Name"], $myrow["Location"], $myrow["Cost"]);

How would you do this...? All I get is a parse error... anywhere I put "bgcolor="ff0000"... I always get a parse error...

Help...


Reply With Quote
  #4  
Old December 10th, 1999, 12:25 PM
rod k
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Look over your line carefully.. How does PHP know when your string begins and ends with all those " in there? URL

You need to escape the " you want passed as part of the string, or use ' instead.

Examples:

"<tr><td bgcolor="#ff0000">...."
or
"<tr><td bgcolor='#ff0000'> ... "

[This message has been edited by rod k (edited 12-10-99).]

Reply With Quote
  #5  
Old December 10th, 1999, 08:33 PM
tucats
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
That worked wonderfully... thank you so much...

Does anybody know how to rotate colors in the tables created from php3 every other line...?

example:

1st output from mySQL
"<tr><td bgcolor='#ff0000'>%s</td><td bgcolor='#0000ff'>%s</td> ... "

2nd output
"<tr><td bgcolor='#0000ff'>%s</td><td bgcolor='#ff0000'>%s</td> ... "

and have it keep alternating... my script looks like:

mysql_select_db("kidz4dayz_com",$db);

$result = mysql_query("SELECT * FROM $state WHERE City = '$cities'",$db);

if ($myrow = mysql_fetch_array($result)) {

echo "<table border=0 cellpadding=5>n";

echo "<tr>
<td><b>Name</b></td><td><b>Location</b></td><td><b>Cost</b></td>< /tr>n";

echo "<tr></tr>n";
echo "<tr></tr>n";
echo "<tr></tr>n";
do {

printf("<tr><td bgcolor='#c8c8ff'>%s</td><td bgcolor='#7d7dff'>%s</td><td bgcolor='#c8c8ff'>%s</tr>n", $myrow["Name"], $myrow["Location"], $myrow["Cost"]);

} while ($myrow = mysql_fetch_array($result));

echo "n";

} else {

echo "Sorry, no records were found!";
}

?>

</body>

</html>


Thank you...


Reply With Quote
  #6  
Old December 11th, 1999, 11:26 AM
rod k
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
You just need a counter in your do..while.

Like this:

$i=1;
do {
if (is_int($i/2))
{$color=$evenrowcolor;}
else{$color=$oddrowcolor;}

print "<tr><td bgcolor='$color'>whatever</td></tr>";

$i++;
} while ($myrow = mysql_fetch_array($result));

[This message has been edited by rod k (edited 12-11-99).]

Reply With Quote
  #7  
Old December 11th, 1999, 07:04 PM
tucats
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Thanks so much rod... I couldn't get your script to work for some reason but I modified it to look like this:

$i=1;
do {
if (is_int($i/2))

printf("<tr><td bgcolor='#c8c8ff'><a href = 'daycare.php3'>%s</a></td><td bgcolor='#9797ff'>%s</td><td bgcolor='#c8c8ff'>%s</tr>n", $myrow["Name"], $myrow["Location"], $myrow["Cost"]);

else printf("<tr><td bgcolor='#9797ff'><a href = 'daycare.php3'>%s</a></td><td bgcolor='#c8c8ff'>%s</td><td bgcolor='#9797ff'>%s</tr>n", $myrow["Name"], $myrow["Location"], $myrow["Cost"]);



$i++;
} while ($myrow = mysql_fetch_array($result));


And it works great... It gives my results a "checkerboard look"... I am not sure I will use this but I saw it in Bank Ones website and thought it might be fun...

Thanks again...

Also... I am using a javascript for a "back" button...

echo "<a href=javascript:history.go(-1)>Please take me back.</a>";

Is there an easy way I can do this without the java but just with "php3"...

thanks again...


Reply With Quote
  #8  
Old December 22nd, 1999, 09:39 PM
Pointman
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Move your bgcolor into your TR tag instead and you'll get solid colors per line instead of per cell.

That would give you an effect that makes the table easier to read instead of the more difficult checker-board.

Just my $0.02

Reply With Quote
  #9  
Old December 22nd, 1999, 11:20 PM
tucats
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Thank you Pointman, I have tried it both ways and I am not sure wich one I will use yet...

Have a great Christmas...

Also... I am using a javascript (javascript:history.go(-1)) for a back button, is there a way to do this with php3 instead of java...?

Thanks again... URL

[This message has been edited by tucats (edited 12-22-99).]

Reply With Quote
  #10  
Old December 27th, 1999, 11:45 PM
Randy
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
I believe you're looking for the $HTTP_REFERER variable. Something like:

<A href=<?echo $HTTP_REFERER?>>Go Back</a>

You might want to put a little more logic in it to make sure that $HTTP_REFERER is set, and that the page they are going back to is on your site.

Reply With Quote
  #11  
Old December 27th, 1999, 11:47 PM
Randy
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Following up on the last message.. .

Never use JavaScript when you CAN do something server-side. It'll save you a ton of headaches in the long run.

Also, one of the most helpful functions in PHP is the phpinfo() function. Try it! Also try linking from another page to a page with phpinfo() to make sure you get the HTTP_REFERER set.


Reply With Quote
  #12  
Old December 28th, 1999, 09:06 AM
tucats
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Thanks Randy... I will give it a shot... looks like it will work...

Happy NEW YEAR... URL

Reply With Quote
  #13  
Old January 7th, 2000, 05:58 AM
timbo timbo is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 1999
Location: London
Posts: 110 timbo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 22 m 26 sec
Reputation Power: 0
I know this is late in the day but..... here is a simple way to alternate colours across and down the page ..

echo "<tr><td valign="top" bgcolor="";
if($trcount=="0")
{
$bgcolor="#fef7d9";
$trcount++;
}
else
{
$bgcolor="#ffffff";
$trcount--;
}
echo "$bgcolor" width="40"><font face="helvetica" color="#0063a2" size="1"><b>$time</b></font></td>
<td align="top" bgcolor="#ffffff" width="5"></td>
<td valign="top" bgcolor="$bgcolor" width="260"><font face="helvetica" color="#0063a2" size="1"><b>$name</b></font></td>
<td align="top" bgcolor="#ffffff" width="5"></td>
<td valign="top" bgcolor="$bgcolor" width="296"><font face="helvetica" color="#0063a2" size="1">$desc<br><br></td></font></tr>";
}

[This message has been edited by timbo (edited January 07, 2000).]

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > bgcolor in tables from database output


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT