Jump to content

arn_php

Members
  • Posts

    80
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

arn_php's Achievements

Member

Member (2/5)

0

Reputation

  1. arn_php

    date

    Maybe it would be easier if the data date would be capture directly into UNIXTIME when the field is entered with a date in a format of M d, Y. I have this code at the header of the file: $class_date = tep_db_prepare_input($HTTP_POST_VARS['class_date']); But this one of course would capture the entered data as it is. How would the code be when I want it to capture in UNIXTIME?
  2. arn_php

    date

    No, I did it before but won't work. This is the complete code, maybe it would give a better thinking: <?php for($j=0;$j<7;$j++){ $query = "SELECT class_name, id FROM tbl_classes WHERE FROM_UNIXTIME(class_date, '%d-%m-%Y') = '".date("d-m-Y", mktime(0,0,0,$zi[1], ($j+($i*7))-date("w",mktime(0,0,0,$zi[1],0,$zi[2])),$zi[2]))."' "; //$result = mysql_query($query, $connection) or die('ERROR :: QUERY'."<br>".$query."<br>".mysql_error()); $result=mysql_query($query); $xx_m = date("m", mktime(0,0,0,$zi[1], ($j+($i*7))-date("w",mktime(0,0,0,$zi[1],0,$zi[2])),$zi[2])); $xx_d = date("d", mktime(0,0,0,$zi[1], ($j+($i*7))-date("w",mktime(0,0,0,$zi[1],0,$zi[2])),$zi[2])); $detail = ''; if($xx_m != $zi[1]){ $class = "customtext2"; $detail = ''; }elseif(($xx_d == date('d'))&&($xx_m == date("m"))){ $class = "td_today"; if(mysql_num_rows($result) > 0){ while($row = mysql_fetch_assoc($result)){ $class = "td_today_ap"; $detail = '<br /><font size="2"><a href="javascript:void(0)" onClick="javascript:window.open(\'open_details.php?date='.date("d-m-Y", mktime(0,0,0,$zi[1], ($j+($i*7))-date("w",mktime(0,0,0,$zi[1],0,$zi[2])),$zi[2])).'\', \'title\', \'width=400, height=300, statusbar=yes, scrollbars=yes\')">'.stripslashes($row['class_name']).'</a></font>'; } } }else{ if(mysql_num_rows($result) > 0){ while($row = mysql_fetch_assoc($result)){ $class = "td_ap"; $detail = '<br /><font size="2"><a href="javascript:void(0)" onClick="javascript:window.open(\'open_details.php?date='.date("d-m-Y", mktime(0,0,0,$zi[1], ($j+($i*7))-date("w",mktime(0,0,0,$zi[1],0,$zi[2])),$zi[2])).'\', \'title\', \'width=600, height=300, statusbar=yes, scrollbars=yes\')">'.stripslashes($row['class_name']).'</a></font>'; } }else{ $class = "tabel"; $detail = ''; } } ?> See, the data date before is in UNIXTIME where by this, it would be converted into this format d-m-Y. Now I got the data date already in a format of M d, Y.. (from OSCommerce), so how could I make this code to read the data date of M d, Y then directly converted into the d-m-Y?
  3. arn_php

    date

    I have a query like this: $query = "SELECT class_name, id FROM tbl_classes WHERE FROM_UNIXTIME(class_date, '%d-%m-%Y') = '".date("d-m-Y", mktime(0,0,0,$zi[1], ($j+($i*7))-date("w",mktime(0,0,0,$zi[1],0,$zi[2])),$zi[2]))."' "; This query should retrieve data from the tbl_classes where the date data is in UNIXTIME format. As a sample, a data date of 1287291600 is read as 17-10-2010 (dd-mm-yy) because of the query above. Anyway, now my data date within the MySQL already in a date format of M d, y and not in the UNIXTIME format. The question is, can someone help me change the query above so it would read my current data date now from M d, y to dd-mm-yy? Thanks a lot for anyhelp.
  4. if ($total=='0') { I am using the code above into my php.. the problem is if the result gets into -1 or -2 or whatever minus.. then the if ($total=='0') is not working properly.. how do I modify it?
  5. no problem, I figure it out by myself. Thanks anyway.
  6. Sorry, found my own error.. $total = $sum2-$sum;
  7. Continuously from my previous post.. now I am trying to get this calculate together.. <? $result = mysql_query("SELECT SUM(jumlah) FROM `gtown_eticket` WHERE category='$id'") or trigger_error(mysql_error(),E_USER_ERROR); $sum = mysql_result($result,0); $result2 = mysql_query("SELECT batas FROM `gtown_events` WHERE events_id='$id' and flag_status='1' LIMIT 1") or trigger_error(mysql_error(),E_USER_ERROR); $sum2 = mysql_result($result2,0); $total = $sum2-$sum echo "# of tickets being purchased are $sum"; echo "<br />Limit of the ticket are $sum2"; echo "<br />Total of the available tickets are $total"; ?> It doesn't work and even it put my page blank again? ha.. please help... Anyone...
  8. funny..! I guess that is because my own fool... I forgot that I do not have "and flag_status='1' " field on the first table. I took it out and it works. $result = mysql_query("SELECT SUM(jumlah) FROM `gtown_eticket` WHERE category='$id'") or trigger_error(mysql_error(),E_USER_ERROR); $sum = mysql_result($result,0); echo "# of tickets being purchased are $sum"; $result2 = mysql_query("SELECT batas FROM `gtown_events` WHERE events_id='$id' and flag_status='1' LIMIT 1") or trigger_error(mysql_error(),E_USER_ERROR); $sum2 = mysql_result($result2,0); echo "<br />Limit of the ticket are $sum2";
  9. I did that actually (and just tried again) but then the page still blank.
  10. Thanks for this great forum.. I am trying to put this code: <? $result = mysql_query("SELECT SUM(jumlah) FROM `gtown_eticket`") or trigger_error(mysql_error(),E_USER_ERROR); $sum = mysql_result($result,0); echo "# of tickets being purchased are $sum"; $result2 = mysql_query("SELECT batas FROM `gtown_events`") or trigger_error(mysql_error(),E_USER_ERROR); $sum2 = mysql_result($result2,0); echo "<br />Limit of the ticket are $sum2"; ?> into something like this: <? $result = mysql_query("SELECT SUM(jumlah) FROM `gtown_eticket` WHERE category=`$id` and flag_status=`1`") or trigger_error(mysql_error(),E_USER_ERROR); $sum = mysql_result($result,0); echo "# of tickets being purchased are $sum"; $result2 = mysql_query("SELECT batas FROM `gtown_events` WHERE events_id=`$id` and flag_status=`1` LIMIT 1") or trigger_error(mysql_error(),E_USER_ERROR); $sum2 = mysql_result($result2,0); echo "<br />Limit of the ticket are $sum2"; ?> The reason is the $id would determine which data entry would be pull and sum from either gtown_eticket and gtown_events. The problem is.. the page went blank!.. do you know where is the error? Thanks.
  11. sorry, I am lost here.. but would you be able to write the php code you mentioned there? please know, I am not an expert, most likely I am only a novice here....
  12. How about doing it like this: BATAS (gtown_events) minus the number of all JUMLAH field (gtown_eticket) per CATEGORY (gtown_eticket, - events_id dari gtown_events), if the result is zero or minus, then the SUBMIT button would be changed to SOLDOUT statement. I am using a mysql 4.1.22, this is the mysql dumb: (please use this one and ignore the one above). CREATE TABLE `gtown_eticket` ( `eticket_id` mediumint( unsigned NOT NULL auto_increment, `title_event` text NOT NULL, `category` smallint(1) NOT NULL default '0', `donation_amount` text NOT NULL, `jumlah` text NOT NULL, `first_name` text NOT NULL, `last_name` text NOT NULL, `address` text NOT NULL, `city` text NOT NULL, `state` text NOT NULL, `zipcode` text NOT NULL, `phone` text NOT NULL, `email` text NOT NULL, `comments` text NOT NULL, `date_added` text NOT NULL, PRIMARY KEY (`eticket_id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; CREATE TABLE `gtown_events` ( `events_id` mediumint( unsigned NOT NULL auto_increment, `title` text NOT NULL, `short_description` text NOT NULL, `long_description` text NOT NULL, `host` text NOT NULL, `tanggal` text NOT NULL, `price` text NOT NULL, `batas` text NOT NULL, `field_display_order` int(10) unsigned NOT NULL default '0', `flag_status` tinyint(1) unsigned NOT NULL default '0', PRIMARY KEY (`events_id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
  13. Sorry, I happened to click post before finishing up. So that was the code I tried then the page just going blank when you open it..? Hmm? Is there any guru out there?
  14. This is a php code I tried to put: <?php $query="SELECT * FROM gtown_events WHERE events_id='$id' and flag_status ='1' LIMIT 1"; $result=mysql_query($query); $limitation="'.stripslashes($row['limitation_ticket']).'" $query="SELECT SUM( SELECT SUM(qty_ticket) FROM gtown_eticket AS t INNER JOIN gtown_events AS e ON t.category=e.events_id GROUP BY e.eticket_id ) AS tickets_sold FROM gtown_events WHERE events_id = '$id'"; $result=mysql_query($query); if(mysql_num_rows($result) == $limitation){ echo '<div align="center"><strong><font size="4">TICKETS ARE SOLD OUT</font></strong></div>'; }else{ while($row=mysql_fetch_array($result)) { echo '<div align="center"><input type="submit" name="purchase" value="Purchase Ticket"></div>'; } } ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.