I have 2 questions:
1) I currently access my front page database (for top 10 results) with this code:
Code: Select all
<?php
$dbname="mydb1";
$host="localhost";
$user="myusername";
$pass="mypw";
$link = mysql_connect($hostname, $user, $pass);
mysql_select_db($dbname, $link);
?>Code: Select all
<?php
$dbname="mydb1";
$host="localhost";
$user="myusername";
$pass="mypw";
$link = mysql_connect($hostname, $user, $pass);
mysql_select_db($dbname, $link);
?>
<?php
$dbname="mydb2";
$host="localhost";
$user="myusername";
$pass="mypw";
$link = mysql_connect($hostname, $user, $pass);
mysql_select_db($dbname, $link);
?>
<?php
$dbname="mydb3";
$host="localhost";
$user="myusername";
$pass="mypw";
$link = mysql_connect($hostname, $user, $pass);
mysql_select_db($dbname, $link);
?>Code: Select all
<?php
$dbname="mydb1";
$host="localhost";
$user="myusername";
$pass="mypw";
<?php
$dbname="mydb2";
$host="localhost";
$user="myusername";
$pass="mypw";
<?php
$dbname="mydb3";
$host="localhost";
$user="myusername";
$pass="mypw";
$link = mysql_connect($hostname, $user, $pass);
mysql_select_db($dbname, $link);
?>Question 2:
Could someone one whip up a quick php script that says...
If Monday, use mydb1;
If Tuesday, use mydb2;
If Wednesday, use mydb3;
// Obviously, I could add the rest of the days if I could get this.
This is how I currently pull the top 10 to the front page:
Code: Select all
<?php
$sql_statement = 'SELECT title, description FROM mytable ORDER BY date DESC LIMIT 0 , 10';
$result = mysql_query($sql_statement, $link);
while ($curr_row = mysql_fetch_assoc($result)) {
$title = $curr_row['title'];
$title = str_replace("-", " ", $title);
$title = strtoupper($title);
$description = $curr_row['description'];
$description = substr($description,0,300);
echo '<font size="2" face="sans-serif"><b><h5>' . $title . '</h5></b>' . ' ' . $description . '...</font>';
}
mysql_free_result($result);
?>Jeff