thenorman138 Posted May 10, 2017 Share Posted May 10, 2017 I have a search function that works perfectly by matching database values and displaying the records on my page. However, I want to make my serial number field in the output a "href " link to open a new page that uses the serial number in the code. I had it working previously with dropdowns but I'm trying to make it work with the search function. Here's the working code: $search = $connect->real_escape_string($_POST['search']); $resultSet = $connect->query("SELECT * FROM staging WHERE serialNumber LIKE '%$search%'"); if($resultSet->num_rows > 0){ while($rows = $resultSet->fetch_assoc()) { $date = $rows['date']; $utility = $rows['utility']; $address = $rows['address']; $sn = $rows['serialNumber']; $output .= "Date: $date <br />Utility: $utility<br />Address: $address<br />Serial Number: $sn<br /><br />"; } }else{ $output = "No Results"; } } Now, when I try to add the link to the serial number variable, like this: $output .= "Date: $date <br />Utility: $utility<br />Address: $address<br />Serial Number: <a href=\\'/dashboard-display?id='.$row['serialNumber'].''>$sn</a><br /><br />"; The page doesn't load. I'm using a PHP reference but I think I may have syntax wrong in the href section. How can I get this to display the info with the link tag around $sn? Quote Link to comment Share on other sites More sharing options...
Solution cyberRobot Posted May 10, 2017 Solution Share Posted May 10, 2017 Try changing this $output .= "Date: $date <br />Utility: $utility<br />Address: $address<br />Serial Number: <a href=\\'/dashboard-display?id='.$row['serialNumber'].''>$sn</a><br /><br />"; To this $output .= "Date: $date <br />Utility: $utility<br />Address: $address<br />Serial Number: <a href='/dashboard-display?id=".$row['serialNumber']."'>$sn</a><br /><br />"; Quote Link to comment Share on other sites More sharing options...
thenorman138 Posted May 10, 2017 Author Share Posted May 10, 2017 I knew I was doing something wrong there, thank you so much! works perfectly Quote Link to comment 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.