Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Closed Thread
Old 12-29-2010, 07:31 AM $_Post
Chris_123K's Avatar
Super Talker

Posts: 128
Name: Chris Kummelstedt
Trades: 0
Hi Forum,

---------------------------------------------------------------------------------------
Quick Question
-------------------------------------------------------------------------------------
How can I replace sa1 with the value of a $_Post in the following:

Code:
<td class='td1'>" .  round ($row['field_sa1_value'] * $exchange_rate, -1) . " " . $currency_to . "</td>
I am new and honestly pretty rubbish, so I can't get it to work
---------------------------------------------------------------------------------------
Question Background
---------------------------------------------------------------------------------------
I am trying to make a comparison website using a simple form and some SQL, but as I am very much a PHP newbie, I have now run aground and I can not find info online that illuminate what I am doing wrong (I have been scratching my head for about 4 hours now).

Basically, I can't find a way get the value of the form into the generated data table.

FORM:
Code:
<form action="?" method="post">
<select name="duration">
<option value="1">1 Month</option>
<option value="2">2 Months</option>
<option value="3">3 Months</option>
<option value="4">4 Months</option>
<option value="5">5 Months</option>
<option value="6">6 Months</option>
<option value="7">7 Months</option>
<option value="8">8 Months</option>
<option value="9">9 Months</option>
<option value="10">10 Months</option>
<option value="11">11 Months</option>
<option value="12">1 Year</option>


</select>
<select name="accommodation">
<option value="sa">Shared Apartment</option>
<option value="pa">Private Apartment</option>
<option value="ha">Home Stay</option>
<option value="na">No Accommodation</option>
</select>
<input type="submit" />
</form>
TABLE:
Code:
<table class='table_schools' border='hidden' margin='0' padding='0'>
<tr class='tr1'>
<td class='td1'>School</td>
<td class='td2'>Established</td>
<td class='td3'>Class Size</td>
<td class='td1'>Monthly Cost </td>
<td class='td1'>Min age</td>
</tr>
<?php
mysql_connect($server,$user,$password);
@mysql_select_db($database) or die("Sorry, unable to select database");
$result = mysql_query("SELECT * FROM drup_content_type_school ORDER BY field_schoolname_value");
$i=0;
 while($row = mysql_fetch_array($result))
  {
if ($i % 2)
   $class= "tr3";
else 
  $class= "tr2";
  echo "<tr class='" . $class . "'>
<td class='td1'><a href='http://compare-chineselanguageschools.com/content/output-school?school=" . $row['field_schoolname_value'] . "'>" . $row['field_schoolname_value'] . "</a></td>
<td class='td2'>" . $row['field_est_value'] . "</td>
<td class='td3'>" . $row['field_max_class_size_value'] . "</td>
<td class='td1'>" .  round ($row['field_sa1_value'] * $exchange_rate, -1) . " " . $currency_to . "</td>
<td class='td1'>" . $row['field_max_class_size_value'] . "</td>
</tr>
";
$i++;
}

  ?>
</table>
The bold "sa1" represents shared accommodation and 1 month in the form, how do I use $_Post inside the table thus getting it to say e.g. sa2?

So thankful,

Christopher
Chris_123K is offline
View Public Profile
 
 
Register now for full access!
Old 12-29-2010, 08:05 AM Re: $_Post
Experienced Talker

Posts: 46
Name: Maneet Puri
Trades: 0
Hi,

Try this: -

$fld_name = "field_" . $_POST['sa1'] . "_value";

and for using it you can use $row[$fld_name]

Hope this helps.

Cheers,

~Maneet
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
maneetpuri is offline
View Public Profile
 
Old 12-29-2010, 12:12 PM Re: $_Post
Chris_123K's Avatar
Super Talker

Posts: 128
Name: Chris Kummelstedt
Trades: 0
Quote:
Originally Posted by maneetpuri View Post
Hi,

Try this: -

$fld_name = "field_" . $_POST['sa1'] . "_value";

and for using it you can use $row[$fld_name]

Hope this helps.

Cheers,

~Maneet
SIR!

Thank you!

Worked like a charm. Really tremendously obliged.
Chris_123K is offline
View Public Profile
 
Closed Thread     « Reply to $_Post
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.28740 seconds with 12 queries