seeking guidance to alias correctly

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
m3rajk
DevNet Resident
Posts: 1191
Joined: Mon Jun 02, 2003 3:37 pm

seeking guidance to alias correctly

Post 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.
Last edited by m3rajk on Sun Apr 11, 2004 6:20 pm, edited 2 times in total.
Steveo31
Forum Contributor
Posts: 416
Joined: Sun Nov 23, 2003 9:05 pm
Location: San Jose CA

Post 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?
m3rajk
DevNet Resident
Posts: 1191
Joined: Mon Jun 02, 2003 3:37 pm

Post by m3rajk »

Last edited by m3rajk on Sun Apr 11, 2004 6:22 pm, edited 1 time in total.
User avatar
Ixplodestuff8
Forum Commoner
Posts: 60
Joined: Mon Feb 09, 2004 8:17 pm
Location: Queens, New York

Post 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.
Steveo31
Forum Contributor
Posts: 416
Joined: Sun Nov 23, 2003 9:05 pm
Location: San Jose CA

Post by Steveo31 »

Sorry man, seriously. Wasn't an attack. Just an opinion and a suggestion. Really. Sorry.
m3rajk
DevNet Resident
Posts: 1191
Joined: Mon Jun 02, 2003 3:37 pm

Post by m3rajk »

Last edited by m3rajk on Sun Apr 11, 2004 6:21 pm, edited 1 time in total.
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post 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
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post 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'])) {
Post Reply