Jump to content

arn_php

Members
  • Posts

    80
  • Joined

  • Last visited

    Never

Everything posted by arn_php

  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>'; } } ?>
  15. SQL query: Documentation 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 =3 MySQL said: Documentation #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT SUM(qty_ticket) FROM gtown_eticket AS t INNER JOIN gtown_events AS ' at line 2 That is what I put and this is the error message I got. I do need it to close the form though.. how would be the code to do so? Maybe a php or javascript code? Also I notice that I do not see the code that mention about the limitation of how many tickets should be sold. So, when the numbers of the ticket (qty_ticket) of all the transactions (eticket_id, category=events_id) of certain events (events_id) match the ticket limitation (limitation_ticket) of that certain events then the form should be closed automatically and switch to a statement of TICKETS ARE SOLD OUT. Thanks.. I guess I am totally lost here.
  16. Ok, I try to put it in as this one.. I use the code to close down the SUBMIT button of the form. The category field of the gtown_eticket is the foreign key that connects this table to the gtown_events, collects the data from events_id. I tried it, but it doesn't work.. maybe the if(mysql_num_rows($result) == 0) is wrong. Or the whole code is wrong.. sorry for my error. <?php $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) == 0){ echo '<div align="center"><input type="submit" name="purchase" value="Purchase Ticket"></div>'; }else{ while($row=mysql_fetch_array($result)) { echo '<div align="center"><strong><font size="4">TICKETS ARE SOLD OUT</font></strong></div>'; } } ?>
  17. I am working on a social organization where they are doing fund raising dinner parties. The attendance needs to purchase tickets to be able to present there. I am able to get the forms and etc but stumble into one issue. How can I limit the tickets? Just say if the dinner party is only sold to 20 seats.. when the 20th ticket sold, then the ticket purchasing form should be closed automatically. This is the table to sell the ticket. CREATE TABLE `gtown_eticket` ( `eticket_id` mediumint( unsigned NOT NULL auto_increment, `title_event` text NOT NULL, `category` smallint(1) NOT NULL default '0', `amount` text NOT NULL, `qty_ticket` text NOT NULL, ------> field to put the numbers of the ticket on each sell. `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 ; The table below is for the dinner/event that would sell the ticket. 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, `date_added` text NOT NULL, `price` text NOT NULL, ------------>Ticket price field `limitation_ticket` text NOT NULL, --------->The field that limit how many ticket needs to be sold. `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 ; So the first table collects the data of the ticket buyer, including how many tickets would be included on each transaction. Logically, it should be able to be counted to reach the same number with the number that limits the ticket that suppose to be sold on the other table, then the form would automatically closed or switched to a statement saying that The Tickets are SOLD OUT. Any idea, how the php code should be to close the purchasing ticket form? Or maybe a javascript? Thanks, any help is appreciated.
  18. I am working on this form where (I want to be) if you put a number to the amount field, the amount adjustment field would automatically calculate the number to add the 3% adjustment. Here is the code: Amount: <input name="amount" type="text" value="<?=stripslashes($_POST['amount']);?>" size="5" /> <?php $amount = $_POST['amount']; $total = $amount * 1.03; ?> Amount Adjustment: $US <?php echo $total; ?> But then this is only works if I click the submit button. I want it calculate directly after I fill the number into the amount field before clicking the submit button. How to do that?
  19. If I use javascript, how would that be? Any idea?
  20. Hi there, need any help on figuring how to make this work. I am making a registration form where it has up to 4 registrar's name fields. And there is a registration fee that filled with a certain amount for each registrar. I am trying to figure it out how to make a total field for the total registration fee where when you fill in each name field, the total field would automatically count each registrar. Here is the form code: (the reg fee is coming from a database, the total should count it all as the registrar being filled) <table width="100%" border="0" cellspacing="0" cellpadding="5"> <tr> <td><strong><font size="3"> Conferees:</font></strong></td> <td><strong><font size="3"> Names</font></strong></td> <td><strong><font size="3"> Last Names</font></strong></td> <td><strong><font size="3"> Badge Name</font></strong></td> </tr> <tr> <td><label <?=($error['first_name1'] != '')?'class="error"':'';?>><strong><font size="3"> Conferee 1</font></strong> <span class="error">*</span></label></td> <td><input <?php mOver('ov') ?> type="text" name="first_name1" size="15" value="<?=stripslashes($_POST['first_name1']);?>" /></td> <td><input <?php mOver('ov') ?> type="text" name="last_name1" size="15" value="<?=stripslashes($_POST['last_name1']);?>" /></td> <td><input <?php mOver('ov') ?> type="text" name="badge_name1" size="15" value="<?=stripslashes($_POST['badge_name1']);?>" /></td> </tr> <tr> <td><strong><font size="3"> Conferee 2</font></strong></td> <td><input <?php mOver('ov') ?> type="text" name="first_name2" size="15" value="<?=stripslashes($_POST['first_name2']);?>" /></td> <td><input <?php mOver('ov') ?> type="text" name="last_name2" size="15" value="<?=stripslashes($_POST['last_name2']);?>" /></td> <td><input <?php mOver('ov') ?> type="text" name="badge_name2" size="15" value="<?=stripslashes($_POST['badge_name2']);?>" /></td> </tr> <tr> <td><strong><font size="3"> Conferee 3</font></strong></td> <td><input <?php mOver('ov') ?> type="text" name="first_name3" size="15" value="<?=stripslashes($_POST['first_name3']);?>" /></td> <td><input <?php mOver('ov') ?> type="text" name="last_name3" size="15" value="<?=stripslashes($_POST['last_name3']);?>" /></td> <td><input <?php mOver('ov') ?> type="text" name="badge_name3" size="15" value="<?=stripslashes($_POST['badge_name3']);?>" /></td> </tr> <tr> <td><strong><font size="3"> Conferee 4</font></strong></td> <td><input <?php mOver('ov') ?> type="text" name="first_name4" size="15" value="<?=stripslashes($_POST['first_name4']);?>" /></td> <td><input <?php mOver('ov') ?> type="text" name="last_name4" size="15" value="<?=stripslashes($_POST['last_name4']);?>" /></td> <td><input <?php mOver('ov') ?> type="text" name="badge_name4" size="15" value="<?=stripslashes($_POST['badge_name4']);?>" /></td> </tr> </table> <table width="100%" border="0" cellpadding="5" cellspacing="0"> <tr> <td width="40%"><div align="right"> <label <?=($error['reg_fee'] != '')?'class="error"':'';?>><strong>Registration Fee: <span class="error">*</span></strong></label> </div></td> <td>$US <input <?php mOver('ov') ?> type="text" name="reg_fee" size="50" value="<?php $query="SELECT * FROM specialm_confe WHERE confe_id='$id' LIMIT 1"; $result=mysql_query($query); while($row=mysql_fetch_array($result)) { echo ''.stripslashes($row['harga']).''; } ?>" /></td> </tr> <tr> <td width="40%"><div align="right"> <label <?=($error['total_fee'] != '')?'class="error"':'';?>><strong>TOTAL: <span class="error">*</span></strong></label> </div></td> <td>$US <input <?php mOver('ov') ?> type="text" name="total_fee" size="15" value="<?=stripslashes($_POST['total_fee']);?>" /></td> </tr> </table> <div align="center"> <input name="Submit" type="submit" value="Submit" class="button1" onmouseover="this.className='button1Ov'" onmouseout="this.className='button1'" /> </div>
  21. You are genius, thanks a lot!! It works perfect.
  22. It works! Only then the drop down box is back to show the current month (which is October 2008), not the month in which the page is showing. So if you choose, just say March 2009, the page would show the calendar of March 2009 but then the drop down box would show the October 2008. The other thing, when you tried to go back to the October 2008, then you can't do that unless you visit other page then come back to it again.
  23. Hello n3ightjay, are you there?
  24. Wow, that works! about the month to month thingy... I bet you already noticed this code: (line 38 into the page) <form method="post" name="form1"> <div align="center"> <select name="month" onChange="javascript:document.forms['form1'].submit();"> <? select_array($array_month, $_GET['month']);?> </select> Quick jump to month </div> </form> So the $array_month comes from the _init.php file which contains only 12 months: $array_month = array('01'=>'January', '02'=>'February', '03'=>'March', '04'=>'April', '05'=>'May', '06'=>'June', '07'=>'July', '08'=>'August', '09'=>'September', '10'=>'October', '11'=>'November', '12'=>'December'); I don't think I could just probably add the next month after December because surely we need to add the yearly thing on the beginning of my calendar page.. correct? Start with line 3: <?php include_once('_init.php'); if(isset($_POST['month'])){ $_GET['month'] = $_POST['month']; }else{ if($_GET['date'] != ''){ $exp = explode('-', $_GET['date']); $_GET['month'] = $exp[1]; }else{ $_GET['month'] = date('m'); } } $_GET['date'] = '01-'.$_GET['month'].'-'.date('Y'); ?> But how? Then maybe tweaking the form of the drop down box above... can you help me? Thanks man..
×
×
  • 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.