Funky Monk
-
Posts
5 -
Joined
-
Last visited
Never
Posts posted by Funky Monk
-
-
I have an form that spreads over 3 pages. I want to pass a field (the article title) from page 1 to page 2 so that the user can see on page 2 the article that they are adding to. I want this to then update the database so all the details from page 2 are added including the article number. How do I do this?
-
I would like to be able to use Dreamweaver to create a dynamic Repeat Region. Rather than just telll Dreamweaver to display a certain amount of records from the database I would like to be able to select a user-defined number of records to display from a drop-down. For example, 'show 10 records', 'show 20 records' etc. How do I do this?
-
The way the date function works is that if there's no parameter passed to it, it defaults to now, and you're not passing it any parameters.
In order to get the date out of the date field, try
<?php date_added = date("l M d, Y @ g:i A", $_recordset1['date_added']);
echo ($date_added); ?>
I've been having all sorts of trouble with timestamp to date with this function, today I found a MySQL function to pull the data (date) out of the database just as you want it, skipping having PHP reword it, so in my select statement I have
DATE_FORMAT(eventdates.`date`, '%m-%d-%Y') alias
date is a reserved word in SQL, so use the ` to escape it, alias is just a way to give that record a name that the GUI can handle
Thanks for the reply but when I try <?php date_added = date("l M d, Y @ g:i A", $_rsShowNews['date_added']);
echo ($date_added); ?>
I get:
"Parse error: parse error, unexpected '=' in [path to file]"
I don't understand where you get the
"in my select statement I have
DATE_FORMAT(eventdates.`date`, '%m-%d-%Y') alias" from.
Here's the entire code for the page:
<?php require_once('Connections/connNews.php'); ?>
<?php
mysql_select_db($database_connNews, $connNews);
$query_rsShowNews = "SELECT * FROM news_items";
$rsShowNews = mysql_query($query_rsShowNews, $connNews) or die(mysql_error());
$row_rsShowNews = mysql_fetch_assoc($rsShowNews);
$totalRows_rsShowNews = mysql_num_rows($rsShowNews);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<table width="75%" border="0" cellspacing="0" cellpadding="0">
<?php do { ?>
<tr>
<td>Headline</td>
<td><?php echo $row_rsShowNews['news_headline']; ?></td>
</tr>
<tr>
<td>Thumbnail</td>
<td><img src="<?php echo $row_rsShowNews['thumbnail']; ?>" alt="image" name="thumbnail" hspace="5" id="thumbnail" style="background-color: #999999" /></td>
</tr>
<tr>
<td>News</td>
<td><?php echo $row_rsShowNews['news_body']; ?></td>
</tr>
<tr>
<td>Date</td>
<td><?php date_added = date("l M d, Y @ g:i A", $_rsShowNews['date_added']);
echo ($date_added); ?></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<?php } while ($row_rsShowNews = mysql_fetch_assoc($rsShowNews)); ?>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
</table>
</body>
</html>
<?php
mysql_free_result($rsShowNews);
?>
-
I am creating a News management system with PHP and MySQl, developing it in Dreamweaver MX2004 and some hand-coding.
I am having a lot of difficulty getting the date to display on a page. I have a MySQl database as follows:
id int(11) NOT NULL auto_increment,
news_headline varchar(255) NOT NULL default '',
news_body text NOT NULL default '',
date_added timestamp(14) default NULL,
I am using:
<?php date_added = date('l M d, Y @ g:i A');
echo ($date_added); ?>
to display the date and time on the page. This worked fine until I realised that all it is doing is displaying the current date and time, not the date that the article was posted in the database. How do I get it to do this?
More Complex databases
in MySQL Help
Posted
I've been using MySQL for quite a while now but have always used quite simple SQL statements. Now I need to do something a bit more complex (well, it is for me at least).
I am creating a web site that will allow people to regsiter events from all over Europe. The details go into a database for display on their own specific country page. The only way that I can think of doing this at the moment is to create one table and duplicate it 50 times:
#
# Table structure for table `albania`
#
CREATE TABLE `albania` (
`organisation` varchar(255) NOT NULL default '',
`id` int(11) NOT NULL auto_increment,
`event` varchar(255) NOT NULL default '',
`description` text NOT NULL,
`start_date` text NOT NULL,
`end_date` text NOT NULL,
`venue` varchar(255) NOT NULL default '',
`contact_name` varchar(255) NOT NULL default '',
`email` varchar(255) default NULL,
`phone` varchar(80) default NULL,
`website` varchar(255) default NULL,
PRIMARY KEY (`id`)
) TYPE=MyISAM PACK_KEYS=0 AUTO_INCREMENT=2 ;
#
.....and so on.
Then I insert into this table using the following code (created using Dreamweaver MX2004):
<?php require_once('../../Connections/connEWT.php'); ?>
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . date("Y-d-m",strtotime($theValue)) . "'" : "NULL";
break;
case "time":
$theValue = ($theValue != "") ? "'" . date("H:i:s",strtotime($theValue)) . "'" : "NULL";
break;
case "datetime":
$theValue = ($theValue != "") ? "'" . date("Y-d-m H:i:s",strtotime($theValue)) . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "frmAddEvent")) {
$insertSQL = sprintf("INSERT INTO albania (organisation, event, description, start_date, end_date, venue, contact_name, email, phone, website) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['organisation'], "text"),
GetSQLValueString($_POST['event'], "text"),
GetSQLValueString($_POST['description'], "text"),
GetSQLValueString($_POST['start_date'], "date"),
GetSQLValueString($_POST['end_date'], "date"),
GetSQLValueString($_POST['venue'], "text"),
GetSQLValueString($_POST['contact_name'], "text"),
GetSQLValueString($_POST['email'], "text"),
GetSQLValueString($_POST['phone'], "text"),
GetSQLValueString($_POST['website'], "text"));
mysql_select_db($database_connEWT, $connEWT);
$Result1 = mysql_query($insertSQL, $connEWT) or die(mysql_error());
$insertGoTo = "events.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
mysql_select_db($database_connEWT, $connEWT);
$query_rsEvents = "SELECT * FROM albania";
$rsEvents = mysql_query($query_rsEvents, $connEWT) or die(mysql_error());
$row_rsEvents = mysql_fetch_assoc($rsEvents);
$totalRows_rsEvents = mysql_num_rows($rsEvents);
?>
Is there a better way of doing this? What I would like is so that I can from an admin area view events from each country without having to flick through 50 pages and also so that the central admin can add to any of the 50 countries using a drop-down box that has each of the countries in it - ie. 1 page that will allow admins to add to any country page, and 1 page that will display all events by country.