sunfighter
Members-
Posts
579 -
Joined
-
Last visited
Never
Everything posted by sunfighter
-
I use this site for pure dropdowns without js, http://www.htmldog.com/articles/suckerfish/dropdowns/ But I have found this http://purecssmenu.com/ If you use that please let us know what you think about it.
-
Generating a list from available products in database.
sunfighter replied to elmas156's topic in PHP Coding Help
Why do you even have two table here? Why not just add column `resdate` to the products table? -
There are a lot of way of approaching this. You should make up your mind on a course of action before starting to code. What follows are my thoughts. First, forget the CMS and input from users until you have the page figured out. Add it last. Are you going to limit the activities per division of the day or make the list infinite? Infinite would mean a number of tables in our database, while setting a limit, of say 5 activities would mean one table. How are you going to display the PLACES to begin with? After the user picks a place it's easy to keep the place names in a vertical list or a couple of vertical lists. If we restrict the activities to 5, we would need a table with a column for the place name followed by 21 times 5 [ 105 ] columns for the activities. Then we would query the table for everything in the place_name column and after the selection get everything WHERE place_name = "the selection". No looping needed! Make your design decisions and code it. Then come back for user input help.
-
While it is posible to add columns and drop them from a table by programming, it may be easier to use a multidimensional array. It is easy to store the array in a file if need be. Below is the code for making the array with a dump for showing the array's contents and a method for displaying the individual rates. PS. The database method I gave you earlier suffers from updating each column one at a time. While 33 accesses may not be too bad, it's not elegant. <?php $XMLContent=file("http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml"); //the file is updated daily between 2.15 p.m. and 3.00 p.m. CET foreach($XMLContent as $line){ if(preg_match("/currency='([[:alpha:]]+)'/",$line,$currencyCode)){ if(preg_match("/rate='([[:graph:]]+)'/",$line,$rate)){ //Output the value of 1EUR for a currency code //echo '1€ = ' . $rate[1] . ' ' . $currencyCode[1] . ' -- ' . $i++.'<br/>'; $name[] = $currencyCode[1]; $money[] = $rate[1]; } } } $big = array_combine($name, $money); print_r($big); echo '<br />===================<br />'; $first = 'USD'; $last = 'ZAR'; echo 'The exchange rate for '.$first.' is '.$big[$first].'<br />'; echo 'The exchange rate for '.$last.' is '.$big[$last].'<br />'; ?>
-
I'd make the table with 34 columns. Name the columns after the currency name plus an id and place the rate in the column. Maybe you want the date also?? If your going to replace the info by destroying the old data you might think on using an array to store the info. But back to my idea. Assume table already set up with data and an id column where the id is set to 1. UPDATE table_name SET $currencyCode[1] = $rate[1] WHERE id = 1; This will set up your db /* Database export results for db hours*/ /* Preserve session variables */ SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS; SET FOREIGN_KEY_CHECKS=0; /* Export data */ /* table structure for places */ CREATE TABLE `exchange` ( `id` tinyint(1) NOT NULL, `USD` decimal(10,5) NOT NULL, `JPY` decimal(10,5) NOT NULL, `BGN` decimal(10,5) NOT NULL, `CZK` decimal(10,5) NOT NULL, `DKK` decimal(10,5) NOT NULL, `GBP` decimal(10,5) NOT NULL, `HUF` decimal(10,5) NOT NULL, `LTL` decimal(10,5) NOT NULL, `LVL` decimal(10,5) NOT NULL, `PLN` decimal(10,5) NOT NULL, `RON` decimal(10,5) NOT NULL, `SEK` decimal(10,5) NOT NULL, `CHF` decimal(10,5) NOT NULL, `NOK` decimal(10,5) NOT NULL, `HRK` decimal(10,5) NOT NULL, `RUB` decimal(10,5) NOT NULL, `TRY` decimal(10,5) NOT NULL, `AUD` decimal(10,5) NOT NULL, `BRL` decimal(10,5) NOT NULL, `CAD` decimal(10,5) NOT NULL, `CNY` decimal(10,5) NOT NULL, `HKD` decimal(10,5) NOT NULL, `IDR` decimal(10,5) NOT NULL, `ILS` decimal(10,5) NOT NULL, `INR` decimal(10,5) NOT NULL, `KRW` decimal(10,5) NOT NULL, `MXN` decimal(10,5) NOT NULL, `MYR` decimal(10,5) NOT NULL, `NZD` decimal(10,5) NOT NULL, `PHP` decimal(10,5) NOT NULL, `SGD` decimal(10,5) NOT NULL, `THB` decimal(10,5) NOT NULL, `ZAR` decimal(10,5) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; /* data for table places */ insert into exchange values(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1); This is the php to update it: <?php require ('./inc/emmy_connect.php'); $XMLContent=file("http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml"); //the file is updated daily between 2.15 p.m. and 3.00 p.m. CET $i = 0; foreach($XMLContent as $line){ if(preg_match("/currency='([[:alpha:]]+)'/",$line,$currencyCode)){ if(preg_match("/rate='([[:graph:]]+)'/",$line,$rate)){ //Output the value of 1EUR for a currency code echo '1€=' . $rate[1] . ' ' . $currencyCode[1] . ' -- ' . $i++.'<br/>'; $query = "UPDATE exchange SET " . $currencyCode[1] . " = " . $rate[1] . " WHERE id = 1"; $result = mysql_query($query); } } } ?>
-
Had a little time so worked on it. This is your query $strEditProfile = "UPDATE tblemployee SET EmployeeName=".$_POST['edit_thename'].", Address1 = ".$_POST['edit_address1'].", Address2 = ".$_POST['edit_address2'].", DesignationID = ".$_POST['edit_des'].", Postcode = ".$_POST['edit_postcode'].", State = ".$_POST['edit_state'].", Country = ".$_POST['edit_country'].", Tel1 = ".$_POST['edit_contact'].", WHERE EEmail=".$_POST['edit_email'];
-
Things like this $_POST[edit_address1] must be in quotes like this $_POST['edit_address1'] and you need to escape most of your quotes. Echo out each section in $strEditProfile to see where.
-
query 3 tables to retrieve fields value and display table in a page
sunfighter replied to danielbala's topic in MySQL Help
Everything you want to show is in the last table. You don't need the first two. But I think you should reconsider how you have things set up. First thing I see is the three activities under activity table.activity done How are you going to handle an email AND a visit? And how about several emails? Maybe change the to three columns and have how many times as the value. You have no way of knowing who has no job assignment nor what jobs are not active. You could have 5 workers and 2 of them straddled with most of the work. You should link the employee table and job table together. And the job table to activity table and drop some of the column there. Try googleing Database Normalization or something similar. -
PHP echo table dependent on drop down box's on same page
sunfighter replied to edd12345678's topic in PHP Coding Help
A rule of thumb here is any time you need to access a database you have to go server side so the page reloads or you use ajax and the page just changes. using ajax you don't need a submit button for the dropdowns( actually that's because of javascript). Each one can fire the ajax using the onchange tag. So here's an example that means without the need to load a new page. Your table lists every person,all 300 million plus, by name, that lives in the US. The first DD(drop down) picks OHIO and the table changes to list only those that live in ohio. The second DD chooses Akron, the table again changes. The last DD picks THOMAS and now the table has the name of every body that lives in Akron, Oh with the first name of Thomas. So what do you want to do? -
Lets do this right . Import this to the database your using: /* Database export results for db hours*/ /* Preserve session variables */ SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS; SET FOREIGN_KEY_CHECKS=0; /* Export data */ /* table structure for places */ CREATE TABLE `places` ( `spot` tinyint(10) NOT NULL, `name` varchar(10) NOT NULL, `lon` tinyint(2) NOT NULL, `lat` tinyint(2) NOT NULL, PRIMARY KEY (`spot`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; /* data for table places */ insert into `places` values (1,"WITCH",1,1); insert into `places` values (2,"MASK",2,2); insert into `places` values (3,"TEETH",5,3); /* Restore session variables to original values */ SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS; This will set you up with a table containing three rows, each with a lon and lat different from each other. Run this php file on it. <?php require ('./inc/DB_connect.php'); $query = "SELECT COUNT(*) from places WHERE lat = 5 AND lon = 3"; $result = mysql_query($query); $row = mysql_fetch_row($result); if($row[0] == 0) { echo 'No Matches Good to add this place'; }else{ echo 'Spot already lived in'; } ?> I combined the two queries I gave you earlier but it's the same code. Please look at it and study it. It contains the parts you were suppose to substitute. Reverse the 5 and the 3 and run again. This time there is a match in the db and it should catch it. If you are still having problems with this contact me via email this forum.
-
This should do it. Both lat and lon need to be in the table. This give zero rows if the random lat/lon is not in table. <?php $query = "SELECT COUNT(*) from table_name WHERE Lat_col = 'random_lat'"; $result = mysql_query($query); $lat = mysql_fetch_row($result); $query = "SELECT COUNT(*) from table_name WHERE Lon_col = 'random_lon'"; $result = mysql_query($query); $lon = mysql_fetch_row($result); if($lat[0] > 0 $$ $lon[0] > 0) you have a problem else its good to go ?>
-
Hi Andy, No, not in tracking industry. Use Gsak and a UPSr unit to geocache. And at one time, tied it into my Ham Radio for tracking my vehicle and sending weather info. My daughter is a hiker and uses it with her GPSr and with something called spot (i think) to upload her location and print it to a map on the internet, so we can track her. PS. I don't think you attached your database design.
-
Just want to say that you might want to check this out http://www.gsak.net/ Andy. I use it all the time.
-
youtube is loaded with tutorials. Or read something like this http://www.openjs.com/articles/ajax_xmlhttp_using_post.php got this from a google search. Just don't get confused between javascript and jquery! If you know javascript or want to learn it use javascript leave jquery alone.
-
Your inserting the $FileName into Location and then defining the $FileName. Why not define it before the query?
-
Read this article and see if it helps. http://javascript.about.com/library/bltip1.htm
-
Not trying to be funny, but this is so elemental I think you should go to http://www.w3schools.com/ and read up on html and css. You need to put a container into your body and place the div there. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>#</title> <style type="text/css"> #content { background-color: #dcd1cd; height: 780px; width: 960px; margin-right:auto; margin-left:auto; } div#top { height:390px; background-color: #1e6fb0; } </style> </head> <body> <div id="content"> <div id="top"> </div> </div> </body> </html>
-
how do I get display answer in an input element?
sunfighter replied to attaboy's topic in PHP Coding Help
Yes it is and a few more things also: file name is test_2.php <?php $ans=''; $what = 'answer:'; $group=''; $first=''; $second=''; if(isset($_POST["msoft"]) && ($_POST["msoft"] == "trash")) { if(isset($_POST['first_number'])) $first = $_POST['first_number']; if(isset($_POST['second_number'])) $second = $_POST['second_number']; if(isset($_POST['group1'])) $group = $_POST['group1']; if ($first != '' && $second != '') { switch ($group) { case "add": $ans = $first + $second; $what = 'addition'; break; case "subtract": $ans = $first - $second; $what = 'subtraction'; break; case "multiply": $ans = $first * $second; $what = 'multiplication'; break; case "divide": $ans = $first / $second; $what = 'division'; break; default: $ans = 'damm...'; } }else{ $ans = 'damm...'; } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <style type="text/css"> input {position:absolute; left:120px;} p {margin-bottom:-10px;} </style> </head> <body> <form method="post" action="test_2.php"> <input type="hidden" name="msoft" value="trash" /> <p>first number:<input type="text" name="first_number" value="<?php echo $first; ?>" /></p> <p>second number:<input type="text" name="second_number" value="<?php echo $second; ?>" /></p> <p><?php echo $what; ?><input type="text" name="answer" id="answer" value="<?php echo $ans; ?>" /></p> <ul> <li>add: <input type="radio" name="group1" value="add" /></li> <li>subtract: <input type="radio" name="group1" value="subtract" /></li> <li>multiply: <input type="radio" name="group1" value="multiply" /></li> <li>divide: <input type="radio" name="group1" value="divide" /></li> </ul> <p><input type="submit" value="submit" /></p> </form> </body> </html> -
Can't insert values into the table (no error message)
sunfighter replied to TottoBennington's topic in PHP Coding Help
You have a number of coding errors like no doc deceleration, no body or head tags, but the biggest is no start <?php as the first line. -
when a user signs in look up to see if they have download rights. In the menu php do an IF on that to put the menu item in that goes to the download page. Now only people that can download can get there. More = Make a folder called secret and have the button go there. Have the index file check for a cookie and if they do then send them to the download page. Do this in php. cookie = use a stange name for this like 'favorites' and have the code be something close to what the non downloaders will get. Like: @GFegcAbc for non and @GFeccAbc for people that can.
-
Sample drop down menu wont work, please help...
sunfighter replied to Hall of Famer's topic in CSS Help
Hall of Famer, It's working for me, but I put the CSS into the head of the HTML. Maybe your link is wrong. -
Your codes for me. Just to be sure your passing the correct values insert this line: echo '|'.$_SESSION["logged"].'|<br />'; Before the if statement to look at your variable. If $_SESSION["logged"] is empty you'll just get a pair of lines. If it has a value that value will appear between the lines.
-
Your ajax send should contain a NULL or use this xmlhttp.send('');
-
select multiple values from mysql between intervals
sunfighter replied to charles07's topic in PHP Coding Help
Your query is: select * from database where Device one = "off" and Device two = "off" -
You did a good job on the tooptip, it stays in view until the browser is shrunk to a width of 380px. At that time the tooltip itself has shrunk to 220px. If you want things to work for even smaller browser widths I would suggest moving the tooltip to display under and to the left of your image instead of to the right, because if you make the tooltip any smaller it would be hard to read and make any sense out of it.