Jump to content

is it possible to append the results from 2 seperate sql statements to url?


Recommended Posts

Hi all,

 

I'm dragging info from a db, printing it to the screen and then when a user click on a particular row it takes them to a page with certain row information appended to the url for use on the next page!

 

$result = mysql_query("SELECT bid.addons, signuphotel.hotelname,signuphotel.email,signuphotel.telephone, signuphotel.county
FROM bid
LEFT JOIN signuphotel ON bid.username = signuphotel.username
WHERE bid.proposalid ='$propid'");

while($row = mysql_fetch_array($result))
{
echo "<tr onclick=\"window.location='bookview.php?hn=" . $row['hotelname'] . "&em=" . $row['email'] . "&te=" . $row['telephone'] . "'\">";
			  echo "<td>" . $row['hotelname'] . "</td>";
			  echo "<td>" . $row['starrating'] . "</td>";
			  echo "<td>" . $row['county'] . "</td>";
			  echo "<td>" . $row['addons'] . "</td>";

 

This works fine.

 

However I was just wondering if I had a separate sql query on the page like

 

Select *
From authuser
Where Uname = '$username'

 

...if there is anyway I could also append this information to the specific row URL?

 

I'm thinkin there isn't and ill need to find another way of getting the information from authuser to the next page but maybe someone here can tell me for sure.

 

I'd appreciate any suggestions

 

Thanks very much!

 

 

 

 

If Uname ain't an indexed key then you'd be better off using the id (primary key) instead as this will greatly speed up search.

 

page1.php

<a href="page2.php?id=$id">view info</a>

 

page2.php

print abs((int) $_GET['id']));

Thanks for getting back to me Ignace!

 

I'm sorry, you are probably answering my question but I'm not sure I understand your suggestion.

 

Ok so currently, I have this line..

 

echo "<tr onclick=\"window.location='bookview.php?hn=" . $row['hotelname'] . "&em=" . $row['email'] . "&te=" . $row['telephone'] . "'\">";

 

The information that is being appended to this url is coming from this sql statement

 

$result = mysql_query("SELECT bid.addons, signuphotel.hotelname,signuphotel.email,signuphotel.telephone, signuphotel.county
FROM bid
LEFT JOIN signuphotel ON bid.username = signuphotel.username
WHERE bid.proposalid ='$propid'");

 

Now, I want to add the results of a second seperate sql statement to the URL.

The second statement is something like..

 

Select firstname
From authuser
Where Uname = '$username'

 

So basically id like to add the result of this ie $row['firstname'] to the above url.

 

I'm just wondering if this is possible?

why don't you just get the primary key of the specific entry and do a query on the next page? that would be a lot easier and safer than passing a bunch of information through the get variables, (Which can easily be tampered with btw)

SELECT authuser.firstname, bid.addons, signuphotel.hotelname,signuphotel.email,signuphotel.telephone, signuphotel.county

FROM bid

JOIN signuphotel ON bid.username = signuphotel.username

JOIN authuser ON bid.username = authuser.username

WHERE bid.proposalid ='$propid'

 

I removed the LEFT I really doubt you want that functionality. If you would remove an entry from signuphotel for which their is an entry in bid you would still get the bid but you would have no hotel for it to display with it.

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.