Re: Re: radio form submission

From: Date: Fri, 24 Jun 2011 08:18:27 +0000
Subject: Re: Re: radio form submission
References: 1 2  Groups: php.db 
Request: Send a blank email to php-db+get-47880@lists.php.net to get a copy of this message
Hi Chris, Here is the corrected code. Yes, call the function before the SQL SELECT like so. You may have to work with it a bit. This was just off the top of the head. But now that I look at it, I think Jim may be right. What's the purpose of the inputs having 1, 2, 3, etc and not the 0-250kbps, etc? If there is no purpose, I would make the values of the inputs the values you want to store in your database. Muuch easier.. Otherwise try this. You should be able to copy an paste. //your form code... function getSpeed($val) { if($val != 'undefined') { switch ($val) { case "1": $post_speed = "0-250kbps"; break; case "2": $post_speed = "250-300kbps"; break; case "3": $post_speed = "300-400kbps"; break; case "4": $post_speed = "400-600kbps"; break; case "5": $post_speed = "600kbps-3.8mbps"; break; default: $post_speed = "Speed Undetected"; // or "0-250kbps" break; } return $post_speed; } else { die("Error, no speed value set"); } } //This part may need to be worked. Basically you want; posts.post_tptest to equal the result of getSpeed($_POST['post_tptest']). //however you can get it there in your code. Or just try this, see if this works and go from there. $_POST['post_tptest'] = getSpeed($_POST['post_tptest']); $posts_sql = "SELECT posts.post_store, posts.post_content, posts.post_tptest, posts.post_date, posts.post_by, users.user_id, users.user_name, users.first_name, users.last_name FROM posts LEFT JOIN users ON posts.post_by = users.user_id WHERE posts.post_store = " . mysql_real_escape_string($_GET['id']) . " ORDER BY posts.post_date DESC "; //... rest of your code HTH, GL, Best, Karl On Jun 23, 2011, at 3:17 PM, Jim Giner wrote:
If you put the "0-250kbps" as the value= of your html <input> tag, php would give you that when you did this: $rb_picked = $_POST['post_tptest']. No need for a switch or anything to re-interpret what the user picked. --PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Karl DeSaulniers Design Drumm http://designdrumm.com

« previous php.db (#47880) next »