Jump to content

How to get value too use for later on?


xwishmasterx

Recommended Posts

Am unalbe to figure out how to get a value from a database and use it later on. If I have a simple query:

 

$query2  ="SELECT team_id FROM vtp_members WHERE id=".$_GET['r']."  ";
$result2 = mysql_query($query2);

 

How can I "store" the value to use later one? can I do something like: $teamvalue = $result2? (there will only be one value /result)

Link to comment
https://forums.phpfreaks.com/topic/233719-how-to-get-value-too-use-for-later-on/
Share on other sites

I need to do and UPDATE right after and need that value in the WHERE clause. if I have this:

 

$query2  ="SELECT team_id FROM vtp_members WHERE id=".$_GET['r']."  ";
$result2 = mysql_query($query2);
$numrows2 = mysql_num_rows($result2);
if($numrows2 == '1')
{
  while($row = mysql_fetch_array($result2, MYSQL_ASSOC))
    {

 

what can I then use to  UPDATE xxxxx WHERE team_id ='$result2???' or how should that look?

You need something like:

 

$query2 = "SELECT team_id FROM vtp_members WHERE id = {$_GET['r']}";
$result2 = mysql_query($query2);
$numrows2 = mysql_num_rows($result2);

if ($numrows2 == 1)
{
   $row = mysql_fetch_assoc($result2);

   $query3 = "UPDATE xxxxx SET yyyyy = zzzzz WHERE team_id = {$row['team_id']}";

   // etc.
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.