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? Link to comment Share on other sites More sharing options...
cyberRobot Posted May 10, 2017 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 />"; 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 Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.