Jump to content

hitman6003

Members
  • Posts

    1,807
  • Joined

  • Last visited

Everything posted by hitman6003

  1. [!--quoteo(post=357313:date=Mar 22 2006, 10:25 AM:name=Grande)--][div class=\'quotetop\']QUOTE(Grande @ Mar 22 2006, 10:25 AM) [snapback]357313[/snapback][/div][div class=\'quotemain\'][!--quotec--] seems like an interesting thing that I can probably use. [/quote] A long time ago I posted some stuff about working with text files...a mini-tutorial if you will. [a href=\"http://www.phpfreaks.com/forums/index.php?showtopic=63496\" target=\"_blank\"]http://www.phpfreaks.com/forums/index.php?showtopic=63496[/a] It was closed almost immeidatly by toplay...I don't think he appreciated the post very much for some reason.
  2. After the form is submitted, do [code]document.formname.reset();[/code]
  3. The easiest thing to do is to make session_start() the first command intrepreted by php. If anything has been sent to the browser before session_start() has been called, it will fail. Move session_start() to the top...make it the first include and at the top of that include, then it should work.
  4. After approximatly 30 seconds of searching on google I found this IE only solution: [code]function printpr() { var OLECMDID = 7; /* OLECMDID values: * 6 - print * 7 - print preview * 1 - open window * 4 - Save As */ var PROMPT = 1; // 2 DONTPROMPTUSER var WebBrowser = ”; document.body.insertAdjacentHTML(‘beforeEnd’, WebBrowser); WebBrowser1.ExecWB(OLECMDID, PROMPT); WebBrowser1.outerHTML = “”; }[/code] which came from this website: [a href=\"http://www.magpiebrain.com/archives/2004/05/14/livecomments#comment1392\" target=\"_blank\"]http://www.magpiebrain.com/archives/2004/0...nts#comment1392[/a] I can't take credit for the script, nor can I verify that it works. Google is your friend.
  5. Try using date(). [code]echo date("d-m-y");[/code] If you need it to display a specific date, use the mktime or strtotime functions. [a href=\"http://www.php.net/date\" target=\"_blank\"]http://www.php.net/date[/a] [a href=\"http://www.php.net/mktime\" target=\"_blank\"]http://www.php.net/mktime[/a] [a href=\"http://www.php.net/strtotime\" target=\"_blank\"]http://www.php.net/strtotime[/a]
  6. [!--quoteo(post=357119:date=Mar 21 2006, 05:26 PM:name=ReVeR)--][div class=\'quotetop\']QUOTE(ReVeR @ Mar 21 2006, 05:26 PM) [snapback]357119[/snapback][/div][div class=\'quotemain\'][!--quotec--] I tried to use mysql_num_rows from a results, but that gives me too many.... any ideas how to get exect number of entries? Thx [/quote] Exact number of entries of what? If you want the number of entries in the whole table, use the count funtion: [!--sql--][div class=\'sqltop\']SQL[/div][div class=\'sqlmain\'][!--sql1--][span style=\'color:blue;font-weight:bold\']SELECT[/span] [color=blue]COUNT[/color](id) [color=green]FROM[/color] [color=orange]table[/color] [!--sql2--][/div][!--sql3--] If you want to narrow it down, add a where clause to it.
  7. Check the manual: [a href=\"http://www.php.net/dir\" target=\"_blank\"]http://www.php.net/dir[/a] There is a lot of good info there. Especially the user comments at the bottom. There are a couple of functions there that will return an array with all the file names and subdirectory names in an array that you can then do a count on to get the number of files in the directory. To display the value of nearly any variable, you can use either echo or print. [a href=\"http://www.php.net/echo\" target=\"_blank\"]http://www.php.net/echo[/a] [a href=\"http://www.php.net/print\" target=\"_blank\"]http://www.php.net/print[/a] For arrays, use the print_r function: [a href=\"http://www.php.net/print_r\" target=\"_blank\"]http://www.php.net/print_r[/a]
  8. Research the file and explode functions. [a href=\"http://www.php.net/file\" target=\"_blank\"]http://www.php.net/file[/a] [a href=\"http://www.php.net/explode\" target=\"_blank\"]http://www.php.net/explode[/a] Also, make sure you understand foreach loops. [a href=\"http://www.php.net/foreach\" target=\"_blank\"]http://www.php.net/foreach[/a]. [code]$file = file("test.txt"); echo "<table>"; foreach ($file as $line) {   $line = explode("\t",$line); //\t is a tab character.  \n would be a newline character   echo "<tr><td>$line[0]</td><td>$line[1]</td><td>$line[2]</td></tr>"; } echo "</table>";[/code] I haven't looked at your file, but from what you said that should do what you want.
  9. Why would doing it in ajax become nullify the "real time" part of ajax? If the script is returning a huge amount of results, then just use ajax to check and see if there are alerts to view, if there is, then give the user a message, if not, then leave them alone. Ajax has nothing to do with the actual query...it's merely displaying the results. Your server is doing the query.
  10. I would recommend the jpgraph library for this task. It is very easy to use and very powerful. [a href=\"http://www.aditus.nu/jpgraph/\" target=\"_blank\"]http://www.aditus.nu/jpgraph/[/a]
  11. [!--quoteo(post=357087:date=Mar 21 2006, 03:48 PM:name=craygo)--][div class=\'quotetop\']QUOTE(craygo @ Mar 21 2006, 03:48 PM) [snapback]357087[/snapback][/div][div class=\'quotemain\'][!--quotec--] Man you guys have been failing me lately[/quote] Sorry to hear you had to learn something with out us. I've noticed that the number of people on the site has declined dramatically the last few days. It's 530 pm here now, and usually when I look at the number of people viewing the form it's 150+ this time of day. Right now it's 16. I hate to attribute it to the new ads, but that's the only really noticeable change that's taken place.
  12. Change: [code]if(is_uploaded_file($_FILES['Picture']['tmp_name']))[/code] to: [code]if ($_FILES['Picture']['size'] > 0)[/code]
  13. Change: [code]echo $result;[/code] to: [code]echo "<table>"; while ($row = mysql_fetch_array($result)) {   echo "<tr>";   foreach ($row as $key => $value) {     echo "<td>$key</td><td>$value</td>";   }   echo "<tr>"; } echo "</table>";[/code] when you assign $result to mysql_query("some sql") it creates a reference to the object that contains your data. You have to use other php mysql functions to access the data contained inside.
  14. I think this will give you what you want: [code]<?php $query = "SELECT * FROM Cards_table"; $result = mysql_query($query); while ($row = mysql_fetch_array($result)) {     $id = $row['CardID'];     $cards[$id] = $row['CardName']; } $query = "     SELECT Restaurants.RestaurantName, Cards_table.CardID     FROM Restaurants_Cards         LEFT JOIN Restaurants ON Restaurants_Cards.RestaurantID = Restaurants.RestaurantID         LEFT JOIN Cards_table ON Restaurants_Cards.CardID = Cards_table.CardID";          $result = mysql_query($query) or die(mysql_error()); while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {     $rname = $row['RestaurantName'];     $cid = $row['CardID'];     $accepted[$rname][] = $cid; } echo "     <table>         <tr>             <th>Restaurant Name:</th>             <th>Cards</th>         </tr>"; foreach ($accepted as $key => $value) {     echo "         <tr>             <td>$key</td>             <td>";     foreach ($cards as $cid => $card) {         echo "<input type=\"checkbox\" name=\"cards[$key][$cid]\" ";         if (in_array($cid, $value) {             echo "checked";         }         echo "> $card ";     }     echo "</td>         </tr>"; }[/code] It posts differently...do a print_r to see how it does it. You should end up with a sub array of $_POST called cards. The key values of cards should be the restaurant names, and should consist of another sub array that has the card id's as the key values and will contain the string "on" if the box is checked, or be empty if the box is not checked... Something like this: [code]Array (     [cards] => Array         (             [Applebees] => Array                 (                     [1] => on                 )             [Chilis] => Array                 (                     [1] => on                     [2] => on                 )             [Outback] => Array                 (                     [2] => on                 )         )     [submit] => submit )[/code] Where 1 is the id for visa and 2 is the id for master card. From this you can see that Chilis accepts both cards, but Outback only accepts master card, and Applebees only Visa.
  15. Change: [code]$lastpage = $pg +1; if($lastpage < 1){ $lastpage = $imgcount; }[/code] to: [code]$lastpage = $pg + 1; if ($lastpage > $imgcount) {     $lastpage = 1; }[/code]
  16. What your asking doesn't make any sense for the code that you've supplied. Please either explain better, provide more code, or both.
  17. [!--quoteo(post=356531:date=Mar 19 2006, 07:23 PM:name=Christopher Robin)--][div class=\'quotetop\']QUOTE(Christopher Robin @ Mar 19 2006, 07:23 PM) [snapback]356531[/snapback][/div][div class=\'quotemain\'][!--quotec--] Column 'timep' in order clause is ambiguous [/quote] That means that that column exists in more than one table. Specify which table you want it to select from in your query by doing tablename.timep.
  18. This should work. Make sure to read through it carefully and adjust names and such where needed. [code]<?php $query = "SELECT * FROM Cards_table"; $result = mysql_query($query); while ($row = mysql_fetch_array($result)) {     $cards[] = $row['CardName']; } $query = "     SELECT Restaurants.RestaurantName, Cards_table.CardName     FROM Restaurants_Cards         LEFT JOIN Restaurants ON Restaurants_Cards.RestaurantID = Restaurants.RestaurantID         LEFT JOIN Cards_table ON Restaurants_Cards.CardID = Cards_table.CardID";          $result = mysql_query($query) or die(mysql_error()); while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {     $rname = $row['RestaurantName'];     $cname = $row['CardName'];     $accepted[$rname][] = $cname; } echo "     <table>         <tr>             <th>Restaurant Name:</th>             <th>Cards</th>         </tr>"; foreach ($accepted as $key => $value) {     echo "         <tr>             <td>$key</td>             <td>";     foreach ($cards as $card) {         echo "<input type=\"checkbox\" name=\"$key-$card\" ";         if (in_array($card, $value) {             echo "checked";         }         echo "> $card ";     }     echo "</td>         </tr>"; }[/code]
  19. The manual is another excellent place to look: [a href=\"http://us3.php.net/manual/en/features.file-upload.php\" target=\"_blank\"]http://us3.php.net/manual/en/features.file-upload.php[/a]
  20. You could try [a href=\"http://www.php.net/exec\" target=\"_blank\"]http://www.php.net/exec[/a]. What are you doing that is going to be running for so long?
  21. in your code, change your mysql_query line to something like: [code]$result = mysql_query($query) or die(mysql_error());[/code] The important part being or die(mysql_error()); so that it will show you what is wrong with your query.
  22. If you look at your js errors, it says that form.banana has no properties...which means it doesn't exist. Remove that part of your code and it will work correctly.
  23. Ajax can not be used to upload files. Javascript is "sandboxed" and can not access the computer's file system, execpt for cookies. You will have to use a "conventional" posted form to upload the file. Also, how is your file upload working when you are not using the 'enctype="multipart/form-data"' declaration in your form?
×
×
  • 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.