Jump to content

vietboy505

Members
  • Posts

    16
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

vietboy505's Achievements

Member

Member (2/5)

0

Reputation

  1. [code] <?php //today date is: 2006-04-10 08:18:24 //last week is: 2006-04-03 06:23:10 $lastWeek=date('Y-m-d H:i:s', strtotime('-1 week')); //How do I get any date before last week(2006-04-03 06:23:10) //This show all date start from last week (2006-04-03 06:23:10) up to today (2006-04-10 08:18:24) $result = mysql_query("SELECT * FROM $table WHERE dateCreate >= '$lastWeek' //I want the opposite of this, from before last week, not from last week up to today. ?> [/code] How can fixed the above code to get all dates in the database from before last week? Any idea?
  2. I figure it out now after posting this message. Mod can delete this post.
  3. I want to enter the data back once a user click submit and they haven't fill all data in yet. How would I do that? Also, if all fields are enter. It will go to another page instead staying on the same page. I use: [code] <form name="create_form" method="POST" action="<?php echo $PHP_SELF; ?>"> [/code] This will add data to the database, but if I use like [code] <form name="create_form" method="POST" action="anotherPage.php"> [/code] This will not add data to the database. Full code: [code] <?php include("config3.php"); ?> <?php if (isset($_POST['create_form'])) {     submitData(); } function submitData() { if (($_POST["NAME"] == "") or ($_POST["QUESTION"] == "")) {     echo "     <script type=\"text/javascript\">     alert(\"Please input all data.\")     </script>     "; } mysql_select_db($dbNAME) or die($errCon . mysql_error());     mysql_query("INSERT INTO $tableNEW         (name,number,question)         VALUES('$NAME', '$NUMBER','$QUESTION') ")     or die($errCon . mysql_error()); } //end function ?> <form name="create_form" method="POST" action="<?php echo $PHP_SELF; ?>"> <table> <tr>     <td align="right">Name:</td>     <td><input name="NAME" size="25"></td> </tr> <tr>     <td align="right">Number:</td>     <td><select name="NUMBER">         <option value="1">1     <option value="2">2     <option value="3">3     <option value="4">4     <option value="5">5     <option value="6">6     <option value="7">7     <option value="8">8     <option value="9">9         </select>     </td> </tr> <tr>     <td align="right">Question:</td>     <td>     <textarea name="QUESTION" rows="10" cols="40"></textarea>     </td> </tr> <tr>     <td colspan="2" align="center"><input type="submit" value="Submit" name="create_form">     <input type="reset" value="Reset" name="reset"></td> </tr> </table> </form> [/code]
  4. I want my textarea box to not to have scrollbars. So depends on how long the message is, it will determine the rows. How would I do that, count the character in $message? [code] <textarea value="<?php echo $message; ?>" rows="<?php ?>" cols="20"> [/code]
  5. I want to move the row from OLD TABLE to NEW TABLE where: the OLD TABLE, status == 'S' & the dateModify is over a week, move that row (all data to the NEW TABLE). Then delete that row on the OLD TABLE. I try the code below, nothing happen, no data is output. I try to change to +1 day, it's still same but it should display the data a day old. How can I fix that? [code] <?php include("config.php"); ?> <?php //INFO from mySQL //id INT NOT NULL AUTO_INCREMENT, //PRIMARY KEY(id), //name VARCHAR(30), //status VARCHAR(1), //dateModify TIMESTAMP,   $overWeek=date('Y-m-d H:i:s', strtotime('+1 week')); $statusCheck="S"; mysql_select_db($dbnameNAME) or die(mysql_error()); $result = mysql_query("INSERT INTO $tableNEW         (name, status, dateModify)         SELECT name,status,dateModify FROM $tableOLD WHERE status = '$statusCheck' AND dateModify >= '$overWeek' " )     or die($errCon . mysql_error());   ?> <?php mysql_select_db($dbnameNAME) or die(mysql_error()); $result2 = mysql_query("SELECT * FROM $tableNEW ") or die(mysql_error()); while($row2 = mysql_fetch_array($result2)) {     echo $row2['name'];     echo $row2['status'];     echo $row2['dateModify']; } //free up memory mysql_free_result($result2); ?> [/code]
  6. yup.. my cable modem is active.. I can use internet with cable modem through LAN. I setup the wireless router from the wizard on the CD. Everything passed. I can connect to the wireless & access 192.168.0.1, but can't go off WWW.
  7. I have searched this forum related to my questions but found no answer. I Use [a href=\"http://www.dlink.com/products/?pid=316\" target=\"_blank\"]DI-524[/a] for my router. I have the cable modem & DI-524 router setup correctly. I can see my SSID on wireless, I connected with WEP. And it's said connected, when I try to go to any web site. It can't go through. I can only access 192.168.0.1 the main DI-524 portal. When I do a ipconfig it gives: [code] Ethernet adapter Wireless Network Connection:         Connection-specific DNS Suffix  . :         IP Address. . . . . . . . . . . . : 192.168.0.101         Subnet Mask . . . . . . . . . . . : 255.255.255.0         Default Gateway . . . . . . . . . : 192.168.0.1 [/code] How can I get on the WWW, I try to use LAN, it's gives me limited connection. Any setting I need to setup? I have try to turn on HTTP port, HTTPS, no luck at all with 192.168.0.101 private IP & clone my MAC address up on the DI-524 portal. I really need help in a day or I can't return the router. thanks
  8. I have run createTable.php and everything is created. Now I want to run insertData.php. I want the user to enter stuff in the form & everything must be fill in before they click the submit button. It will call submitData() & all the information was enter will insert into the database. How can I do that. config.php [code] <?php $errCon = "<br> Contact your webmaster. <br>"; $server = "localhost"; $user = "root"; $password = "pass"; $tableDaily="issue"; $dbnameDaily="daily_issue"; ?> <?php     mysql_connect($server, $user, $password)     or die($errCon . mysql_error());     echo "SUCCESS"; ?> [/code] createTable.php [code] <?php include("config.php"); ?> <?php mysql_query("CREATE DATABASE $dbnameDaily") or die($errCon . mysql_error()); echo "success in database creation. $dbnameDaily"; ?> <?php     mysql_select_db($dbnameDaily) or die($errCon . mysql_error()); // Create a MySQL table in the selected database mysql_query("CREATE TABLE $tableDaily( id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(id), owner VARCHAR(30), problem VARCHAR(999), status VARCHAR(1), dateCreate DATETIME,   //YYYY-MM-DD HH:MM:SS dateModify TIMESTAMP)")  //YYYY-MM-DD HH:MM:SS or die($errCon . mysql_error()); echo "Table Created!"; ?> [/code] insertData.php [code] <?php include("config.php"); ?> <?php function submitData() { mysql_select_db($dbnameDaily) or die($errCon . mysql_error()); $DATECREATE=$DATEMODIFY=date("Y-m-d H:i:s"); // Insert a row of information into the table mysql_query("INSERT INTO $tableDaily (owner, problem, status, dateCreate, dateModidy) VALUES('$OWNER', '$PROBLEM','$STATUS', '$DATECREATE', '$DATEMODIFY' ) ") or die($errCon . mysql_error()); //owner VARCHAR(30), //problem VARCHAR(999), //status VARCHAR(1), //dateCreate DATETIME,   //YYYY-MM-DD HH:MM:SS //dateModify TIMESTAMP)")  //YYYY-MM-DD HH:MM:SS echo "Data Inserted!"; } ?> <?php echo('<form name="create_form" method="post"> <input type="hidden" name="require" value="OWNER,PROBLEM"> <table> <tr>     <td align="right">Name:</td>     <td><input name="OWNER" size="25"></td> </tr> <tr>     <td align="right">Status:</td>     <td><select name="STATUS">     <option value="W">Work     <option value="I">Idle     </select>     </td> </tr> <tr>     <td align="right">Problem:</td>     <td><textarea name="PROBLEM" rows="10" cols="40"></textarea>     </td> </tr> <tr>     <td colspan="2" align="center"><input type="submit" value="Submit" name="create_form">     <input type="reset" value="Reset" name="reset"></td> </tr> </table> </form>'); ?> [/code]
  9. I am new to PHP. I want to start from stratch for a script to have box of Daily Bulletin like a shout box. Any users can post message on the web page. Maybe like a box of daily bullentin, as time passed, it will gray out (strikethrough) like after couple of days or weeks. There is an option of admin which can archive it, goes into a .txt file or mySQL database, or gray out. Any help would be appreciate. Thanks. Some features: -No registratin involved -Any one can read/post it -Specific password for admin --Archive by pressing a button which embed to a TXT file or store in the mySQL database Can I have some snipet codes to start?
  10. I try [a href=\"http://www.htmlgoodies.com/beyond/webmaster/article.php/3473341\" target=\"_blank\"]this link[/a], when I try in .pl file, it doesn't do nothing. I also read this link, [a href=\"http://www.zend.com/php5/articles/php5-perl.php?article=php5-perl&kind=php5&id=6290&open=1&anc=0&view=1#Heading3\" target=\"_blank\"]PERL in PHP[/a] [code] <?php     print "Hello from PHP!\n";     $perl = new Perl();     $perl->require("script1.pl");     print "Bye!\n";     ?> [/code] Give me this: Hello from PHP! Fatal error: Class 'Perl' not found in C:\Inetpub\webaps\test2.php on line 4 I try include inside PHP script inside PERL script, doesn't work, so I try the PHP include of PERL file. No luck at all. Do I need to import Perl class from PHP or something?
  11. You can use webcalendar, [a href=\"http://webcalendar.sourceforge.net/\" target=\"_blank\"]http://webcalendar.sourceforge.net/[/a]
  12. I want to include a PHP file inside a PERL file.. script1.pl [code] #!/usr/local/bin/perl use strict; use warnings; use CGI qw(:standard); use CGI::Carp qw(fatalsToBrowser warningsToBrowser); print header(); warningsToBrowser(1); print("<?php include('require_file.php') ?>\n\n"); [/code] It's in the source code, but it's never include my other php. How can I fixed that? 'require_file.php' is in the same directory the script1.pl is.
  13. I want my PErl to output the content of XML to HTML table like this: [code] <table border="1"> <tr> <th>Type</th> <th>Contact</th> </tr> <tr> <td>Work</td> <td><a href="../search.asp?ID=123456">John Doe</a></td> </tr> <tr> <td></td> <td><a href="../search.asp?ID=05789">Jack Doe</a></td> </tr> <tr> <td>Relative</td> <td><a href="../search.asp?ID=654321">Jane Doe</a></td> </tr> </table> [/code] address.xml [code] <?xml version="1.0" encoding="ISO-8859-1"?> <!-- Comment --> <Address>   <Work>     <JohnDoe>       <name>John Doe</name>       <email>john@doe.com</email>       <phone>555-555-5555</phone>       <pager>6666666666</pager>       <id>123456</id>     </JohnDoe>     <JackDoe>       <name>Jack Doe</name>       <email>jack@doe.com</email>       <phone>666-666-6666</phone>       <pager>7777777777</pager>       <id>05789</id>     </JackDoe>   </Work>   <Relative>     <JaneDoe>       <name>Jane Doe</name>       <email>jane@doe.com</email>       <phone>444-444-4444</phone>       <pager>8888888888</pager>       <id>654321</id>     </JaneDoe>   </Relative> </Address> [/code] address2.pl [code] #!/usr/local/bin/perl print "Content-Type: text/html\n\n"; use XML::Simple; use Data::Dumper; my $ref = XMLin('address.xml'); print('<table border="1">\n <tr>\n <th>Type</th>\n <th>Contact</th>\n </tr>\n'); foreach my $type (qw(Work Relative)) {    foreach my $person (keys %{$ref->{$type}}) {        my $id=$ref->{$type}->{$person}->{id};        my $name=$ref->{$type}->{$person}->{name};       print("<a href='../search.asp?ID=$id'>$name</a>");    } } print('</table>'); [/code] I just need how to fix my foreach loop. Any help?
  14. I try to follow the example from [a href=\"http://search.cpan.org/~grantm/XML-Simple-2.14/lib/XML/Simple.pm\" target=\"_blank\"]XML Parse[/a] with foo. [code] #!/usr/local/bin/perl use XML::Simple; my $ref = XMLin('foo.xml'); #also with my $ref = XMLin(); use Data::Dumper; print Dumper($config); print $config->{logdir}; [/code] where foo.xml [code]   <config logdir="/var/log/foo/" debugfile="/tmp/foo.debug">     <server name="sahara" osname="solaris" osversion="2.6">       <address>10.0.0.101</address>       <address>10.0.1.101</address>     </server>     <server name="gobi" osname="irix" osversion="6.5">       <address>10.0.0.102</address>     </server>     <server name="kalahari" osname="linux" osversion="2.0.34">       <address>10.0.0.103</address>       <address>10.0.1.103</address>     </server>   </config> [/code] I try to test out foo.pl and get $VAR1 = undef; Why is that, it doesn't match the one with from the web.
×
×
  • 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.