RE: Basic Appointment Calendar or "Events Scheduler"
hi. this is my first attempt at using MySQL (SELECT - WHERE) style queries on a table using Data Access Object style PHP Classes -- where all of the table data will be returned in the form of a "Data Object", or array as one might say.
although it took me a while, trial and error and much research to figure out how to select only certain fields from the DB using this OOP approach (as in, make a drop-down w/ only the date info, or only the "event" name), i feel like i developed a fair understanding of how to 'look at' these data objects (the arrays returning my rows of events data), but i'm having trouble thinking about how i'm going to do my UPDATEs if necessary-- and furthermore-- even how to simply take a single, user-selected event-date, and query the db for displaying the corresponding details (another Data Object puzzle for me).
[maybe this next part isn't a problem, but for me...] to make matters worse, in my testing on localhost, i've deleted rows (where i messed up and inserted blank fields), so no longer do i have a consecutively enumerated Primary Key, but simply rather random, Unique id's, put there originally by an autoincrementing id, and of course any new entries will continue where the AutoInc left off...
my data Class select Method looks like this:
Code:
function selectWhere($table,$field,$where) {
$dbconnect = mysql_connect("secretstuff");
$this->query = "SELECT * FROM ".$table." WHERE ".$field."=".$where.";";
$this->result = mysql_query($this->query) or die(mysql_error());
$this->data = mysql_fetch_assoc($this->result);
return $this->data;
the way i see it, my problem stems from my inability to take a user input, plug it into this selectWhere() method at $where, and return that singular row which the user wants to see. there it is. that's my issue. to retrieve a single row using this method.
your own commentary is preferred, of course, but if you know of a URL which covers precisely this issue, i'd appreciate it.
thank you for reading my short-story/ thriller, titled:
"When OOP Crushed a Newb into Bits pt. II - the Puzzle Continues"
I look forward to your reply.
***********************
Do the hokey pokey.
Turn yourself around.