Jump to content

richardw

Members
  • Posts

    120
  • Joined

  • Last visited

Contact Methods

  • Website URL
    http://www.richardweinberg.com

Profile Information

  • Gender
    Male
  • Location
    Providence, RI USA
  • Age
    59

richardw's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hello, Make sure your table has a timestamp, and then sort on the date, most recent first fot the last 20 mysql_query("SELECT * FROM SOMEWHERE ORDER BY yourtime_stamp DESC LIMIT 0,20"); I hope this helps Richard
  2. You will need a third party mudule. Pear is on most installs, so first you will have to track down ot's location. Specifically the "Speadsheet/Excel/Writer.php" script. That foundation will enable you to create an Excel file, complete with formatting and headers here is my example for a mailing list download: <?php // Include PEAR::Spreadsheet_Excel_Writer set_include_path('../PEAR/'); require_once("Spreadsheet/Excel/Writer.php"); // Create an instance $xls =& new Spreadsheet_Excel_Writer(); $today = date("Ymd"); // Send HTTP headers to tell the browser what's coming $xls->send("filename_here".$today.".xls"); // Add a worksheet to the file, returning an object to add data to $sheet =& $xls->addWorksheet('Mailing List Download'); $titleText = ' Mailing List generated: ' . date('dS M Y'); // Create a format object $titleFormat =& $xls->addFormat(); // Set the font family - Helvetica works for OpenOffice calc too... $titleFormat->setFontFamily('Helvetica'); // Set the text to bold $titleFormat->setBold(); // Set the text size $titleFormat->setSize('15'); // Set the text color $titleFormat->setColor('navy'); // Set the bottom border width to "thick" $titleFormat->setBottom(2); // Set the color of the bottom border $titleFormat->setBottomColor('navy'); // Set the alignment to the special merge value $titleFormat->setAlign('left'); // Add the title to the top left cell of the worksheet, // passing it the title string and the format object $sheet->write(0,0,$titleText,$titleFormat); // Some text to use as a title for the worksheet // $titleText = 'List Created:' . date('dS M Y'); // $sheet->write(0,1,$titleText); // Set up some formatting $colHeadingFormat =& $xls->addFormat(); $colHeadingFormat->setBold(); $colHeadingFormat->setFontFamily('Helvetica'); $colHeadingFormat->setBold(); $colHeadingFormat->setSize('10'); $colHeadingFormat->setAlign('center'); // An array with the data for the column headings // **************** ******************************* // $colNames = array('Item','Price($)','Quantity','Total'); // $sheet->writeRow(2,0,$colNames,$colHeadingFormat); // **************** ******************************* $str = "HEADING HERE"; //"$row["fname"]; $arr = explode (",", $str); $colNames = array('ID','Salutation','First Name','Middle Name','Last Name','last_index','first_index', 'Address','Address2','City','Organization','Oranization Type','role','Department','E-Mail','email_id','Phone','Title','State ID','Zip','Referral Source ID','Reffered By','OtherSource','created', 'modified', 'mail_type', 'sent_on'); $sheet->writeRow(2,0,$arr,$colHeadingFormat); $sheet->writeRow(5,0,$colNames,$colHeadingFormat); // Get data records from table. // leaving a blank row to look nicer // The row height // The cell group to freeze // 1st Argument - vertical split position // 2st Argument - horizontal split position (0 = no horizontal split) // 3st Argument - topmost visible row below the vertical split // 4th Argument - leftmost visible column after the horizontal split $freeze = array(6,0,7,0); // Freeze those cells! $sheet->freezePanes($freeze); // Use this to keep track of the current row number $currentRow = 8; // $sheet->setRow(0,30); // Set the column width for the first 4 columns $sheet->setColumn(0,3,15); // Write some numbers /* for ( $i=0;$i<11;$i++ ) { // Use PHP's decbin() function to convert integer to binary $sheet->write($i,0,decbin($i)); } */ // Connect database. // mysql_connect(""); // mysql_select_db(""); $host="localhost"; // Host name $username_s =""; // Mysql username $password_s =""; // Mysql password $db_name=""; mysql_connect("$host", "$username_s", "$password_s")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); // Get data records from table. $sql = "SELECT * FROM contacts"; $result =mysql_query($sql); // Create an array of arrays out of the recordset. while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $sheet->writeRow($currentRow,0,$row); $currentRow++; } // Finish the spreadsheet, dumping it to the browser $xls->close(); ?> For more detail google this module /* * Module written/ported by Xavier Noguer <xnoguer@rezebra.com> * * PERL Spreadsheet::WriteExcel module. * require_once 'PEAR.php'; require_once 'Spreadsheet/Excel/Writer/Workbook.php'; /** * Class for writing Excel Spreadsheets. This class should change COMPLETELY. * * @author Xavier Noguer <xnoguer@rezebra.com> * @category FileFormats * @package Spreadsheet_Excel_Writer */
  3. First is a suggestionto change your query updates into a switch staement to make it easier to track bracket sets which is the cause of the missing bracket, hence the unexpexted end. Second is more out of curiosity since I don't know your table strucutre, why are you updating the same field within the database with different value types: "forum_name" i.e. place, age, tel? if(isset($_POST['placech'])) { $forum = $_POST['place']; $query = "UPDATE users SET forum_name = '$place' WHERE user_id = '$user_id'"; $result = mysql_query($query); } if(isset($_POST['agech'])) { $forum = $_POST['age']; $query = "UPDATE users SET forum_name = '$age' WHERE user_id = '$user_id'"; $result = mysql_query($query);
  4. Try this: $arraynum = sizeof($uploaded); //how many entities the array contains //then use for each to loop through the insert statement up for x number of files uploaded insert into gallery (Title, Cat, Photographer, Makeup, Hair, Wardrobe, uploaded, destination) values('$Title'[$i],'$Cat[$i]','$Photographer'[$i],'$Makeup'[$i],'$Hair'[$i],'$Wardrobe'[$i],'$uploaded'[$i],'$destination[$i]')";
  5. can you post some code? why can't you join the tables and edit the respective data? Also, look at using replacements for the php tags such as: <?php or ?> php = "Hypertext Preprocessor" and the PHP scripts will be compiled at runtime by the PHP engine
  6. hi, check out this program which was posted about two years ago. it will create a basic foundation for you, then you will have to modify The php My SQL To fit your needs. IT will allow you to display and edit right away. i have not tested or used it since then, but i remember it as being very functional. you will still have to design your sql tables to meet your needs. http://iobe.net/proj/index.php?pg=install i hope this works for you
  7. try this, it is somewhat of a guess,but intval may helpinthe sorting SELECT t.team_id, t.level, t.name, t.initials, t.owner, l.user_id, SUM(l.2playerpts) AS 2playerpts, SUM(l.4playerpts) AS 4playerpts,SUM(l.6playerpts) AS 6playerpts, SUM(l.8playerpts) AS 8playerpts, l.wins, l.losses, u.user_id, u.team_id FROM teams t INNER JOIN users u ON u.team_id = t.team_id INNER JOIN leaderboard l ON l.user_id = u.user_id GROUP BY t.team_id $sum_on_this = intval((2playerpts + 4playerpts + 6playerpts + 8playerpts)); ORDER BY $sum_on_this DESC
  8. % is a wildcardas it "Matches any number of characters, even zero characters"
  9. there is also a good solution posted a day or two ago http://www.phpfreaks.com/forums/index.php/topic,214197.0.html
  10. hi, try using [MAX(date) as last_record however, you indicated date of entry, and also reffered to last modification. if that is the case, make sure to build in a routine To upate your date field on record modification. Keep in mind, if it is date of entry and it you have an autoincrement Id field you can probably select on The last id. best
  11. check out this solution by Barand: http://www.php-editors.com/forums/php-programming-help/2389-need-help-sorting-directory-files.html
  12. <?php $text = "Lanacane Anti-Chafing Gel, relieves and prevents soreness from rubbing skin and skin on clothing.<br />\r\nUnique barrier against friction.<br />\r\nSilky finish - dries on contact.<br />\r\nNon-greasy, non-staining and fragrance free.<br />\r\nLanacane Anti-chafing Gel forms a breathable barrier on your skin, to prevent and aid healing of chafing caused by repeated rubbing of skin on skin or clothing. <br />\r\n<br />\r\nUnique anti-friction formula dries on contact, clear, non-greasy, providing your skin with long lasting relief. <br />\r\n<br />\r\nGentle enough to use anywhere, everyday. <br />\r\n<br />\r\nDirections: A small amount of Lanacane Anti-Chafing Gel goes a long way.<br />\r\nSmooth a small dab on irritated area.<br />\r\nRe-apply if needed.<br />\r\nTo avoid future chafing, apply prior to activity.<br />\r\nIf pain from soreness and rubbing extends 7 days, consult doctor. For external use only. <br />\r\n<br />\r\nIngredients: <br />\r\nCyclopentasiloxane • Dimethicone Crosspolymer • Vinyl Dimethicone Crosspolymer • Zea Mays (Corn starch)."; echo $text ; seems to work. is there any other code used in the output routine? echo "<br><br>" ; echo nl2br($text) ; // provides extra space ?> myouput for the above is respectively: Lanacane Anti-Chafing Gel, relieves and prevents soreness from rubbing skin and skin on clothing. Unique barrier against friction. Silky finish - dries on contact. Non-greasy, non-staining and fragrance free. Lanacane Anti-chafing Gel forms a breathable barrier on your skin, to prevent and aid healing of chafing caused by repeated rubbing of skin on skin or clothing. Unique anti-friction formula dries on contact, clear, non-greasy, providing your skin with long lasting relief. Gentle enough to use anywhere, everyday. Directions: A small amount of Lanacane Anti-Chafing Gel goes a long way. Smooth a small dab on irritated area. Re-apply if needed. To avoid future chafing, apply prior to activity. If pain from soreness and rubbing extends 7 days, consult doctor. For external use only. Ingredients: Cyclopentasiloxane • Dimethicone Crosspolymer • Vinyl Dimethicone Crosspolymer • Zea Mays (Corn starch). --------> with nl2br Lanacane Anti-Chafing Gel, relieves and prevents soreness from rubbing skin and skin on clothing. Unique barrier against friction. Silky finish - dries on contact. Non-greasy, non-staining and fragrance free. Lanacane Anti-chafing Gel forms a breathable barrier on your skin, to prevent and aid healing of chafing caused by repeated rubbing of skin on skin or clothing. Unique anti-friction formula dries on contact, clear, non-greasy, providing your skin with long lasting relief. Gentle enough to use anywhere, everyday. Directions: A small amount of Lanacane Anti-Chafing Gel goes a long way. Smooth a small dab on irritated area. Re-apply if needed. To avoid future chafing, apply prior to activity. If pain from soreness and rubbing extends 7 days, consult doctor. For external use only. Ingredients: Cyclopentasiloxane • Dimethicone Crosspolymer • Vinyl Dimethicone Crosspolymer • Zea Mays (Corn starch).
  13. Here is an ftp solution, useful if you want ownership to show instead of "nobody". This example will post your uploaded file into a database for later use. <?php if(isset($_POST['start_upload']) && $_FILES['txt_file']['name'] != ""){ $local_file = $_FILES['txt_file']['tmp_name']; // Defines Name of Local File to be Uploaded $destination_file = "/public_html/YourDomain/docs/".($_FILES['txt_file']['name']); // $destination_file = "/recreation/images/".basename($_FILES['txt_file']['name']); // Path for File Upload (relative to your login dir) // Global Connection Settings $ftp_server = "address_see_note_at right"; // FTP Server Address (exlucde ftp://) $ftp_user_name = "user_here"; // FTP Server Username $ftp_user_pass = "pass_here"; // Password // Connect to FTP Server $conn_id = ftp_connect($ftp_server); // Login to FTP Server $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); // Verify Log In Status if ((!$conn_id) || (!$login_result)) { // echo "FTP connection has failed! <br />"; // echo "Attempted to connect to $ftp_server for user $ftp_user_name"; // exit; } else { // echo "Connected to $ftp_server, for user $ftp_user_name <br />"; } $upload = ftp_put($conn_id, $destination_file, $local_file, FTP_BINARY); // Upload the File // Verify Upload Status ?> <?php if (!$upload) { $message = "<h2>FTP upload of ".$_FILES['txt_file']['name']." has failed!</h2><br /><br />"; } else { $link = "http://www.domainname_here.com/docs/".$_FILES['txt_file']['name']; $file_name = $_FILES['txt_file']['name']; // </font><br /><br /><br /><br />"; $message = "Success!<br /><br />" . $_FILES['txt_file']['name'] . " has been uploaded to " . $ftp_server . $destination_file . "!<br /><br />"; $title = $_POST["title"]; $description = $_POST["description"]; $category = $_POST["category"]; // Connect to Database include "db_conn.php"; $sql = "INSERT INTO docs ( title,link,filename,description,category) VALUES ('$title','$link','$file_name','$description','$category')"; $result = mysql_query($sql); } ftp_close($conn_id); // Close the FTP Connection } ?> and my form is: <form action="<?php echo $_SERVER['PHP_SELF'];?>" method="POST" enctype="multipart/form-data"> Please choose a file: <input name="txt_file" type="file" size="35" /><br /> <br /> File Title: <input name="title" type="Text" size="62"> <br /> <br /> Description: <input name="description" type="Text" size="62"><br> <br> Category: <select name="category"> <option value=""> - Select - </option> <?php include "db_conn.php"; $sql2 = "SELECT * FROM cat ORDER BY category ASC"; $result2 = mysql_query($sql2); while ( $row2 = mysql_fetch_assoc( $result2)) { echo "<option value=\"".$row2["cat_id"]."\">".$row2["category"]. "</option>\n"; } mysql_free_result($result2); ?> One important item that I forgot to mention: The PHP code for the ftp upload must appear at the top of the page before the 'DOCTYPE' line. best
  14. I just wanted to know if your making headway. If not, I will give it a try in the am. I have already recreated your table structures, but I won't be able to test my query till the am.
  15. Hi, YOu are missing a ' before the 5 in your enum field CREATE TABLE users ( id int(11) NOT NULL auto_increment, username varchar(22) NOT NULL, password varchar(32) NOT NULL, email_address varchar(155) NOT NULL, nickname varchar(255) NOT NULL, user_level enum('0','1','2','3','4','5') default '0' NOT NULL, forum_posts int(11) default '0' NOT NULL, profile text NOT NULL, siggy varchar(255) NOT NULL, last_post varchar(155) NOT NULL, last_login varchar(12) NOT NULL, style varchar(55) NOT NULL, PRIMARY KEY (id) ) TYPE=MyISAM try this
×
×
  • 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.