Page 1 of 1

Send multiple ID's in a link?

Posted: Wed Sep 30, 2009 10:17 am
by synical21
Hey gurus, i got a little problem

When a user clicks a link they are taken to a new page "proofprocess.php" on this page is various queries what change user values, i got the id of that user by making the link "proofprocess.php?id=$userproof_id" and then useing $id.... so this page with the queries looks like this:

Code: Select all

<?
  
     
 $sql = "SELECT `proof`.*,
        `users`.*
   FROM `proof`,`users`
  WHERE users.id = $id
    AND proof.userproof_id = $id
    AND proof.job_id = ?????"; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< STUCK
 $result = mysql_query($sql)
     or die('Invalid query: ' . $sql . ' - Error is ' . mysql_error());
     
     $sql = "UPDATE `users`,`proof`
    SET clickstatus = 1
  WHERE proof.userproof_id = $id";
 $result = mysql_query($sql)
     or die('Invalid query: ' . $sql . ' - Error is ' . mysql_error());
  
 $sql = "UPDATE `users`,`proof`
    SET user_money = user_money + perperson
  WHERE users.id = $id";
 $result = mysql_query($sql)
     or die('Invalid query: ' . $sql . ' - Error is ' . mysql_error());
  
  
 $sql = "UPDATE `users`
    SET jobs_completed = jobs_completed + 1
  WHERE id = $id";
 $result = mysql_query($sql)
     or die('Invalid query: ' . $sql . ' - Error is ' . mysql_error());
 
 
?>
now i edited the code to show you where i am stuck, i need to select another ID not the users id but the jobs id, how can i get this information when the only id i have used has traveled in the link? The id of the job is on the page before it i just dont know how to send it to the process page. Any help is much apreicated

Re: Send multiple ID's in a link?

Posted: Wed Sep 30, 2009 10:40 am
by jackpf
Umm...put it in the query string as well?

Re: Send multiple ID's in a link?

Posted: Wed Sep 30, 2009 10:43 am
by synical21
But the job id is a variable to, $job_id wouldnt work

Re: Send multiple ID's in a link?

Posted: Wed Sep 30, 2009 10:58 am
by jackpf
You should be using $_GET. Don't use register globals.

Re: Send multiple ID's in a link?

Posted: Wed Sep 30, 2009 11:33 am
by synical21
It still will not work, how will the database know which job_id i need when the userid is on multiple job_ids

Re: Send multiple ID's in a link?

Posted: Wed Sep 30, 2009 12:44 pm
by mayanktalwar1988
first poast the script before the script that you posted here
first do that second thing
what is in the query is utilised like this
$id=$_GET[id];
only then you can use $id
which you used in where clause of your sql query

Re: Send multiple ID's in a link?

Posted: Wed Sep 30, 2009 12:50 pm
by synical21
Ok here is the page before

Code: Select all

<?php
 
# connect to the database
********
session_start(); 
 
if (isset($_SESSION['user_id'])) 
 
$my_id = trim (' ' . @$_GET['ID']) ; 
 
if ('' < $my_id) { $my_id= (int) $my_id; 
                           if ( 0 == $my_id) { $my_id= ''; 
                           } else $my_id = "$my_id"; 
                        }
if ('' == $my_id) {
 
} else { //we have a ID
 
 
   $query = "SELECT fulldata.* FROM fulldata WHERE fulldata.createuser_id ='$_SESSION[user_id]' and fulldata.job_id =$my_id";
   $result = mysql_query($query);
   $num_rows = mysql_num_rows($result);
   if ($num_rows != 1){die("You do not have permission to view this page!</p>");
   
   }else {
   $sql = "SELECT proof.* FROM proof WHERE proof.createuser_id2 ='$_SESSION[user_id]' and proof.job_id =$my_id and proof.clickstatus='0'";
   $result = mysql_query($sql);
   }
  
 
// START AN OUTPUT TABLE
echo "<table class='sample5'>";  
 
// IF NO RESULTS
if (!mysql_num_rows($result)) 
{
    echo "<tr><td colspan='8'><font color='green'><u>No workers have completed your task yet, check back very soon!</u></font></td></tr>";
 
}
else
{
 
// TITLE FOR COLUMNS
    echo "<tr><td align='center'><b>Job ID</b></td><td align='center'><b>Worker ID</b></th><td align='left'><b>Proof</b></th><td align='center'><b>Accept</b></th><td align='center'><b>Deny</b></th></tr>";
 
// ITERATE OVER THE RESULTS
    while ($line = mysql_fetch_assoc($result)) 
    {
//LOCAL VARIABLES    
        foreach ($line as $key => $val) { $$key = htmlentities($val); }
// CREATE THE ROW OF DATA        
        echo "<tr>";
        echo "<td width='10%' align='center'>$job_id</td>\n";
    echo "<td width='12%' align='center'>$userproof_id</td>\n";
        echo "<td width='60%' align='left'>$proof </td>\n";
        echo "<td width='10%' align='center'><a href='proofprocess.php?id=$userproof_id'><img src ='images/tick.png'></img></a></td>\n";
    echo "<td width='5%' align='center'><img src ='images/cross.png'></img></td>\n";
    } // END WHILE ITERATOR
    echo "</table>\n";
} // END IF/ELSE
}
?>

Re: Send multiple ID's in a link?

Posted: Wed Sep 30, 2009 12:59 pm
by mayanktalwar1988
if you only asking how to send it to the next page ur job_id go like this

Code: Select all

echo "<td width='10%' align='center'><a href='proofprocess.php?id=$userproof_id&jid=$job_id'><img src ='images/tick.png'></img></a></td>\n";
then to use that in current script do this
$job_id=$_GET[jid];

Re: Send multiple ID's in a link?

Posted: Wed Sep 30, 2009 1:02 pm
by synical21
Sounds like what i need, trying it now

Re: Send multiple ID's in a link?

Posted: Wed Sep 30, 2009 1:11 pm
by mayanktalwar1988
hey i would say read some good tutorials on working with query strings in php (http://www.domainname.com?id=$mayank&gi ... id=$talwar it is a query string as u may know already)
its easy concept..and very useful one to

Re: Send multiple ID's in a link?

Posted: Wed Sep 30, 2009 1:15 pm
by mayanktalwar1988
only if you are very new to php
http://www.zymic.com/forum/index.php?showtopic=3705 this is the good tutorial to follow

Re: Send multiple ID's in a link?

Posted: Wed Sep 30, 2009 1:17 pm
by synical21
Thank you for the tutorials i will read up on them for sure, and the soloution has worked thank you very much for the help. :drunk:

Re: Send multiple ID's in a link?

Posted: Wed Sep 30, 2009 1:22 pm
by mayanktalwar1988
cooooooooool :D