php/mysql - retrieve mysql result and place in parameter
Moderator: General Moderators
php/mysql - retrieve mysql result and place in parameter
Hi,
i have a sql select query:
select value from valuetable where valueid = '34';
what i want to do is, get the value from the result and pass it into a parameter, so i can use it to insert into another table
is this possible?
i know you retrieve the last entered id from a table using: mysqli_insert_id function
just wondering if there is a general solution for getting any data.
thanks for your time.
i have a sql select query:
select value from valuetable where valueid = '34';
what i want to do is, get the value from the result and pass it into a parameter, so i can use it to insert into another table
is this possible?
i know you retrieve the last entered id from a table using: mysqli_insert_id function
just wondering if there is a general solution for getting any data.
thanks for your time.
php/mysql - retrieve mysql result and place in parameter
thanks for the reply
i've got mysql5 installed which supports sub-queries. but ive not tried it yet.
what about if i do:
insert value1 into table2
(select value1 from table1 where valueid=31)
value1 will be stored as an id in the table table2, so i can retrieve the data using mysqli_insert_id.
long way round, what you think?
i've got mysql5 installed which supports sub-queries. but ive not tried it yet.
what about if i do:
insert value1 into table2
(select value1 from table1 where valueid=31)
value1 will be stored as an id in the table table2, so i can retrieve the data using mysqli_insert_id.
long way round, what you think?
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
thanks for that.
i forgot that the function doesnt retrieve any old data type.
is there any solution for retrieving single data items from a query of type: dates, varchar and int.
mysqli_fetch_field - can select primary key - but it puts it into an object.. is there any way of getting of extracting this object?
i forgot that the function doesnt retrieve any old data type.
is there any solution for retrieving single data items from a query of type: dates, varchar and int.
mysqli_fetch_field - can select primary key - but it puts it into an object.. is there any way of getting of extracting this object?
SOLUTION FOUND.
what i did was pass the result into mysqli_fetch_array
and used while look to populate a list for it,
then i passed this list (hopefully query all produces one result) into an array - and then i can pass it globally around all my other pages.
$sql = "select value from t1 where tname='ananth' and tolgroup='first';";
$rs=mysqli_query($conn,$sql);
while($row= mysqli_fetch_array($rs)){
$list .= $row["value"] ;
}
$qt2 = $list;
echo "$qt2";
thanks for all your suggestions.
what i did was pass the result into mysqli_fetch_array
and used while look to populate a list for it,
then i passed this list (hopefully query all produces one result) into an array - and then i can pass it globally around all my other pages.
$sql = "select value from t1 where tname='ananth' and tolgroup='first';";
$rs=mysqli_query($conn,$sql);
while($row= mysqli_fetch_array($rs)){
$list .= $row["value"] ;
}
$qt2 = $list;
echo "$qt2";
thanks for all your suggestions.