Jump to content

jcbones

Staff Alumni
  • Posts

    2,653
  • Joined

  • Last visited

  • Days Won

    8

Everything posted by jcbones

  1. They need to pass the variables to the next page. It would be better to use SESSION (IMO), but sending them in that manner will work also.
  2. Couple of things. 1. isset() will return true IF the variable is set, and it's value is NOT null. So, if any of the 8 fields that doesn't have a default value, is not assigned a value, you will get a fatal error. Which means all of your arguments will be set. To correct this behavior, you could. A: set a default value of each argument as NULL. (Thus allowing the isset() function to do it's job.) Or, B: Change the isset() function to empty() function. This will test if the argument ' ' was passed to it. 2. You need to rethink how you are doing this. If $region is NOT set, then your query will not be built right. I would suggest putting all of the variables into an array, then imploding. if(isset($city) || isset($region) || isset($size) || isset($vendor) || isset($faces) || isset($status) || isset($artwork) || isset($recommendation) || isset($illumination)) { $fquery .= " WHERE"; if(!empty($region)){ $query[] = " Region = '{$region}'"; } if(!empty($city)){ $query[] = " City = '$city'"; } if(!empty($size)){ $query[] = " Size = '$size'"; } if(!empty($vendor)){ $query[] = " Vendor = '$vendor'"; } if(!empty($faces)){ $query[] = " Faces = $faces"; } if(!empty($status)){ $query[] = " Status = '$status'"; } if(!empty($artwork)){ $query[] = " Aartwork = '$artwork'"; } if(!empty($recommendation)){ $query[] = " Recommendation = '$recommendation'"; } if(!empty($illumination)){ $query[] = " Illumination = '$illumination'"; } $setQuery = implode('AND',$query); } $fquery .= " $setQuery ORDER BY Board_ID LIMIT 0, $limit"; echo $fquery; }
  3. Post your full code. We can simplify the database calls, and get it to pull all the data with one loop to populate the array.
  4. Does $search->results() return a simple array, or multi-dimensional array?
  5. Since I was being a *(&# I decided to go ahead and make something up for you. It works, but you may want to change the formatting of it. <?php session_start(); $timestamp = time(); $diff = 3600; if(isset($_SESSION['ts'])) { $slice = ($timestamp - $_SESSION['ts']); $diff = $diff - $slice; } if(!isset($_SESSION['ts']) || $diff > 3600 || $diff < 0) { $diff = 3600; $_SESSION['ts'] = $timestamp; } //Below is demonstration of output. Seconds could be passed to Javascript. $diff; //$diff holds seconds less than 3600 (1 hour); $hours = floor($diff / 3600) . ' : '; $diff = $diff % 3600; $minutes = floor($diff / 60) . ' : '; $diff = $diff % 60; $seconds = $diff; ?> <div id="strclock">Clock Here!</div> <script type="text/javascript"> var hour = <?php echo floor($hours); ?>; var min = <?php echo floor($minutes); ?>; var sec = <?php echo floor($seconds); ?> function countdown() { if(sec <= 0 && min > 0) { sec = 59; min -= 1; } else if(min <= 0 && sec <= 0) { min = 0; sec = 0; } else { sec -= 1; } if(min <= 0 && hour > 0) { min = 59; hour -= 1; } var pat = /^[0-9]{1}$/; sec = (pat.test(sec) == true) ? '0'+sec : sec; min = (pat.test(min) == true) ? '0'+min : min; hour = (pat.test(hour) == true) ? '0'+hour : hour; document.getElementById('strclock').innerHTML = hour+":"+min+":"+sec; setTimeout("countdown()",1000); } countdown(); </script>
  6. Sorry, I haven't had a chance to use HLMGTFY in the last few days, so I jumped on it. Example: <?php session_start(); $timestamp = time(); $diff = 3600; if(isset($_SESSION['ts'])) { $slice = ($timestamp - $_SESSION['ts']); $diff = $diff - $slice; } if(!isset($_SESSION['ts']) || $diff > 3600 || $diff < 0) { $diff = 3600; $_SESSION['ts'] = $timestamp; } //Below is demonstration of output. Seconds could be passed to Javascript. $hours = $diff; //$diff holds seconds less than 3600 (1 hour); echo floor($hours / 3600) . ' : '; $minutes = $hours % 3600; echo floor($minutes / 60) . ' : '; $seconds = $minutes % 60; echo floor($seconds); ?>
  7. HLMGTFY There is plenty of tutorials on this subject.
  8. Try: $test->changeValue(); echo $test2->myvar . '<br />' . $test->myvar;
  9. This is one way, regex might not be right, un-tested. if(!preg_match('~^[A-Za-z]{2}~',$password)) { $hold = $characters[rand(0,51)]; $hold .= $characters[rand(0,51)]; $password = preg_replace('~^(.){2}~',$hold,$password); }
  10. jcbones

    Help, how.

    Of course it is simple. The problem lies in that no one could possibly offer you a solution, being that they have no idea how your database is structured. Since this is purely a database driven problem, sufficient data, such as table name and column names is important. Any other way will just leave you flustered. But, since your are so anxious for an answer. UPDATE `table` SET `column` = column + 1 WHERE `id` = '$id' Couple that with: setcookie('updated','set',84000); And you have an updated column, that can only be updated once per user. IF the code is put together correctly.
  11. A callback function for array_walk is built that it takes one argument, and returns either true or false. It is built in the same manner as a regular function, but make sure it has an argument to it. When the array_filter runs, it runs each element of the array against your function. //Is first char a letter? suppose to be a number. function letters($str) { $str = substr($str,0,1); if(!is_numeric($str)) return false; return true; } //make an array; $array = array('me','exercise','another','none','1dies'); //filter the array by our function; $array1 = array_filter($array,'letters'); var_dump($array1); On the other hand, array_walk passes both the key, and the value to a user defined function. As in: function letters($value,$key) { $str = substr($key,0,1); echo $str . ': ' . $value . "<br />\n"; return; } //make an array; $array = array('me' => 'walking', 'fall' => 'exercise', 'taste' => 'another', 'three' => 'none', '14' => '1dies'); //filter the array by our function; array_walk($array,'letters'); PS. don't bump, we see it.
  12. If you don't have photoshop, you can use this online .ico generator.
  13. echo $count; //<- must have semicolon; Your query is failing: //replace $result=mysql_query($sql); //with $result=mysql_query($sql) or die(mysql_error());
  14. You are going to have problems with that set up. It would be better to set your table up as "id","login","timein","timeout","real_date". Run an Insert for clock in, and an update for clock out. UPDATE `clock` SET `timeout`='$timeout' WHERE `login` = '$user' AND `real_date` = CURDATE() Otherwise, you are going to try and make sure all of the `reason` = 1 dates, line up with `reason` = 2 dates, and account for lunch times, etc. Pulling reports would be just a matter of finding the table data, and formatting with HTML.
  15. I'm sorry, he asked a question. He knew what functions to use. He couldn't figure it out. So yes, he has the code, now he knows the answer. I'm not that smart, I just had help when I started out. The same kind of help I just gave, and not vague suggestions dancing around an answer. BTW, strtotime() does care which way you insert the date into it. Giving it a "mm-dd-yyyy" will return the wrong date. It looks for "dd-mm-yyyy".
  16. //07.02.2010 = sign up date. $date = date('d.m.Y',strtotime('+7 days',strtotime("$signupdate-$signupmonth-$signupyear"))); //14.02.2010 = output date.
  17. Well, we could guess what the data is. Or, how you want the averaging to happen. Simple as it gets. $count = 0; while($row = mysql_fetch_assoc($namelessTablewithWhoKnowsWhatKindOfData)) { //How many entries are there. ++$count; //The sum of the column you want averaged. $sum += $row['columnIwantToaverage']; } $average = round($sum / $count); Of course, if it was a little clearer, then we could use some MySQL functions to speed up the process.
  18. Change: //This gets today's date $date = time (); To: $date = (!isset($_GET['month']) && !isset($_GET['year'])) ? time() : strtotime($_GET['month'] . '/1/' . $_GET['year']); Your links should be: //find this line: echo "<tr><th colspan=7> $title $year </th></tr>"; //add links here (suggestion only); echo "<tr><th colspan=7><a href=\"?month=". ($month - 1) . "&year=$year\"><<</a> $title $year <a href=\"?month=" . ($month + 1) . "&year=$year\">>></a></th></tr>"; Hope there is no errors in there.
  19. You must send the page the $month variable. This would be in a $_GET array. You set a $_GET array by passing it in the URL. <a href="page.php?month=02">Feb</a> PHP will then GET the variable $month from the URL, and pass it to the page. $month = $_GET['month']; You can force the variable to an integer by assigning it: $month = (int) $_GET['month']; From your original post: You would need to make the links I've described above, for each of these months.
  20. I see file_get_contents now. Which makes me either crosseyed, tired, or stupid (probably a combo of all 3). The file doesn't exist. Did you check to see if it arrived in the directory you pointed it to? Why do you want to save the image to a directory if you are going to base64 encode it into your database?
  21. The warning you have posted: has nothing to do with move_uploaded_file. You need to look around line 69, or just post your entire script.
  22. Since there is no validation on this page, I'm assuming it is not "staffRequestValidate.php". Which is where all of the validation from this form resides.
  23. $sql = "SELECT * FROM `chat` WHERE `room` = '$room_id' AND `time` > '$time'"; Since I see no code on this thread, I cannot give you a clear answer. 1. We don't know what format $newmsgtime is. 2. We don't know what format userlogintime CONSTANT is. 3. We don't know what the time column in your database is. 4. We don't know what the name of your time database column is.
  24. Let me explain this way. $n = 0; echo $n++; // 0 = echo $n then increment the number. echo $n; //1 = echo $n echo ++$n; // 2 = echo $n AFTER incrementing the number. Durn Ken beats everyone to the punch.
  25. I have a database with country names, each name can appear several times in the database. I want to use the database to create a dropdown menu but i dont know how to limit each country to appear just once. There is probobly a simple solution, i just havent evolved to that level. $sql = "SELECT DISTINCT country FROM table ORDER BY country ASC"; And if you have trouble with that query (Sometimes DISTINCT doesn't like the ORDER BY clause). Try. SELECT DISTINCT country FROM (table INNER JOIN table AS t ON table.id=t.id) ORDER BY country DESC;
×
×
  • 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.