Re: radio form submission

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Jun 23, 2011 at 2:49 PM, Daniel P. Brown
<daniel.brown@xxxxxxxxxxxx> wrote:
> On Thu, Jun 23, 2011 at 15:46, Chris Stinemetz <chrisstinemetz@xxxxxxxxx> wrote:
>>>
>>>    Use an if or a switch.  For example:
>>>
>>
>> I think your suggestions are exactly what I am looking for. I am not
>> sure exactly where to place it. Do I insert it after the query
>> statment?
>
>    During your while() loop.  This line here:
>
>        <td class="post-content">' . $posts_row['post_tptest'] .
>
>    If you convert it to a function as Karl suggested, you could do
> something like this:
>
>        <td class="post-content">' . getSpeed($posts_row['post_tptest']) .
>

I must be missing something. I am just getting a blank page. Your help
is greatly apprecieated.

The function and query statement is:

			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);
		
			//fetch the posts from the database
			$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 ";	
													

The call:

				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">' .
getSpeed($posts_row['post_tptest']) . '<br/>' .
htmlentities(stripslashes($posts_row['post_content'])) . '</td>
						  </tr>';
				}
			}


Thank you!

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux