/    Sign up×
Community /Pin to ProfileBookmark

2 php results problems

I have a results page that is built using PHP.

The results of which are in a table.
I want the table rows to be of alternating colours (light and dark blue)
Could someone please helpme by modifying the uploaded code so that ROW 1 is coloured #00ffff ROW 2 #0000ff ROW 3 #00ffff ROW 4 #0000ff and so on.

The other problem is on line 118 (in Dreamweaver that is) that is coded
<td height=”66″ valign=”top”> <div align=”center”><img src=”../images/dates/56/00.gif” width=”388″ height=”56″></div></td>
At the moment I am using an image for the date as in PHP it only prints the date in the format YYYY/MM/DD but I want the date to be shown in the format DD/MM/YYYY

If someone could please amend the code so that the image is no longer needed and that the date would show as DD/MM/YYYY format

I have uploaded all the code in the zip file.

All help is very much appreciated.

[upl-file uuid=c14b6ebc-d9e7-4e26-aa81-6be9278999af size=2kB]code.zip[/upl-file]

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@bokehFeb 06.2006 — Something like this?[code=php]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>UK charts</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="description" content="these are the UK charts from the 1950s">
<meta name="keywords" content="oldies,chart,yesteryear,years gone by archives, old, 1950's, 50's, 1950s, 50s.">
<style>
.tw {
font-family: Arial, Helvetica, sans-serif;
font-size: 11px;
font-style: normal;
font-weight: normal;
color: #FFFFFF;
text-align: center;
border: none;
}
.lw {
font-family: Arial, Helvetica, sans-serif;
font-size: 11px;
font-style: normal;
font-weight: normal;
color: #00FFFF;
text-align: center;
text-transform: uppercase;
}
.headings {
font-family: Tahoma, Arial, Verdana;
font-size: 11px;
font-style: normal;
font-weight: bold;
color: #FFFF00;
text-align: center;
background-color: #6699cc;
}
.title { font-family: Arial, Helvetica, sans-serif; font-size: 11px; font-style: normal; font-weight: bold; color: #FFFFFF; text-align: left}
.artist { font-family: Arial, Helvetica, sans-serif; font-size: 11px; font-style: normal; font-weight: normal; color: #FFFFFF; text-align: left}
.date {
font-family: Tahoma, Arial, sans-serif;
font-size: 11px;
font-weight: normal;
text-align: left;
}
.wks {
font-family: Arial, Helvetica, sans-serif;
font-size: 11px;
font-weight: normal;
color: #FFFF00;
text-align: center;
}
.table {
background-color: #6699cc;
padding: 2px;
width: 760px;
border: thin solid #000000;
}
.body {
background-color: #255771;
}
tr {
background-color: #2164c4;
}
.years-ago {
font-family: Arial, Helvetica, sans-serif;
font-size: 16px;
font-weight: bold;
color: #FF0000;
text-align: center;
border: none;


}
.table2 {
background-color: #6699cc;
padding: 2px;
width: 774px;
border: thin solid #000000;
}

.light_blue{
background:#ccf;
}

.dark_blue{
background:#77b;
}
</style>

<?php
// create short variable names

if(ini_get('register_globals') != "1")
{
$post = (floatval(substr(phpversion(), 0, 3)) >= 4.1) ? $_POST : $HTTP_POST_VARS;

foreach($post as $key => $value)
{
$$key = $value;
}
}
$searchtype = addslashes(trim($searchtype));
$searchterm = addslashes(trim($searchterm));

if(!$searchtype || !$searchterm)
{
exit('You have not entered search details. Please go back and try again.');
}
$link_id = @mysql_connect("localhost", "root", "password");

if($link_id === false)
{
exit("Error, Could not connect to the system database. Sorry...");
}
mysql_select_db('charts50db', $link_id);
$result = mysql_query("SELECT * FROM uk WHERE {$searchtype} LIKE '%{$searchterm}%'");

?>
</head>

<body bgcolor="#0000FF"><div align="center">
<table class="table" width="760" height="233" border="0" cellpadding="5" cellspacing="0">
<tr align="center">
<td width="561" valign="top"> <div align="center"><img src="../images/singleUK.jpg" width="389" height="56"></div></td>
<td width="175" rowspan="3" valign="middle" bgcolor="#5e90cb"> <div align="center"><img src="../images/flags/uk.gif" width="80" height="58"></div></td>
</tr>
<tr>
<td height="66" valign="top"> <div align="center"><img src="../images/dates/56/00.gif" width="388" height="56"></div></td>
</tr>
<tr>
<td height="26" class="years-ago">50 Years Ago<br>
listen to a clip from the No. 1 single <img src="../images/speaker.gif" width="16" height="15"></td>
</tr>
<tr align="left">
<td height="29" colspan="5" class="years-ago"> <table width="100%" border="0" cellspacing="0" cellpadding="1">
<tr class="headings">
<tr>
<th class="headings" width="28">TW</th>
<th class="headings" width="53">LW</th>
<th class="headings" width="28">Wks</th>
<th class="headings" width="340">Title</th>
<th class="headings" width="307">Artist</th>
</tr>
<?php
$i = 1;
while ($row = mysql_fetch_assoc($result)) {
$item = array();
$item['tw'] = stripslashes($row['tw']);
$item['lw'] = stripslashes($row['lw']);

// now we can override that
$item['lw'] = ($item['lw']=='new')
? "<img src="../images/new2.gif" alt="new!" />"
: $item['lw'];


$item['wks'] = stripslashes($row['wks']);
$item['title'] = strtoupper(stripslashes($row['title']));
$item['artist'] = stripslashes($row['artist']);
?>
<tr <?php echo($i%2)?'class="light_blue"':'class="dark_blue"'?>>
<td width="28" class="tw"><?php echo $item['tw']; ?></td>
<td width="53" class="lw"><?php echo $item['lw']; ?></td>
<td width="28" class="wks"><?php echo $item['wks']; ?></td>
<td width="340" class="title"><?php echo $item['title']; ?></td>
<td width="307" class="artist"><?php echo $item['artist']; ?></td>
</tr>
<?php $i++; } ?>
</table></tr>
</table>

</body>
</html>
[/code]
×

Success!

Help @charter 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.15,
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,
)...