if you followed the code from yesterday you'll notice a couple of things.
1. this isn't a tutorial - Sorry. more like the ramblings of a
troubled programmer. These notes are as much for my own learning
progress, and I am not really taking the time to double read these notes.
2. there were loads of gaps in the code.
I hope these notes are clear enough though to help trigger
somepeoples understanding of php/mysql.
#########################
Mainly I should have explained the mysql setup and what's being
achieved. here's the statement for the mysql I have used in this
part of the booking calender project
CREATE TABLE `landlords` (
`lid` int(6) unsigned NOT NULL auto_increment,
`fname` varchar(55) default '0',
`lname` varchar(55) NOT NULL default '',
`propertyCount` int(5) NOT NULL,
`phone` varchar(25) default '0',
PRIMARY KEY (`lid`)
) ENGINE=MyISAM AUTO_INCREMENT=25 DEFAULT CHARSET=latin1
AUTO_INCREMENT=25 ;
CREATE TABLE `listings` (
`rid` int(15) NOT NULL auto_increment,
`llid` int(6) NOT NULL default '0',
`rtype` varchar(25) NOT NULL default '',
`addone` varchar(75) NOT NULL default '',
`addtwo` varchar(75) NOT NULL default '',
`city` varchar(35) NOT NULL default '',
`state` varchar(25) NOT NULL default '',
`postcode1` varchar(6) NOT NULL,
`postcode2` varchar(6) NOT NULL,
`pets` char(3) NOT NULL default '',
`websiteURL` varchar(120) NOT NULL,
`descrip` text NOT NULL,
`bed` int(2) NOT NULL default '0',
`bath` char(2) NOT NULL default '',
`garage` char(3) NOT NULL default '',
`yard` char(3) NOT NULL default '',
`utilities` varchar(5) NOT NULL default '',
`rent` varchar(10) NOT NULL default '0.00',
`deposit` varchar(10) NOT NULL default '0.00',
`listdate` date NOT NULL default '0000-00-00',
`img1` varchar(25) NOT NULL default '',
`img2` varchar(25) NOT NULL default '',
`img3` varchar(25) NOT NULL,
`img4` varchar(25) NOT NULL,
`img5` varchar(25) NOT NULL,
`img6` varchar(25) NOT NULL,
`img7` varchar(25) NOT NULL,
`img8` varchar(25) NOT NULL,
KEY `lstid` (`rid`),
KEY `city` (`city`),
KEY `pets` (`pets`),
KEY `bed` (`bed`),
KEY `bath` (`bath`),
KEY `garage` (`garage`),
KEY `yard` (`yard`)
) ENGINE=MyISAM AUTO_INCREMENT=40 DEFAULT CHARSET=latin1
AUTO_INCREMENT=40 ;
CREATE TABLE `users` (
`userid` int(10) NOT NULL auto_increment,
`llid` int(10) NOT NULL default '0',
`fname` varchar(35) NOT NULL default '',
`lname` varchar(35) NOT NULL default '',
`email` varchar(75) NOT NULL default '',
`addone` varchar(75) NOT NULL default '',
`addtwo` varchar(75) NOT NULL default '',
`city` varchar(35) NOT NULL default '',
`state` varchar(25) NOT NULL default '',
`zip` varchar(15) NOT NULL default '',
`phone` varchar(25) NOT NULL default '',
`passwd` varchar(35) NOT NULL default '',
`tdate` date NOT NULL default '0000-00-00',
KEY `userid` (`userid`),
KEY `email` (`email`),
KEY `passwd` (`passwd`),
KEY `date` (`tdate`)
) ENGINE=MyISAM AUTO_INCREMENT=21 DEFAULT CHARSET=latin1
AUTO_INCREMENT=21 ;
CREATE TABLE `weeks` (
`llid` int(5) NOT NULL,
`rid` int(5) NOT NULL,
`dayID` int(2) NOT NULL,
`monthID` int(2) NOT NULL,
`yearID` int(4) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
--
-- Dumping data for table `weeks`
--
INSERT INTO `weeks` (`llid`, `rid`, `dayID`, `monthID`, `yearID`)
VALUES (21, 38, 15, 12, 2008),
(21, 38, 1, 1, 2008),
(21, 38, 15, 12, 2008);
################################################################
You may have also noticed that there is a major problem with the
code from yesterday. Being that it was only doing a check on
'landlord' and not on each individual listing. Fine if landlords
only list 1 product or are available on the same day.
the main thing I had to change is the mysql statements in
landlords/calendarListingEdit.php
Here are the changes that I made.
>>>>>>>>>>>>>>>>>>>>>>
FIND:
if ($_GET['dayID'] && $_GET['monthID'] && $_GET['yearID'] ){
ABOVE ADD:
$rid=$_GET["id"];
FIND:
// db insert and redirection
mysql_query ("INSERT INTO we
CHANGE THIS LINE TO.
mysql_query ("INSERT INTO weeks (llid, rid, dayID, monthID,
yearID) VALUES ('$llid', '$rid', '$dayID', '$monthID', '$yearID')");
FIND:
mysql_query ("DELETE FROM weeks WHERE
CHANGE THIS LINE TO.
mysql_query ("DELETE FROM weeks WHERE (llid = '$llid' && rid
='$rid' && dayID ='$dayID' && monthID ='$monthID' && yearID
='$yearID') ");
FIND
$dateRst =mysql_query("SELECT * FROM weeks WHERE
CHANGE THIS LINE TO.
$dateRst =mysql_query("SELECT * FROM weeks WHERE (llid='$llid' &&
rid='$rid') ");
SAVE
#############################
open Landlords index.php
FIND:
echo $row["city"];
UNDERNEATH
echo "
href=\"calendarListingEdit.php?id=".$row["rid"]."\">Set Available
Dates";
|