charter
12-15-2004, 02:04 PM
Can anyone please help?
I have a flat MySql database which has 100 rows that have the same date and week no.
It is a list for music charts.
These are the databse table fields.
tw lw wks title artist date week no.
It goes through until it has found all 100 of the same date from the search.
The thing is I want it to show the date but just once in a certain place.
Also I want the date to show as dd/mm/yyyy Not as yyyy/mm/dd.
This is the php code of my results page. I have put password where my password is and put it in bold where I want the date to be.
At the moment I am having to enter the date manually.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>usold90</title>
<?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('charts90db', $link_id);
$result = mysql_query("SELECT * FROM `usa` WHERE `{$searchtype}` LIKE '%{$searchterm}%'");
?>
</head>
<body bgcolor="#0000FF"><div align="center">
<table class="table" width="760" height="266" border="0" cellpadding="5" cellspacing="0">
<tr align="center">
<td colspan="4" valign="top"> <div align="center"><img src="../oldies/images/singleUSA.gif" width="389" height="56"></div></td>
<td width="219" rowspan="3" valign="top" bgcolor="#5e90cb"> <div align="center"><img src="../oldies/images/eu-flag1.gif" width="152" height="108" align="middle"></div></td>
</tr>
<tr>
<td width="102" valign="top"><div align="center"></div></td>
<td width="194" valign="top" bgcolor="#00FFFF"><font color="#FFFFFF" face="Arial Black">week
ending </font></td>
<td width="194" valign="top" bgcolor="#00FFFF"><div align="right"><font color="#FFFF00" face="Arial Black">04.01.90</font></div></td>
<td width="93" valign="top"> </td>
</tr>
<tr>
<td height="29" colspan="4" class="years-ago">15 years ago </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=\"../oldies/images/new2.gif\" alt=\"new!\" />"
: $item['lw'];
$item['wks'] = stripslashes($row['wks']);
$item['title'] = strtoupper(stripslashes($row['title']));
$item['artist'] = stripslashes($row['artist']);
?>
<tr>
<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>
</body>
</html>
Everything else works fine.
All Help much appreciated.
I have a flat MySql database which has 100 rows that have the same date and week no.
It is a list for music charts.
These are the databse table fields.
tw lw wks title artist date week no.
It goes through until it has found all 100 of the same date from the search.
The thing is I want it to show the date but just once in a certain place.
Also I want the date to show as dd/mm/yyyy Not as yyyy/mm/dd.
This is the php code of my results page. I have put password where my password is and put it in bold where I want the date to be.
At the moment I am having to enter the date manually.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>usold90</title>
<?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('charts90db', $link_id);
$result = mysql_query("SELECT * FROM `usa` WHERE `{$searchtype}` LIKE '%{$searchterm}%'");
?>
</head>
<body bgcolor="#0000FF"><div align="center">
<table class="table" width="760" height="266" border="0" cellpadding="5" cellspacing="0">
<tr align="center">
<td colspan="4" valign="top"> <div align="center"><img src="../oldies/images/singleUSA.gif" width="389" height="56"></div></td>
<td width="219" rowspan="3" valign="top" bgcolor="#5e90cb"> <div align="center"><img src="../oldies/images/eu-flag1.gif" width="152" height="108" align="middle"></div></td>
</tr>
<tr>
<td width="102" valign="top"><div align="center"></div></td>
<td width="194" valign="top" bgcolor="#00FFFF"><font color="#FFFFFF" face="Arial Black">week
ending </font></td>
<td width="194" valign="top" bgcolor="#00FFFF"><div align="right"><font color="#FFFF00" face="Arial Black">04.01.90</font></div></td>
<td width="93" valign="top"> </td>
</tr>
<tr>
<td height="29" colspan="4" class="years-ago">15 years ago </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=\"../oldies/images/new2.gif\" alt=\"new!\" />"
: $item['lw'];
$item['wks'] = stripslashes($row['wks']);
$item['title'] = strtoupper(stripslashes($row['title']));
$item['artist'] = stripslashes($row['artist']);
?>
<tr>
<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>
</body>
</html>
Everything else works fine.
All Help much appreciated.