mike12255 Posted June 14, 2009 Share Posted June 14, 2009 Im grabbing this line from my database: pfd/Order Number.pdf I need to create a url like this: <a href = admin/pfd/Order Number.pdf>Link</a> to do this im using the following PHP code: <?php $sql = "SELECT * FROM catagories"; $res = mysql_query($sql) or die (mysql_error()); while ($row = mysql_fetch_assoc($res)){ //echo "<a href= Admin/".$row['Name'].">".$row['wantedname']."</a><br>"; echo "<a href=\"" . urlEncode($row['Name']) . "\">" . $row['wantedname'] . "</a><br >\n"; } ?> unfortinatlly this outputs this: <a href="Admin/pfd/Order" number.pdf="">sdfas sdf asdf</a> anyone know how to fix the <a href part? Quote Link to comment Share on other sites More sharing options...
joel24 Posted June 14, 2009 Share Posted June 14, 2009 change it to echo '<a href="' . urlEncode($row['Name']) . '">' . $row['wantedname'] . '</a><br >\n'; you should use ' instead of " when there is no php variables inside the quotes, otherwise PHP is still searching through it in case there is one. Quote Link to comment Share on other sites More sharing options...
Alex Posted June 14, 2009 Share Posted June 14, 2009 change it to echo '<a href="' . urlEncode($row['Name']) . '">' . $row['wantedname'] . '</a><br >\n'; you should use ' instead of " when there is no php variables inside the quotes, otherwise PHP is still searching through it in case there is one. However, like that the \n won't parse. The \n must be wrapped in double quotes to parse. Also, urlEncode is just going to change your space to +, which I don't think you want. That's used more for variables and such. So try this: $name = 'pfd/Order Number.pdf'; echo '<a href="admin/' . $name . '">' . $row['wantedname'] . '</a><br >' . "\n"; Output: <a href="admin/pfd/Order Number.pdf"></a><br > 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.