-
Posts
1,437 -
Joined
-
Last visited
Never
Posts posted by papaface
-
-
<?php $string = '<span style="font-size:10px; font-weight:bold;">Hello <em>World</em></span>'; echo strip_tags($string); ?>
-
Yeah I totally agree, but that wasn't my point. It is valid PHP code.That will get so irreparably sloppy in a short amount of time that it's easier to just fix the underlying issue.
OPs question:
Can you do an if else statment in an echo? Pretty much i want to do and if else statment to hide empty fields.The answer. Yes:
Conditional statements in echo's are quite easily possible:
<?php $num = 1; echo "\$num has a value of 10? " . ($num == '10' ? 'True' : 'False'); ?>
Apply to your code as necessary.
Question answered, mark as solved.
-
Conditional statements in echo's are quite easily possible:
<?php $num = 1; echo "\$num has a value of 10? " . ($num == '10' ? 'True' : 'False'); ?>
Apply to your code as necessary.
-
-
That was going to be my suggestion too
Can you tell me though, with the case what if you have a multi line block of code to run in each case do you just put it in parenthesis with the break inside it? I can't remember and haven't done it in a while (but I'm going to switch most of my site over the the switch, case, default method of comparisons soon).
Would be:
<?php switch($positoin){ case 1: $style = 'A lot of code'; echo 'A lot of code'; break; case 1: $style = 'A lot of code'; echo 'A lot of code'; break; case 1: $style = 'A lot of code'; echo 'A lot of code'; break; case 1: $style = 'A lot of code'; echo 'A lot of code'; break; } ?>
No { } needed
-
http://www.google.co.uk/search?q=html+to+bbcode&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a any reason why you couldn't just google what you want?
-
It gives the image a different name without actually renaming it, which prompts the browser to reload the image as it see's it as a different image.Found the answer. It's simple, but makes no sense:
<img src="yourimage.jpg?<?php echo time();?>" border="0" alt="" />
I've seen images listed like this before. Now I know what the ?var is for.
-
I am well aware of what you want. But its your grave.not really.
www.PhonePwners.com is my website (im working on it)
and want it where I can click any of the nav links
and have them like index?=1 - 5
instead of contact.php, call.php, sound.php, ect.
i dont really care about search eng. and stuff..
-
The way you are trying to do it is bad for search engines, also it not very user friendly. In order for me to quickly go to your page I have to know the internal number reference. Whereas, tutorials are at tutorials.php. Catch my drift?<tr>
<td class="box" style="border-bottom: 1px solid rgb(52, 73, 102);" width="167">
<a href="contact.php">Contact</a></td>
</tr>
That is what I have so far, how can i change it where like contact is index.php?=1
-
Try:
<HTML> <TITLE> RJSWS - mafia Wars </TITLE> <body> <font face=verdana size=2> <?php foreach ($_POST as $k => $v) { if (!isset($_POST[$k]) || trim($_POST[$k]) == "" || $_POST[$k] == "" ) { $_POST[$k] = 0; } } $a_lot_price = $_POST['a_lot_price'] ; $a_lot_base = 0 ; $a_lot_rent = 100 ; $a_lot_sum_a = $a_lot_price+$a_lot_base ; $a_lot_sum = $a_lot_sum_a/$a_lot_rent ; $a_lot_sum_for = number_format($a_lot_sum, 0); $c_lot_price = $_POST['c_lot_price'] ; $c_lot_base = 0 ; $c_lot_rent = 300 ; $c_lot_sum_a = $c_lot_price+$c_lot_base ; $c_lot_sum = $c_lot_sum_a/$c_lot_rent ; $c_lot_sum_for = number_format($c_lot_sum, 0); $p_lot_price = $_POST['p_lot_price'] ; $p_lot_base = 0 ; $p_lot_rent = 2000 ; $p_lot_sum_a = $p_lot_price+$p_lot_base ; $p_lot_sum = $p_lot_sum_a/$p_lot_rent ; $p_lot_sum_for = number_format($p_lot_sum, 0); $b_lot_price = $_POST['b_lot_price'] ; $b_lot_base = 0 ; $b_lot_rent = 8000 ; $b_lot_sum_a = $b_lot_price+$b_lot_base ; $b_lot_sum = $b_lot_sum_a/$b_lot_rent ; $b_lot_sum_for = number_format($b_lot_sum, 0); $r_prop_price = $_POST['r_prop_price'] ; $r_prop_base = 5000 ; $r_prop_rent = 300 ; $r_prop_sum_a = $r_prop_price+$r_prop_base ; $r_prop_sum = $r_prop_sum_a/$r_prop_rent ; ?> <head> <title></title> <style type="text/css"> tr.a { background-color: Aqua; } tr.a1 { background-color: lime; } td.b { color: black; width: 200px; } .lot_value { color: red; text-align: center; } td.c_title { color: black; width: 150px; text-align: center; } tr.blank { background-color: black; height: 3px; } </style> </head> <body> <form method=post action=mafia_prices.php> <table> <tr class="a"> <td class="c_title"></td> <td class="c_title">Price Per Lot</td> </tr> <tr class="a"> <td class="b">Abandoned Lot</td> <td class="c"><input type="text" class="lot_value" name=a_lot_price size="20" value="<? echo $a_lot_price; ?>"></td> <td class="d"><input type="text" class="lot_value" name=a_lot_per size="20" value="$<? echo $a_lot_sum_for; ?>"></td> </tr> <tr class="a1"> <td class="b">Commercial Block</td> <td class="c"><input type="text" class="lot_value" name=c_lot_price size="20" value="<? echo $c_lot_price; ?>"></td> <td class="d"><input type="text" class="lot_value" name=c_lot_per size="20" value="$<? echo $c_lot_sum_for; ?>"></td> </tr> <tr class="a"> <td class="b">Prime Downtown Lot</td> <td class="c"><input type="text" class="lot_value" name=p_lot_price size="20" value="<? echo $p_lot_price; ?>"></td> <td class="d"><input type="text" class="lot_value" name=p_lot_per size="20" value="$<? echo $p_lot_sum_for; ?>"></td> </tr> <tr class="a1"> <td class="b">Beachfront Property</td> <td class="c"><input type="text" class="lot_value" name=b_lot_price size="20" value="<? echo $b_lot_price; ?>"></td> <td class="d"><input type="text" class="lot_value" name=b_lot_per size="20" value="$<? echo $b_lot_sum_for; ?>"></td> </tr> <tr class="blank"> <td></td> <td></td> </tr> <tr class="a"> <td class="b">Rent House</td> <td class="c"><input type="text" class="lot_value" name="r_prop_price" size="20" value="<?php echo $r_prop_price; ?>"></td> <td class="d"><input type="text" class="lot_value" name="r_prop_per" size="20" value="$<?php echo $r_prop_sum_for; ?>"></td> </tr> <tr class="a1"> <td class="b">Italian Restaurant</td> <td class="c"><input type="text" class="lot_value" name="i_prop" size="20" value=""></td> </tr> <tr class="a"> <td class="b">Apartment Complex</td> <td class="c"><input type="text" class="lot_value" name="a_prop" size="20" value=""></td> </tr> <tr class="a1"> <td class="b">Valu-Mart</td> <td class="c"><input type="text" class="lot_value" name="v_prop" size="20" value=""></td> </tr> <tr class="a"> <td class="b">Office Building</td> <td class="c"><input type="text" class="lot_value" name="o_prop" size="20" value=""></td> </tr> <tr class="a1"> <td class="b">5-Star Hotel</td> <td class="c"><input type="text" class="lot_value" name="5_prop" size="20" value=""></td> </tr> <tr class="a"> <td class="b">Mega Casino</td> <td class="c"><input type="text" class="lot_value" name="m_prop" size="20" value=""></td> </tr> </table> <input type=submit value="Submit" > </form> </body> </html> </font> </body> </HTML>
-
change to:
<td class="c"><input type="text" class="lot_value" name="r_prop_price" size="20" value="<?php echo $r_prop_price; ?>"></td> <td class="d"><input type="text" class="lot_value" name="r_prop_per" size="20" value="$<?php echo $r_prop_sum_for; ?>"></td>
and try:
foreach ($_POST as $k => $v) { if ($v == "") { $_POST[$k] = 0; } } $r_prop_price = $_POST['r_prop_price'] ; $r_prop_base = 5000 ; $r_prop_rent = 300 ; $r_prop_sum_a = $r_prop_price+$r_prop_base ; $r_prop_sum = $r_prop_sum_a/$r_prop_rent ;
-
What are you putting in the form fields when you submit?
-
Try:
if ($_POST) { foreach ($_POST as $k => $v) { if ($v == "") { $_POST[$k] = 0; } } $r_prop_price = $_POST['r_prop_price'] ; $r_prop_base = 5000 ; $r_prop_rent = 300 ; $r_prop_sum_a = $r_prop_price+$r_prop_base ; $r_prop_sum = $r_prop_sum_a/$r_prop_rent ; }
-
if ($_POST) { foreach ($_POST as $k => $v) { if (trim($v) == "") { $_POST[$k] = 0; } } $r_prop_price = $_POST['r_prop_price'] ; $r_prop_base = 5000 ; $r_prop_rent = 300 ; $r_prop_sum_a = $r_prop_price+$r_prop_base ; $r_prop_sum = $r_prop_sum_a/$r_prop_rent ; }
-
Thank you everyone fo your help with this.
I decided to use
if ($number_field == "") {
$number_field = $blank ;
$number_field_plus = $blank ; }
This makes both fields $0
Thanks again everyone
-Rob
Not very good use of code tbh as $number_field may have a value, but $number_field_plus may not and will therefore remain blank. My code is the best.
-
Can you tell us the directory structure please. i.e. where is your index file in relation to the pages folder.
-
Easiest thing to do is:
foreach ($_POST as $k => $v) { if (trim($v) == "") { $_POST[$k] = 0; } }
Place it at the top of your code. It will automatically replace any blank form fields with a 0 value.
-
Not sure what is wrong but:
$filename="pages/" . $_GET['p'] . ".htm"; if (file_exists($filename)){ include("pages/" . $_GET['p'] . ".htm");
Is pointless excess code. Should be:
$filename="pages/" . $_GET['p'] . ".htm"; if (file_exists($filename)){ include($filename);
-
I'm not entirely sure what you're wanting to do.
Are you trying to prevent SQL injections?
If so, then you dont need to filter out words, all you have to do it have a good level of checking.
Why would someone use javascript?
All you have to do is use mysql_real_escape_string($str)
-
Something like:
<?php $badwords = array("f***","b******"); $string = "hello f*** you b******"; $parts = explode(" ",$string); foreach($parts as $k => $v) { if(in_array($v,$badwords)) { echo "bad word detected: " . $v . "<br />"; } } ?>
But there are much more complex examples out there.
-
Can you provide code as to how your POST vars are currently processed.
-
Yeah you can, in actual fact "id" is the correct way to do it in valid HTML I believe, but PHP only accepts the elements with the name attribute (as far as I am aware anyway).You can have both:
<input id="date1" name="date1"
-
Use code tags.
-
<input id="date1"
Should be:
<input name="date1"
Killing spaces in strings
in PHP Coding Help
Posted