debuitls Posted September 2, 2009 Share Posted September 2, 2009 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! Quote Link to comment https://forums.phpfreaks.com/topic/172875-is-it-possible-to-append-the-results-from-2-seperate-sql-statements-to-url/ Share on other sites More sharing options...
ignace Posted September 2, 2009 Share Posted September 2, 2009 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'])); Quote Link to comment https://forums.phpfreaks.com/topic/172875-is-it-possible-to-append-the-results-from-2-seperate-sql-statements-to-url/#findComment-911144 Share on other sites More sharing options...
debuitls Posted September 2, 2009 Author Share Posted September 2, 2009 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? Quote Link to comment https://forums.phpfreaks.com/topic/172875-is-it-possible-to-append-the-results-from-2-seperate-sql-statements-to-url/#findComment-911150 Share on other sites More sharing options...
mikesta707 Posted September 2, 2009 Share Posted September 2, 2009 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) Quote Link to comment https://forums.phpfreaks.com/topic/172875-is-it-possible-to-append-the-results-from-2-seperate-sql-statements-to-url/#findComment-911153 Share on other sites More sharing options...
ignace Posted September 2, 2009 Share Posted September 2, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/172875-is-it-possible-to-append-the-results-from-2-seperate-sql-statements-to-url/#findComment-911196 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.