php - getting a query output to be a link(to another page) -
i trying create query suck data database , return them(rows of user names) links pages(respectively).
the query seeems work having hard time echoing link (i missing '.' or alog line).
i greatful if point me problem , why error browser doesn't expect: </a><br>
.
here code of php page(on html page stick expected results no need show logic there unless ask me to):
<?php include('connectdb.php'); if( isset( $_post['user_name'] ) ) { $name = $_post['user_name']; $query = $conn->query("select u.firstname,u.lastname tblfriendswith fw inner join tbluser u on u.username=fw.username2 username1 '$name%' "); while($row = $query->fetch_row()) { echo '<a href=\'userpage.php?fullname='. $row[0] .' '. $row[1].'>'.$row[0] .' '. $row[1].'\'>' '</a>''<br>'; } } ?>
i tried add '.' between ,
'' between , no avail.
thank you! tom
if issue echo...
echo '<a href="/userpage.php?fullname=', urlencode($row[0] . ' ' . $row[1]), '">', $row[0], ' ', $row[1], '</a><br>';
you must urlencode query of href parameter in anchor tag spaces , other funny characters may break link.
in example i've shown echo statement multiple inputs separated commas (,). echo takes unlimited number of input variables , echo them out screen 1 after another. method faster concatenating strings periods (.) before echoing , may make code easier read in future.
Comments
Post a Comment