premiso
Members-
Posts
6,951 -
Joined
-
Last visited
-
Days Won
2
Everything posted by premiso
-
Did you fail to notice that it has nothing to do with PHP? This is more of a html/javascript issue. PHP is done server side, html/javascript is client side which is what you want.
-
I did a quick mock up of your code. <?php mysql_connect("localhost", "root", ""); mysql_selectdb("test"); if (isset($_POST['submit'])) { $value = $_POST['Mortgage']; if (is_numeric($value)) { $value = (double)$value; }else { $value = 0; } mysql_query("UPDATE mortgage SET amount = " . $value . " WHERE name = 'Mortgage'"); } $output = '<form method="post" action="test.php">'; $result = mysql_query("SELECT mid, amount, name FROM mortgage"); while ($row = mysql_fetch_array($result)) { $output .= '<input type="text" name="' . $row['name'] . '" value="' . $row['amount'] . '" />'; } $output .= '<input type="submit" name="submit" value="Process" /> </form>'; echo $output; ?> This works exactly as expected. Updated the DB to the correct result. Where you are going wrong, I have no clue. But the above worked great for me. Updated the DB with the correct value each time I ran it. Why yours does not work, either your logic is flawed somewhere, which it sets it to be 0.00, or the value is not being modified via the form and it just keeps posting 0.00. You have only posted part of your code, maybe posting more (or even the full thing) will help diagnose the problem.
-
[SOLVED] Multiple Array with 5 Values in each...
premiso replied to gary_rip's topic in PHP Coding Help
$cnt = count($match1); for ($i=0; $i < $cnt; $i++) { echo '<tr><td>'.$match4[$i].'</td>'; echo '<td><a href="http://www.awebsite.com/'.$match3[$i].'" target="_blank">'.$match2[$i].'</a></td></tr>'; } By outputting the first row, I will take it as it is working, it just needs to separate the data into rows. That should, hopefully work. You are giving me some vague feedback, by the way can you post how your arrays are populated/setup? If the above does not work that is, it would help diagnosing the issue. -
What data type is your mysql column set to for amount?
-
[SOLVED] Multiple Array with 5 Values in each...
premiso replied to gary_rip's topic in PHP Coding Help
You may need it to be $match1, given your initial post I thought that there was also a $match, but that is probably a wrong assumption. Change it to $match1 and see if that works. -
Using this form, are you changing that value from 0.00 to something else. From the sounds of it, given the data in the DB it is doing it right. I am not sure what you have/havn't tried. It should work though given what you have shown me.
-
[SOLVED] Multiple Array with 5 Values in each...
premiso replied to gary_rip's topic in PHP Coding Help
for ($i=0; $i < $cnt; $i++) { Sorry, meant for that to be $cnt -
All the print statements should be in menu.php, the include will execute the code in the menu.php file like the code was on that page to begin with. Give it a try and mess around with it to see how it works.
-
Why does array_pop not work for you? Can you post some of the code you are working with, cause what you are saying is basically that this element may not be the last element, hence why array_pop does not work and it could be an associative array, hence the count($array) would not work to determine the last element. How exactly is this array setup? You can use a foreach and loop through storing the $key foreach element then at the end just unset that key. foreach ($array as $key => $val) { $unset = $key; } unset($array[$unset]);
-
[SOLVED] Displaying Text File. - Entries Missing. !
premiso replied to TomT's topic in PHP Coding Help
<?php $addresses = array('user1', 'user2', 'user3'); $inArray = false; foreach ($addresses as $address) { if (stristr($user, $address) !== false) { $inArray = true; break; } } if ($inArray) echo "<td align='left'><font face='Verdana' size='2'><b>" . htmlentities($user) . "</b></td></tr>"; else echo "<td align='left'><font face='Verdana' size='2'>" . htmlentities($user) . "</td></tr>"; ?> -
No, the code generated from that script, not the script code. View the source of the page with the form on it and paste the generated HTML here. (But if you checked the values and that is not the issue then do not worry about it). If you are sure the form value is being populated to $budg_mortgage, you may have to cast this to be a double variable: $budg_mortgage = (double) $_POST['Mortgage']; I am also not sure if surrounding that value with single quotes in the query is the right way to go, you may try leaving the single quotes off since this is a numerical value.
-
If you are just sending users texts, and do not care to get/receive a text from them then this is easily done with mail You just have to find a list of service providers and how they format their text messages addresses. Like for att it is your10digitnumber@txt.att.net That can be easily found, then you just send an email to that and they will get the text.
-
[SOLVED] Displaying Text File. - Entries Missing. !
premiso replied to TomT's topic in PHP Coding Help
Eh I am a moron. Sorry about that, my mind is completely podged today. if (stristr($user, 'user@domain1.com') !== false || stristr($user, 'user@domain2.com')) { echo "<td align='left'><font face='Verdana' size='2'><b>" . htmlentities($user) . "</b></td></tr>"; else echo "<td align='left'><font face='Verdana' size='2'>" . htmlentities($user) . "</td></tr>"; You can use the array, you would just have to loop through it. It depends on how many exemptions you want to add, if it would be worth doing. If it is just these 2, it would not be worth it 4+ I would say it would. -
You need to post the form your code generated. My but is that "Mortgage" is either not on the form, or it is a different case.
-
include would be what you are after
-
[SOLVED] Multiple Array with 5 Values in each...
premiso replied to gary_rip's topic in PHP Coding Help
$cnt = count($match); for ($i=0; $i < $match; $i++) { echo '<td>'.$match4[$i].'</td>'; echo '<td><a href="http://www.awebsite.com/'.$match3[$i].'" target="_blank">'.$match2[$i].'</a></td>'; } Damnit, sorry for the double post. I thought I clicked the edit button =\ -
[SOLVED] Multiple Array with 5 Values in each...
premiso replied to gary_rip's topic in PHP Coding Help
You need to loop through the results, for an array I would suggest foreach or even a for loop. Right now you are just manually writing them. -
[SOLVED] Displaying Text File. - Entries Missing. !
premiso replied to TomT's topic in PHP Coding Help
Try removing the !== false. Both the usernames should appear, just the ones specified should be red colored. -
[SOLVED] Insert problems ..going blind looking for problem
premiso replied to CodeMama's topic in PHP Coding Help
Is $adstart a valid timestamp? -
Echo out $query and post it here. Chances are you are either still using ` (back ticks) instead of ' (single quotes) or your data has invalid characters, not being escaped properly.
-
serialize it is a function. $array = array("item" => 1, 1 => "item"); $urlGET = rawurlencode(serialize($array)); header("Location: page.php?array={$urlGET}"); However, I would prefer to use POST or even sessions (if the page is on your server) to do this. To separate each item to avoid serialization: (The below assumes an associative array, with the index being the "variable" name.) $getData = array(); foreach ($array as $key => $val) { $getData[] = "{$key}={$val}"; } $urlQueryString = implode("&", $getData); header("Location: page.php?{$urlQueryString}");
-
[SOLVED] Displaying Text File. - Entries Missing. !
premiso replied to TomT's topic in PHP Coding Help
in_array $adresses = array('address1@test.com', 'address2@test.com'); if (in_array($user, $addresses) !== false) echo "<td align='left'><font face='Verdana' size='2'><b>" . htmlentities($user) . "</b></td></tr>"; else echo "<td align='left'><font face='Verdana' size='2'>" . htmlentities($user) . "</td></tr>"; -
Yea, it may be a good idea to try doing that...
-
[SOLVED] Displaying Text File. - Entries Missing. !
premiso replied to TomT's topic in PHP Coding Help
stristr if (stristr($user, "email@here.com") !== false) echo "<td align='left'><font face='Verdana' size='2'><b>" . htmlentities($user) . "</b></td></tr>"; else echo "<td align='left'><font face='Verdana' size='2'>" . htmlentities($user) . "</td></tr>"; -
Questions one, yes <? can be turned off. It is better to use <?php Question two, include_once means it will only include that file once, even if called 5 times. This prevents some errors etc. Question three inc.php is just informing people that it is an include. It is not it's own extension, it just makes it easier in some cases to find out files that are included.