Send multiple ID's in a link?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
synical21
Forum Contributor
Posts: 150
Joined: Tue Jul 28, 2009 8:44 am
Location: London UK

Send multiple ID's in a link?

Post 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
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: Send multiple ID's in a link?

Post by jackpf »

Umm...put it in the query string as well?
synical21
Forum Contributor
Posts: 150
Joined: Tue Jul 28, 2009 8:44 am
Location: London UK

Re: Send multiple ID's in a link?

Post by synical21 »

But the job id is a variable to, $job_id wouldnt work
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: Send multiple ID's in a link?

Post by jackpf »

You should be using $_GET. Don't use register globals.
synical21
Forum Contributor
Posts: 150
Joined: Tue Jul 28, 2009 8:44 am
Location: London UK

Re: Send multiple ID's in a link?

Post 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
mayanktalwar1988
Forum Contributor
Posts: 133
Joined: Wed Jul 08, 2009 2:44 am

Re: Send multiple ID's in a link?

Post 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
synical21
Forum Contributor
Posts: 150
Joined: Tue Jul 28, 2009 8:44 am
Location: London UK

Re: Send multiple ID's in a link?

Post 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
}
?>
mayanktalwar1988
Forum Contributor
Posts: 133
Joined: Wed Jul 08, 2009 2:44 am

Re: Send multiple ID's in a link?

Post 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];
synical21
Forum Contributor
Posts: 150
Joined: Tue Jul 28, 2009 8:44 am
Location: London UK

Re: Send multiple ID's in a link?

Post by synical21 »

Sounds like what i need, trying it now
mayanktalwar1988
Forum Contributor
Posts: 133
Joined: Wed Jul 08, 2009 2:44 am

Re: Send multiple ID's in a link?

Post 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
mayanktalwar1988
Forum Contributor
Posts: 133
Joined: Wed Jul 08, 2009 2:44 am

Re: Send multiple ID's in a link?

Post 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
synical21
Forum Contributor
Posts: 150
Joined: Tue Jul 28, 2009 8:44 am
Location: London UK

Re: Send multiple ID's in a link?

Post 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:
mayanktalwar1988
Forum Contributor
Posts: 133
Joined: Wed Jul 08, 2009 2:44 am

Re: Send multiple ID's in a link?

Post by mayanktalwar1988 »

cooooooooool :D
Post Reply