Jump to content

richardw

Members
  • Posts

    120
  • Joined

  • Last visited

Everything posted by richardw

  1. Try using DISTINCT on one field in your table first. Also, is ZIP_CLASS defined? <?php SELECT DISTINCT FROM fieldnamehere WHERE (CITY = 'ORLANDO' OR CITY = 'WINTER PARK' ) AND ZIP_CLASS='STANDARD'; ?> OR I think you may mean this... a guess anyway. Also be aware of the case, ie ORLANDO will not match Orlando. <?php SELECT DISTINCT FROM ZIP_CLASS WHERE (CITY = 'ORLANDO' OR CITY = 'WINTER PARK' ) ORDER BY ZIP_CLASS asc; ?> best
  2. Look at the following page: http://66.223.105.215/pictures.php <?php $conn= mysql_connect("localhost" ,"uname" ,"password" ) ; if(!$conn) { echo "Unable to connect to DB: " . mysql_error(); exit; } if (!mysql_select_db("gallery")) { echo " Unable to select gallery Database: " . mysql_error() ; exit; } $sql = "SELECT * FROM stock_tbl"; $result = mysql_query( $sql); if ( mysql_num_rows($result) == 0) { echo "No Documents Available at this time"; } else { $num_results = mysql_num_rows($result) ; echo "There are currently", $num_results, " images available<br>"; while ( $row = mysql_fetch_assoc( $result)) { echo $row["st_id"], " - <img src=", $row["image"], " /><br>", $row["descr"], " - ", $row["price"] ,"<br>"; ?> <?php echo "<br>"; } } mysql_free_result($result); ?> It was created from the following schema: # # Table structure for table `stock_tbl` # CREATE TABLE `stock_tbl` ( `st_id` int(11) NOT NULL auto_increment, `name` varchar(15) NOT NULL default '', `image` varchar(255) NOT NULL default '', `descr` text NOT NULL, `stock` enum('No','Yes') NOT NULL default 'No', `dateadd` date NOT NULL default '0000-00-00', `price` tinytext NOT NULL, KEY `st_id` (`st_id`) ) TYPE=MyISAM AUTO_INCREMENT=2 ; # # Dumping data for table `stock_tbl` # INSERT INTO `stock_tbl` VALUES (1, 'Sloop', 'DSC_2691.JPG', 'Picture from my sailing trip', 'No', '2007-02-05', 'N/A');
  3. I am going to try and replicate your table and test it, but how are you storing your images, or is this just a link to your image. Also, have you worked with this server before? I have never seen the code reappear in that manner unless it was pasted into a WYSIWIG screen. What are you using for an editor?
  4. This connection string may be helpful in finding the error, <?php $conn = mysql_connect("correcthost", "correctuser", "correctpassword"); if (!$conn) { echo "Unable to connect to DB: " . mysql_error(); exit; } if (!mysql_select_db("correct")) { echo "Unable to select Database: " . mysql_error(); exit; } $show_all = 'SELECT * FROM stock_tbl' ; $result = mysql_query($show_all ); if (!$result) { echo "Could not successfully run query ($sql) from DB: " . mysql_error(); exit; } if (mysql_num_rows($result) == 0) { echo There are no rows found"; exit; } $num_results = mysql_num_rows($result); // echo above $num_results to check rows returned while ($row = mysql_fetch_assoc($result)) { echo $row['st_id']. ' - <img src="'. $row['image'] . '" />' . $row['descr'] . ' - ' . $row['price'] .,"<br>"; } mysql_free_result($result); ?> Keep going! If this does not work, could you post your table structure...
  5. Dont forget to connect to the DB before executing the select statement. Also I always use "mysql_free_result($result); " after the while loop $show_all = 'SELECT * FROM stock_tbl' ; $result = mysql_query ($show_all) or die ( mysql_error ()); while ($row = mysql_fetch_assoc($result)) { echo $row['st_id']. ' - <img src="'. $row['image'] . '" />' . $row['descr'] . ' - ' . $row['price'] . " \n"; } mysql_free_result($result); ?> Hope this helps,
  6. Try using substr, this works for me $daystring = $row["birthdate"]; $month = substr($daystring, 4, 2); $day = substr($daystring, 6, 2); $year = substr($daystring, 0, 4); Best,
  7. (2038 is the default last year that I have been able to test scripts through, so it souns like its defaulting to the end) Try adding it to the query, such as: "SELECT *, date_format(begindate, '%m/%d/%Y'), date_format(enddate, '%m/%d/%Y') FROM road" Then, echo back: <?php echo $row["date_format(begindate, '%m/%d/%Y')"]; ?> This works with the UNIX 14 digit timestamp. Alternately, you can my convoluted method (works create with many calendar scripts if you bring the date field in for editing): $daystring = $row["begindate"]; $month = substr($daystring, 4, 2); $day = substr($daystring, 6, 2); $year = substr($daystring, 0, 4); THEN: <?php echo $month,"-",$day,"-",$year ?> I hope this works for you.
  8. Take a look at Tiny MCE http://tinymce.moxiecode.com/ I use it frequently in forms to show formtted text in a textarea. "TinyMCE is a platform independent web based Javascript HTML WYSIWYG editor control released as Open Source under LGPL by Moxiecode Systems AB. It has the ability to convert HTML TEXTAREA fields or other HTML elements to editor instances. "
  9. Hopefully the post by chronister will work for you. If not I have had good luck extracting data from Word if it's in a column by using this command to exctract the column from word: Place the cursor in the upper left of the first column and then press the Shift and Alt keys together and drag to highlight your column. Cut and paste into notepad and insert the textfile into the respective field... repeat the process a few times. Another tip for data if it is in a table is to cut and paste the table into notepad, all formatting will be lost and the data should be intact. You might have to use a search & replace function to place delimiters between fields. best
  10. A date funtion that returns the current year if at least February or no later than November. Otherwise this script returns the current year, in November it will display 2007-2008 and last month, January it would have returned 2006-2007. This way the page always appears current ( a trash pickup schedule). The principals are the same for future and past dates. <?php $lastmonth = mktime(0, 0, 0, date("m")-1, date("d"), date("Y")); $nexttmonth = mktime(0, 0, 0, date("m")+2, date("d"), date("Y")); $lookahead = date("m")+2; $lookback = date("m")-1; $year0 = date('Y')-1; $year1 = date('Y') ; $year2 = date('Y')+1; $nextyear = mktime(0, 0, 0, date("m"), date("d"), date("Y")+1); if ($lookahead == "1") { echo $year1," - ",$year2; } elseif ( $lookback == "12" ) { echo $year0," - ",$year1; } else { echo $year1; } ?>
  11. Brian, Can you post your table structure? I belive you should be using the date() function for this purpose. Also, does your form bring back the current record data (less the time) prior to executing the UPDATE query. // set the default timezone to use. Available since PHP 5.1 date_default_timezone_set('UTC'); // Prints something like: Monday echo date("l"); // Prints something like: Monday 15th of August 2005 03:12:46 PM echo date('l dS \of F Y h:i:s A'); event_date='$idate', event_time='$time' // Prints: July 1, 2000 is on a Saturday echo "July 1, 2000 is on a " . date("l", mktime(0, 0, 0, 7, 1, 2000)); /* use the constants in the format parameter */ // prints something like: Mon, 15 Aug 2005 15:12:46 UTC echo date(DATE_RFC822); // prints something like: 2000-07-01T00:00:00+00:00 echo date(DATE_ATOM, mktime(0, 0, 0, 7, 1, 2000)); ?>
  12. I hope this will work for you, http://www.readybydesign.com/data2b.php    try using just the folling db & table databse: dpw and table: road
  13. if ($rank == 1) { $prize = "Auto; } elseif ($rank == 2) $prize = "500,000 points"; } else { echo "You loose"; exit; } or you could use the "case" function -- It is a very effecient way to handle more than three. I will try and post an example in a few minutes
  14. Take a look at this handout that I prepared last September... The first page cites reasons to use MySQL. [url=http://www.providenceri.com/NAGW/MySQL-handoutv2.pdf]http://www.providenceri.com/NAGW/MySQL-handoutv2.pdf[/url] Richard
  15. [quote author=emehrkay link=topic=121498.msg500008#msg500008 date=1168289980] I havent played around with it that much, but i have a program that can modify header info - are these queries basic posts? [/quote] The forms and queries are basic at the moment. My intent is to allow the program to generate code based on selected features. I would be interested in seeing your program if it is open source as it may let me see more possibilities.
  16. You are correct. The initial page is not well formatted, but my  idea was to test wether it was doable. I plan on breaking it into compents with more options and styling with prompts. I have been testing the code as I build new applications, with success. But I welcome feedback where errors may be found. Based on feedback  above, I plan on developing this into a user friendly tool with more options. The present output was so that I could test the internal routines. I will look to incorporate more error trapping, and yes I will look to use newer code or maybe provide an option for different versions of mysql / php and populate the code respectively. Here is one application built from db: dpw  and table: road (Well the input and edit pages are in a pw directory, but they allow for the output that can be seen) [url=http://www.providenceri.com/publicworks/road_closings.php]http://www.providenceri.com/publicworks/road_closings.php[/url] Thanks for the constructive comments. I hope to be able to post the code as GNU open source within a month after the formattiing and prompts are programmed.
  17. This is a simple program that will generate mysql code and forms for any given database and table. The information is read from the table schema and the connection string, INSERT, UPDATE, SELECT and DELETE statements are written. In additon, it builds two forms for inserting data and displaying data back so that content can be edited. Just copy and paste the code into a PHP page. The program based on feedback will be developed with a series of prompts so that a specific page can be written from top to bottom with the ability to select fields based on a checkbox. Try the program at: [url=http://www.readybydesign.com/data2b.php]http://www.readybydesign.com/data2b.php [/url]    try any combination, but for speed you can input databse: dpw and table: road Feedback needed.
×
×
  • 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.