ckir5951 Posted March 5, 2020 Share Posted March 5, 2020 The below code produces a dropdown and when a selection is made and submitted produces a table row with a link to the record but the link doesn't work. suggestions? --------------------------------------------------------------------------- <!DOCTYPE><html><head> <title>lookup menu</title> </head> <body><center><b> <form name="form" method="post" action=""> <?php // error_reporting(0); error_reporting(E_ALL ^ E_NOTICE); include 'homedb-connect.php'; //This creates the drop down box echo "<select name= 'target'>"; echo '<option value="">'.'--- Select account ---'.'</option>'; $query = mysqli_query($con,"SELECT target FROM lookuptbl"); $query_display = mysqli_query($con,"SELECT * FROM lookuptbl"); while($row=mysqli_fetch_array($query)) {echo "<option value='". $row['target']."'>".$row['target'] .'</option>';} echo '</select>'; ?> <input type="submit" name="submit" value="Submit"/> </form><center> <?php // error_reporting(0); error_reporting(E_ALL ^ E_NOTICE); include 'homedb-connect.php'; if(isset($_POST['target'])) { $name = $_POST['target']; $fetch="SELECT target, purpose, user, password, email, visits, date, saved FROM lookuptbl WHERE target = '".$name."'"; $result = mysqli_query($con,$fetch); if(!$result) {echo "Error:".(mysqli_error($con));} //display the table echo '<table border="1"><tr><td bgcolor="#ccffff" align="center">lookup menu</td></tr> <tr><td> <table border="1"> <tr> <td> Target </td> <td> Purpose </td> <td> User </td> <td> Password </td> <td> Email </td> <td> Visits </td> <td> Date </td> <td> Saved </td> </tr>'; while($data=mysqli_fetch_row($result)) { $url= "http://localhost/home/crud-link.php?target=". $data[0]; $link= '<a href="'.$url.'">'. $data[0]. '</a>'; echo ("<tr><td> $link </td><td>$data[1]</td><td>$data[2]</td><td>$data[3]</td> <td>$data[4]</td><td>$data[5]</td><td>$data[6]</td><td>$data[7]</td></tr>"); } echo '</table> </td></tr></table>'; } ?> </body></html> Quote Link to comment Share on other sites More sharing options...
ginerjm Posted March 5, 2020 Share Posted March 5, 2020 a lot of (improperly posted) code there but not sure why. What is your question? BTW - you are NOT turning on error reporting which you should be doing. The '0' argument turns it off. A '1' will turn it on for you. Quote Link to comment Share on other sites More sharing options...
gizmola Posted March 5, 2020 Share Posted March 5, 2020 Why don't you var_dump or print_var the contents of $data to debug this. An obvious concern is that you do not urlencode() $data[0]. $url= "http://localhost/home/crud-link.php?target=". urlencode($data[0]); We need more information than "but the link doesn't work." What exactly does that mean? Probably not related, but the form is user input, and your mysqli queries should be using mysqli_prepare with a bound parameter. 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.