Page 1 of 1
seeking guidance to alias correctly
Posted: Sat Apr 10, 2004 11:51 am
by m3rajk
since no one cared to read, but only to attack becasue i don't space PHP in their style on a db question, i've decided that db questions are not to be asked here since ppl attack instead fo reading and then veer as far from topic as possible.
Posted: Sat Apr 10, 2004 12:14 pm
by Steveo31
I don't have an answer for you, but that has got to be the most confusing code I have ever seen. Any way you could clean it up to make it easier to read?
Posted: Sat Apr 10, 2004 2:15 pm
by m3rajk
Posted: Sat Apr 10, 2004 4:00 pm
by Ixplodestuff8
The code itself isn't confusing, but it looks very jumbled up and hard to read, instead of
Code: Select all
<?php
if(isset($_POST['month'])&&($_POST['month']!='')&&(isset($_POST['day']))&&($_POST['day']!='')
&&(isset($_POST['year']))&&($_POST['year']!='')){ # there is a month, day & year
$date1="{$_POST['year']}-{$_POST['month']}-{$_POST['day']} 00:00:00"; # get day start
$date2="{$_POST['year']}-{$_POST['month']}-{$_POST['day']} 23:59:59"; # get day end
$sql.=" and appdate>'$date1' and appdate<'$date2'"; } # add the date restriction
?>
try
Code: Select all
<?php
# there is a month, day & year
if(isset($_POST['month'])&&($_POST['month']!='')&&(isset($_POST['day']))&&($_POST['day']!='')&&(isset($_POST['year']))&&($_POST['year']!='')){
# get day start
$date1="{$_POST['year']}-{$_POST['month']}-{$_POST['day']} 00:00:00";
# get day end
$date2="{$_POST['year']}-{$_POST['month']}-{$_POST['day']} 23:59:59";
# add the date restriction
$sql.=" and appdate>'$date1' and appdate<'$date2'";
}
?>
For me it's alot more readable, while the first example seems fine to you, it only seems fine to you since you made it and understand what is going on, but for another person who isn't familiar with the code it isn't as easy to understand what it's doing.
Posted: Sat Apr 10, 2004 5:21 pm
by Steveo31
Sorry man, seriously. Wasn't an attack. Just an opinion and a suggestion. Really. Sorry.
Posted: Sat Apr 10, 2004 10:10 pm
by m3rajk
Posted: Sun Apr 11, 2004 10:08 am
by twigletmac
m3rajk - debugging your code is a nightmare and I know I've pointed out the same things that Steveo31 and Ixplodestuff8 have a number of times now (so you should be aware of exactly what Steveo31 was trying to say). Please, you have to help us help you by making your code not only clear to yourself but clear to those that would like to try and help you - requiring them to spend ages reformatting your code so that it makes sense isn't going to inspire anyone to help.
I know this sounds harsh but your intense dislike of whitespace and insistence on putting multiple statements on one line makes your code very difficult to read and is going to make maintaining your code a horrible soul destroying experience.
Mac
Posted: Mon Apr 12, 2004 1:07 pm
by JAM
What was the question? Cant judge from the code I see sofar (I'm abit late, i know). I do see something that might be of interest tho:
Code: Select all
// your
if(isset($_POST['month'])&&($_POST['month']!='')&&(isset($_POST['day']))&&($_POST['day']!='')&&(isset($_POST['year']))&&($_POST['year']!='')){
// spaced (I note abit to many odd ()'s?)
if(
isset($_POST['month']) && ($_POST['month'] !='') &&
(isset($_POST['day'])) && ($_POST['day'] !='') &&
(isset($_POST['year'])) && ($_POST['year'] !='')
) {
// clean(er)
if(!empty($_POST['month']) && !empty($_POST['day']) && !empty($_POST['year'])) {