foozago Posted February 20, 2008 Share Posted February 20, 2008 okay easy enough...but i would like one of those fields to be a hyperlink...when i work in the mysql browser control to add my data it won't let me add a hyperlink as a variable.... any idea as to how to do that... i have name city street. and a whole much others one of them i would like it to see see reviews - i want the words see reviews to be clickable to go to a new page....so how do i add a hyperlink into that field? Link to comment https://forums.phpfreaks.com/topic/92160-adding-fields-to-mysql/ Share on other sites More sharing options...
craygo Posted February 20, 2008 Share Posted February 20, 2008 don't see why you can't enter a hyperlink into a field. What kind of error you getting?? Link to comment https://forums.phpfreaks.com/topic/92160-adding-fields-to-mysql/#findComment-472078 Share on other sites More sharing options...
jedney Posted February 20, 2008 Share Posted February 20, 2008 Try this: <?php echo "<a href=\"". $row["url"] ."\">See Reviews</a><br />"; ?> Just have a field in the table called URL, and put "www.page.com" there. -Jon Link to comment https://forums.phpfreaks.com/topic/92160-adding-fields-to-mysql/#findComment-472094 Share on other sites More sharing options...
foozago Posted February 20, 2008 Author Share Posted February 20, 2008 i am not sure why it didn't let me put the url's. but i will definately try it thank you Link to comment https://forums.phpfreaks.com/topic/92160-adding-fields-to-mysql/#findComment-472163 Share on other sites More sharing options...
foozago Posted February 20, 2008 Author Share Posted February 20, 2008 http://foozago.com if you type andover in the search bar above...it gives you the URL but i can't click on it or anything.......please help Link to comment https://forums.phpfreaks.com/topic/92160-adding-fields-to-mysql/#findComment-472230 Share on other sites More sharing options...
revraz Posted February 20, 2008 Share Posted February 20, 2008 You still need to make it a Link with HTML, right now it's just this <table width="1073" border="0"> <tr> <td>andover</td> <td>sparta</td> <td>nj</td> <td>french</td> <td>www.foozago.com/andover</td> </tr> </table> Link to comment https://forums.phpfreaks.com/topic/92160-adding-fields-to-mysql/#findComment-472239 Share on other sites More sharing options...
foozago Posted February 20, 2008 Author Share Posted February 20, 2008 yeah how do i turn it into a hyperlink if it's dynamically set.....how do i add a hyperlink into the mysql browswer.. Link to comment https://forums.phpfreaks.com/topic/92160-adding-fields-to-mysql/#findComment-472255 Share on other sites More sharing options...
roopurt18 Posted February 20, 2008 Share Posted February 20, 2008 The same way you'd echo any other link, or any other text for that matter, in PHP: $url = 'http://www.yahoo.com/'; echo '<a href="' . $url . '">Click here!</a>'; The only difference is you don't have a variable named $url. You're pulling the URL from the database so it'll be something like: $sql = "SELECT ..."; $q = mysql_query($sql) or die('Error: ' . mysql_error()); while($row = mysql_fetch_assoc($q)){ echo '<a href="' . $row['url'] . '">Click here!</a>'; } Link to comment https://forums.phpfreaks.com/topic/92160-adding-fields-to-mysql/#findComment-472270 Share on other sites More sharing options...
foozago Posted February 20, 2008 Author Share Posted February 20, 2008 okay kind of makes sense....would i put that in the bindings panel...... i am using dreamweaver cs3 and using the simple...so i gues i would have to go to advanced and type it exactly as you have posted it??? Link to comment https://forums.phpfreaks.com/topic/92160-adding-fields-to-mysql/#findComment-472278 Share on other sites More sharing options...
foozago Posted February 20, 2008 Author Share Posted February 20, 2008 this is what i have and it says i have an error in syntax.... SELECT * FROM restaurants WHERE name LIKE %colname% ORDER BY name ASC $q = mysql_query($sql) or die('Error: ' . mysql_error()); while($row = mysql_fetch_assoc($q)){ echo '<a href="' . $row['url'] . '">Click here!</a>'; } the part that starts with $q is the part that i just put it and made it stop working....the top part that starts with select works...it goes to the database and gets the information.... am i typing it wrong? Link to comment https://forums.phpfreaks.com/topic/92160-adding-fields-to-mysql/#findComment-472288 Share on other sites More sharing options...
roopurt18 Posted February 20, 2008 Share Posted February 20, 2008 okay kind of makes sense....would i put that in the bindings panel...... i am using dreamweaver cs3 and using the simple...so i gues i would have to go to advanced and type it exactly as you have posted it??? I have no idea what you're talking about. I have a feeling you may be attempting to run when you haven't even learned how to walk yet. Are you working out of a book or an online tutorial? As for your error, try changing: SELECT * FROM restaurants WHERE name LIKE %colname% ORDER BY name ASC to $sql = "SELECT * FROM restaurants WHERE name LIKE '%colname%' ORDER BY name ASC"; Also the '%colname%' is likely meant to be a search string, something like: '%Friday%' Link to comment https://forums.phpfreaks.com/topic/92160-adding-fields-to-mysql/#findComment-472308 Share on other sites More sharing options...
foozago Posted February 21, 2008 Author Share Posted February 21, 2008 i am wokring with dreamweaver cs3....so it does teh work for you...and thats the code it generated....no "$" were put anywhere and it works... Link to comment https://forums.phpfreaks.com/topic/92160-adding-fields-to-mysql/#findComment-472670 Share on other sites More sharing options...
uniflare Posted February 21, 2008 Share Posted February 21, 2008 whats the filename that this code is in SELECT * FROM restaurants WHERE name LIKE %colname% ORDER BY name ASC (im thinking its using a file to store the query only. thats the only way php would work with this syntax) what EXACTLY does the error say? if you can give us the entire script (or if its really big 100 lines around the error line should do) Link to comment https://forums.phpfreaks.com/topic/92160-adding-fields-to-mysql/#findComment-472673 Share on other sites More sharing options...
foozago Posted February 21, 2008 Author Share Posted February 21, 2008 $q = mysql_query($sql) or die('Error: ' . mysql_error()); while($row = mysql_fetch_assoc($q)){ echo '<a href="' . $row['url'] . '">Click here![/url]'; } i had the select part and that worked. once i add the above...it stops working.. question all my fields are just named.....name, street, city....and so forth should they be named $name, $street and so forth? every tutorial i see online has that dollar sign all over the place...but when i try to add it it just gives me errors all over the place. Link to comment https://forums.phpfreaks.com/topic/92160-adding-fields-to-mysql/#findComment-472681 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.