leszer Posted August 17, 2011 Share Posted August 17, 2011 Not sure why I'm having such trouble making this work. Seems I've done it before but I can't wrap my head around it. The basic idea is that I want to throw the $id into the URL link in the table for the First and Last name to allow the record to be selected for editing. Easy... or so it seemed. <html> <title>Visitors Logs</title> <body> <center><h1>Visitors Log</h1></center> <center><h3><?php echo date('m/d/Y H:i'); ?></h3></center> <center><input type="button" value="Click here to login" onclick="window.location.href='login.php'" /></center> <br /><br /> <?php $username="root"; $password=""; $database="safety"; mysql_connect("localhost",$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query="SELECT * FROM login WHERE Date=CURDATE()"; $result=mysql_query($query); $num=mysql_num_rows($result); mysql_close(); ?> <table border="1" cellspacing="2" cellpadding="2"> <tr> <th><font face="Arial, Helvetica, sans-serif">Last Name</font></th> <th><font face="Arial, Helvetica, sans-serif">First Name</font></th> <th><font face="Arial, Helvetica, sans-serif">Company</font></th> <th><font face="Arial, Helvetica, sans-serif">Badge</font></th> <th><font face="Arial, Helvetica, sans-serif">Employee<br> You're Visiting</font></th> <th><font face="Arial, Helvetica, sans-serif">Time In</font></th> <th><font face="Arial, Helvetica, sans-serif">Time Out</font></th> <th><font face="Arial, Helvetica, sans-serif">Visitor & Contractor <br>Safety Video Reviewed</font></th> <th><font face="Arial, Helvetica, sans-serif">Employee Safety <br>Video Reviewed</font></th> </tr> <?php $i=0; while ($i < $num) { $id=mysql_result($result,$i,"ID"); $f1=mysql_result($result,$i,"LastName"); $f2=mysql_result($result,$i,"FirstName"); $f3=mysql_result($result,$i,"Company"); $f4=mysql_result($result,$i,"Badge"); $f5=mysql_result($result,$i,"TowEmp"); $f6=mysql_result($result,$i,"TimeIn"); $f7=mysql_result($result,$i,"TimeOut"); $f8=mysql_result($result,$i,"VCvid"); $f9=mysql_result($result,$i,"Tvid"); ?> <tr> <td><font face="Arial, Helvetica, sans-serif"><a href=logout.php?ID=$id><?php echo $f1; ?></a></font></td> <td><font face="Arial, Helvetica, sans-serif"><a href=logout.php?ID=$id><?php echo $f2; ?></a></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $f3; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $f4; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $f5; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $f6; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $f7; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $f8; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $f9; ?></font></td> </tr> <?php $i++; } ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/245033-single-record-by-id-in-url/ Share on other sites More sharing options...
PFMaBiSmAd Posted August 17, 2011 Share Posted August 17, 2011 You didn't exactly state what problem or error you need help with. The only apparent problem is that your link syntax is missing some quotes around the URL - href="logout.php?ID=$id" Quote Link to comment https://forums.phpfreaks.com/topic/245033-single-record-by-id-in-url/#findComment-1258586 Share on other sites More sharing options...
leszer Posted August 17, 2011 Author Share Posted August 17, 2011 Getting that $id into the url. It's not working. It literally shows up as $id, not the # of the record. Quote Link to comment https://forums.phpfreaks.com/topic/245033-single-record-by-id-in-url/#findComment-1258597 Share on other sites More sharing options...
JKG Posted August 17, 2011 Share Posted August 17, 2011 think about how you got the other values to show. <a href=logout.php?ID=<?php echo $id; ?>><?php echo $f1; ?> Quote Link to comment https://forums.phpfreaks.com/topic/245033-single-record-by-id-in-url/#findComment-1258602 Share on other sites More sharing options...
PFMaBiSmAd Posted August 17, 2011 Share Posted August 17, 2011 You would need to use php code to echo the php variable. Right now, it is just the characters $, i, and d in the html. Quote Link to comment https://forums.phpfreaks.com/topic/245033-single-record-by-id-in-url/#findComment-1258603 Share on other sites More sharing options...
leszer Posted August 17, 2011 Author Share Posted August 17, 2011 lol SOB, I knew it was going to be something stupid when it came down to it. Thanks for catching it! I've done it on other projects but forgot to echo. Thanks again! Quote Link to comment https://forums.phpfreaks.com/topic/245033-single-record-by-id-in-url/#findComment-1258609 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.