Try this...
function getSpeed($val) {
if($val != 'undefined') {
switch ($val){
case "1":
$post_tptest = "0-250kbps";
break;
case "2":
$post_tptest = "250-300kbps";
break;
case "3":
$post_tptest = "300-400kbps";
break;
case "4":
$post_tptest = "400-600kbps";
break;
case "5":
$post_tptest = "600kbps-3.8mbps";
break;
default:
$post_tptest = "Speed Undetected"; // or "0-250kbps"
break;
}
} else {
return("Error, no speed value set");
}
}
}
$post_speed = getSpeed($post_tptest);
$posts_sql = "SELECT
posts.post_store,
posts.post_content,
posts.post_speed,
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 ";
...
Best,
Karl
On Jun 23, 2011, at 1:18 PM, Chris Stinemetz wrote:
So far I am good on creating the form and submitting it to mysql
database and calling the submitting value from a different script.
My question is: How can I make it so when a user selects radio option
value "1" it will then be displayed as 0-250kbps when I call it the
value in the bottom script?
forgive my indention. Gmail messes it up.
#### My Form ####
echo '<form method="post" action="">
Store name: <input type="text" name="store_subject" /><br /
><br />
Market:';
echo '<select name="store_mar">';
while($row = mysql_fetch_assoc($result))
{
echo '<option value="' . $row['mar_id'] . '">' .
$row['mar_name'] . '</option>';
}
echo '</select><br /><br />';
echo 'Broadband speed test results: <br /><br />
0-250kbps<input type="radio" name="post_tptest" value="1" />|
250-300kbps<input type="radio" name="post_tptest" value="2" />|
300-400kbps<input type="radio" name="post_tptest" value="3" />|
400-600kbps<input type="radio" name="post_tptest" value="4" />|
600kbps-3.8mbps<input type="radio" name="post_tptest" value="5"
/><br /><br />
Store visit details: <br /><br />
<textarea name="post_content" /></textarea><br /><br />
<input type="submit" value="Add a store visit" />
</form>';
#### My display script ####
$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 ";
$posts_result = mysql_query($posts_sql);
if(!$posts_result)
{
echo '<tr><td>The posts could not be displayed, please try again
later.</tr></td></table>';
}
else
{
while($posts_row = mysql_fetch_assoc($posts_result))
{
echo '<tr class="topic-post">
<td class="user-post">' . $posts_row['first_name'] . ' ' .
$posts_row['last_name'] . '<br/>' . date('m-d-Y h:iA',
strtotime($posts_row['post_date'])) . '</td>
<td class="post-content">' . $posts_row['post_tptest'] .
'<br/>' . htmlentities(stripslashes($posts_row['post_content'])) .
'</td>
</tr>';
}
}
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Karl DeSaulniers
Design Drumm
http://designdrumm.com