Jump to content

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.
}

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.