Saturday, 7 September 2013

use another column to save data mysql

use another column to save data mysql

I have a simple mysql table that has:
ID userID type price
The table kind of looks like this: (the userID comes from another table)
ID type price
1 Area 8.95
2 Areas 17.9
3 Areas 26.85
4 Areas 35.8
5 Areas 39.95
I am using the ID for the value of the type in a select drop-down:price
<select name="rooms" id="Areas">
<option value="" selected="selected">0</option>
@foreach ($room as $rooms)
<option data-price="{{ $rooms->price }}" value='{{
$rooms->ID }}'>{{ $rooms->ID }}</option>
@endforeach
</select>
The reason why I have it like this is due to my js(it updates pricing
information based on selection)
When the information is saved to the database it's pulling the value which
in the case is the ID.
Format of table being saved to
ID USERID service price
149 1 1
150 1 1
151 1 1
152 1 1
I would like it to pull the column price and type over to price and
service so it will look like:
ID USERID service price
149 1 Area 8.95
150 1 Areas 17.9
151 1 Areas 26.85
152 1 Areas 35.8
How can this be accomplished? using JOINs?

No comments:

Post a Comment