ignace
Moderators-
Posts
6,457 -
Joined
-
Last visited
-
Days Won
26
Everything posted by ignace
-
Is this what you want to create? +----------+----------------+ | | 6% | .. +----------+----------------+ | 1st year | base+intrest^1 | .. +----------+----------------+ | 2nd year | base+intrest^2 | .. +----------+----------------+ | 3th year | base+intrest^3 | .. +----------+----------------+ Then this should do it: <?php $base = 100; $years = range(1, 12); $percents = range(6, 10); $number_of_years = sizeof($years); $total_percentages = sizeof($percents); for ($i = 0; $i < $number_of_years; ++$i) { for ($j = 0; $j < $total_percentages; ++$j) { $base += ($base * ($percents[$j] / 100))^$years[$i]; print 'Year: '. $years[$i] . ' Percentage: ' . $percents[$j] . ' Base+Intrest: ' . $base . '<br>'; } } ?> It misses the markup to create the table though
-
Yeah, manually resize them.
-
This implies you have ftp access to the remove server? Then why don't you create a script that just copies all videos from dir to backup?
-
Read the manual! <?php if (!empty($_POST)) { $column1 = $_POST['column1']; //.. $query = 'INSERT INTO table VALUES (\'%s\')'; $fquery = sprintf($query, $column1); mysql_query($fquery, $db); } ?>
-
<?php $el = new SimpleXmlElement('file.xml'); // $el == item $sizeOf = sizeof($el->list); for ($i = 0; $i < $sizeOf; ++$i) { $attributes = $el->list[$i]->attributes(); if ($attributes['name'] === 'kill') { unset($el->list[$i]); } } print $el; ?>
-
[SOLVED] Changing and Deleting Entries in a MySQL Database
ignace replied to Grizzly13's topic in PHP Coding Help
Ofcourse this does imply that your php code will be responsible for user status (and not the db (and thus statusses will be not manageable) but as you used a number and directly assumed a status i'm pretty sure you weren't using a table to manage the user statusses anyway) -
[SOLVED] Changing and Deleting Entries in a MySQL Database
ignace replied to Grizzly13's topic in PHP Coding Help
Damn, a script that works. I can only think of how you now would feel Javascript and Java are 2 different things. JavaScript is a scripting-language which means it's statements are being interpreted by the browser (which means that the browser keeps an association table for each statement and just swaps it with micro-code) while Java code is being translated (using a compiler) into executable code (1's and 0's). This may be not entirely correct and I'm sure someone with a more proper knowledge can tell you the ins and outs. Now to answer your question: Yes you can use just plain php to perform these actions. I do recommend using something else then numbers to indicate status. You may want to start looking at design patterns, active record more precise which would allow you to do somthing like: <?php class User { const STATE_PENDING = 'pending'; const STATE_ACTIVATED = 'activated'; const STATE_FROZEN = 'frozen'; //depending if the account remains in the system or not STATE_DELETED may be added protected $_data = array(); public function isPending() { return $_data['state'] === self::STATE_PENDING; } ...you get the idea } ?> You can then use this as: <?php while ($row = mysql_fetch_assoc($result)) { $users[] = new User($row); } foreach ($users as $user) { if ($user->isPending()) { ..logic.. } } ?> The same applies for login: <?php // login query if (mysql_num_rows($result) == 1) { $row = mysql_fetch_assoc($result); $user = new User($row); if ($user->isPending()) { //sorry, wait for your account to be activated or activate your account (if using e-mail activation) } if ($user->isFrozen()) { //sorry, your account has been frozen } } ?> -
Contain website registration to a single email domain
ignace replied to miesnerd's topic in PHP Coding Help
1. As sharagold mentioned, I dont know where to impliment the one line Implement this line where your validation starts and should come as: if (strstr($email, '@school.edu')) { // valid } 2. I also dont know how to make the script auto-mail login info that needs to be validated. You usually send this kind of information after they registered at your website. $mailBody = ""; $username = $_POST['username']; $password = $_POST['password']; $mailBody .= "Username: $username\n"; $mailBody .= "Password: $password\n"; mail($to, $subject, $mailBody, $headers); 3. I dont know how to make it so that a certain page cannot be accessed unless a person is logged in. You mean that only one user (John Doe) can access a specific page? Or a group (Authenticated Users) of people? (Ie: couldnt they just get the url and use that to access the page without logging in every time?) No they can't because if i would know your url i could be able to see your page and your system had nothing to defend itself to keep me away from that page. -
Are you using this to create an agenda?
-
This code was missing colspan="3" $contentOutput .= "<tr><td colspan=\"3\">".$cat['title']."</td></tr>"; To add a break-line type of thing you'll need to add an empty row as <br> won't do much in a table context. This will create a "break" before every category. $contentOutput .= "<tr><td colspan=\"3\"> </td></tr><tr><td colspan=\"3\">".$cat['title']."</td></tr>";
-
<?php print getmypid(); ?>
-
php solution to refresh html table display of MySQL data
ignace replied to webguync's topic in PHP Coding Help
This should work: <button onclick="window.location.href=window.location.href">Do Not Press</button> As would this: <?php header('Location: '. $_SERVER['REQUEST_URI']); ?> -
You always talk like this to eachother? It's pretty funny though
-
At first I couldn't see the added value of a framework (to much you don't need, mostly untested, thousand pages of configuration, ..). Then someone said that I am always using a framework wether or not it is visually there. Then i started using Zend first as a test project and afterwards i started using it in production environments and now I am among the believers of frameworks and Zend and it's methods, as my posts in this thread clearly states.
-
http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_substr
-
I never said it was bad nor did i say it wouldn't work but I'm going to leave it with this. Like I already said you are a respected member of this community and i respect your opinion on things and you are right maybe i'm making a to big fuss about it and I now know the pros and cons of using both techniques (I am just someone who doesn't easily do A just because someone said A is better). Anyway thanks for clearing this out!
-
As long as this server has php installed you can run everything (and yes this includes your templating engine) that can run with/on php
-
Unique urls for individual posts in mysql database
ignace replied to mitman's topic in PHP Coding Help
INSERT INTO content VALUES (1, 'http://localhost/index.php?p=ABOUTS'); INSERT INTO content VALUES (2, 'http://localhost/index.php?p=CONTACTS'); SELECT * FROM content WHERE href = 'http://localhost/index.php?p=ABOUTS' You are probably trying to create a content management system where you work with 'pages', right? -
<html> <body> <form name="form" action="index.php" method="post"> <input name="x" type="text"> <input name="y" type="submit" value="oK"> </form> <?php if (!empty($_POST)) { if (isset($_POST['x'])) { print $_POST['x']; } if (isset($_POST['y'])) { print $_POST['y']; } } else { print 'tralala'; } ?> </body> </html>
-
$body .= $string1 . $string2 . $string3;
-
strip_tags()
-
I am not setting anything client-side. For example: <input type="hidden" name="subscription" value="unsubscribe"> <input type="checkbox" name="subscription" value="subscribe"> Then i perform validation and this only allows 2 values: subscribe or unsubscribe (anything else is considered incorrect and if it is a required field it will keep displaying you this form over and over again until it gets unsubscribe or subscribe and if it is not a required field then it would default to its internal state wether checked or unchecked (server-side)). While you would allow: "", "0", 0, NULL, FALSE (these would all pass as unsubscribe and all others as subscribe). Please enlighten me why this is better? I don't want to be an asshole here or anything I just like a good discussion and I just want to know all angles (we are here to learn and I am no different). And what amazes me even more is why if this is so wrong it is used in the Zend framework? <?php class TestForm extends Zend_Form { public function init() { $e = $this->createElement('Checkbox', 'subscription'); $e->setCheckedValue('subscribe'); $e->setUncheckedValue('unsubscribe'); $this->addElement($e); } } Generates the hidden field + the checkbox field. P.S. Sorry monkuar for screwing up your thread here
-
For more information: http://framework.zend.com/manual/en/zend.session.global_session_management.html#zend.session.global_session_management.rememberme
-
Make sure your session hasn't already started: if (!Zend_Session::isStarted()) { Zend_Session::rememberMe(86400); }