i list the newest articles from 2 tables. The title of each is a link to its $copy row, where the article is stored. it uses the id row passed on to anothere ph file and lists the title and copy with the corresponding id#.
now the problem is the link from the second database loads the copy from the first database. Any easy way i can specify the database to load it from?
any help will be great.
link= http://www.gelphoto.com/geluk/html/
newest links from two databases:
<?
include("../conf.php");
include("../functions.php");
$connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!");
$tablename_one = "talent_feat";
$tablename_two = "comp_feat";
mysql_select_db($db) or die ("Unable to select database!");
$query = "SELECT id, function, date, title, copy,link, image_ref FROM $tablename_one ORDER BY date DESC LIMIT 1";
$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
$querytwo = "SELECT id, function, date, title, copy,link, image_ref FROM $tablename_two ORDER BY date DESC LIMIT 1";
$resulttwo = mysql_query($querytwo) or die ("Error in query: $query. " . mysql_error());
if (mysql_num_rows($result) > 0)
{
while($row = mysql_fetch_object($result)){
$id = $row['id'];
$function = $row['function'];
$date = $row['date'];
$title = $row['title'];
$copy = $row['copy'];
$date = $row['date'];
$link = $row['link'];
$image_ref = $row['image_ref'];
$display_block .= "TALENT FEATURE<br> <a href=\"story.php?id=$row->id \"target=\"content\"> $row->title </a>.
<br><br>";
}
}
if (mysql_num_rows($resulttwo) > 0)
{
while($row = mysql_fetch_object($resulttwo)){
$display_block .= "COMPANY FEATURE<br> <a href=\"story.php?id=$row->id \"target=\"content\"> $row->title </a>
$copy
<br><br>";
}
}
echo "$display_block";
?>
story.php =
<?
// includes
include("../conf.php");
include("../functions.php");
$tablename_one = "talent_feat";
$tablename_two = "comp_feat";
// open database connection
$connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!");
// select database
mysql_select_db($db) or die ("Unable to select database!");
// generate and execute query
$query = "SELECT id, function, date, title, copy, link, image_ref FROM $tablename_one WHERE id = '$id'";
$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
$querytwo = "SELECT id, function, date, title, copy, link, image_ref FROM $tablename_two WHERE id = '$id'";
$resulttwo = mysql_query($querytwo) or die ("Error in query: $query. " . mysql_error());
// get resultset as object
$row = mysql_fetch_object($result);
// print details
if ($row)
{
?>
<p><font size="2" color="black"><b><? echo $row->title; ?></b></p>
<p><font size="2" color="black"><? echo ($row->copy); ?></font></p>
<p><font size="2" color="black"><? echo formatDate($row->date); ?>.</font><BR><?
}
else
{
mysql_close($connection);
echo "$display_block";
?>