Jump to content

kodosai

Members
  • Posts

    11
  • Joined

  • Last visited

    Never

Everything posted by kodosai

  1. Your problem is that your if segment that deals with going backwards (or forwards) only applies to the current date and time. You would need to put in some type of conditional inside of those that would do your calculations based on the current month you're viewing, rather than always on the current actual month. This is assuming that $month will always be available as a variable in the script (since it's starting out in current month/year on a default page load). if (isset ($_POST['back1'])) { if ($month == date('m',time())) { $date = time() - 269743; } else { $date = strtotime("$month-1-$year"); } $month = date('m',$date); $day = date('d',$date); $year = date('y',$date); $first_day = mktime(0,0,0,$month, 1, $year); $title = date('F', $first_day); $day_of_week = date('D', $first_day); }
  2. I usually only call this at run-time which would be done by putting this at the top of the script file <?php set_time_limit(0); ?>
  3. This might be a little more to standards and produce less overhead, but you do have the right idea. You might want to also look in to case/switch function in PHP as some people find that format easier to follow. **Also added in closing curly braces for the if/elseif/else segments (that was probably a typo in the original) <?php if ($row_rs_itemdetail['format']==Format1) { echo 'Format 1 Dropdown'; { elseif ($row_rs_itemdetail['format']==Format2) { echo 'Format 2 Dropdown'; } elseif ($row_rs_itemdetail['format']==Format3) { echo 'Format 3 Dropdown'; } else($row_rs_itemdetail['format']==Format4) { echo 'Format 4 Dropdown'; }?>
  4. there is no imposed limitation attribute on the <textarea> tag. Only on the <input type=text> will that limitation work. Although I did find this option available, but only with the use of javascript. http://javascript.internet.com/forms/limit-textarea.html Not a very good solution with the amount of people that turn js off these days. Still though, My recommendation would be to do a javascript counter maybe as just a way of notifying the user they have "x" characters left, and that the form handler will truncate anything larger than X characters when submitted.
  5. What I used to approach this was the following: In the accounts/users table, create a field for securitygroup. Or more specifically in your case I would put in a field for an array of modules (like comma separated numeric values) that the user has subscribed to, purchased, or has access to. then in your menu table you have each module that contains a numeric identifier (or some other type of GUID of your choosing) That way when building your menu output, you would just parse out the array for that user's account (probably storing in a session variable or cookie) and your menu query would be like select * from menu where module_id in($parse1,$parse2,etc); Then again in your menu table, you could have the landing page for each module to help build the menu and the index.php would handle it via the post/get variables from the form... Using your "news" module as an example the menu would say news, it would link to index.php?mod=2 the index.php page would either contain the array locally of modules like so: $modules = array( 1 => 'index.php' 2 => 'news.php' ); or you could query the database again and it would just do an include('news.php'); statement in the appropriate output area to display the data.
  6. $first=$_POST['first']; $last=$_POST['last']; $city=$_POST['city']; $state=$_POST['state']; This portion is just adding overhead and unncessary. Just use the $_POST['var'] itself in the query construction statement. <?php include("dbinfo.inc.php"); mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query="SELECT * FROM contacts"; $result=mysql_query($query); while ($row = mysql_fetch_object($result)) { echo '<td>' . $row->first . '</td>'; echo '<td>' . $row->last . '</td>'; echo '<td>' . $row->city . '</td>'; etc... } mysql_free_result($result); ?> One problem you may have having with your scripts is the use of "short tags" for the php opening tag. Use "<?php" not just "<?" It's bad practice and a bad habit to get in to. Try using the above modified section as a better method for your search code, less overhead and less hassle to mess with than your method. In your 3rd block of code, you are utilizing an mysql_fetch_array(), which is going to cause you some issues if it's only returning one thing or nothing. Again, might want to use the mysql_fetch_object() function instead as you won't run in to those issues. You also might want to nest your results displays inside of the check for whether you got any results or not. Just makes more logical sense from a code stance.
  7. Not too familiar with mysql..so bear with... while ($row = mysql_fetch_assoc($result)) { if ($row['energy'] < $row['maxenergy']){ // Check to see if energy is less than max $new_energy = $row['energy'] + 5; // add 5 to energy if($new_energy > $row['maxenergy']){ // check to make sure energy is not more than max $new_energy = $row['maxenergy']; // set energy to max energy if it was previous greater than. } $query = sprintf('UPDATE players set energy = $new_energy where id = $row['id']); myqsql_query($query) or die(mysql_error()); } }
  8. Your Code: echo "<tr><td>" . $row1['name'] . "</td><td>" . $row1['lastname'] . "</td><td>" '<a href="' . $row1['link'] . '">Click Here</a>' "</td><td>" . $row1['poll'] . "</td></tr>"; Proper Code: echo '<tr><td>' . $row1['name'] . '</td><td>' . $row1['lastname'] . '</td><td><a href="' . $row1['link'] . '">Click Here</a></td><td>' . $row1['poll'] . '</td></tr>'; As a tip...try to get used to using single quotes for strings unless a variable is enclosed in the quotes. It processes the echo faster than doing everything in double quotes. If double quotes are used, PHP has to spend overhead searching for a variable to expand in there before it can process out the echo value. Realistically you may not even have to use the double quotes I put in the Proper Code to work, but you do to meet W3C DOM requiresments for tag attributes.
  9. add this in your headers... 'MIME-Version: 1.0' . "\r\n"; 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
  10. It uses $tmp as the array handle... A "basic" usage of file() is $myfile = file('myfilename.txt'); He's just, think of it as nesting functions so: $tmp = array_map('trim', file('myfilename.txt'); works in this order. Get me an array in an internal handle for file('myfilename.txt'), then perform array_map() on that results and trim whitespace, and assign the result to the $tmp array...
  11. echo '<a href="' . $row1['filelink'] . '">Click Here</a>';
×
×
  • 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.