shedokan Posted July 28, 2009 Share Posted July 28, 2009 Is there a way to print to the browser from a mysql query? I heard that on the mysql command line you can do: mysql> print "something" so is there a way to do it from mysql, so i don't have to get a mysql array and echo it? thanks. Quote Link to comment https://forums.phpfreaks.com/topic/167815-is-there-a-way-to-print-to-the-browser-from-a-mysql-query/ Share on other sites More sharing options...
Maq Posted July 28, 2009 Share Posted July 28, 2009 Can you explain exactly what you're trying to accomplish so we can provide the best solution for your situation? Quote Link to comment https://forums.phpfreaks.com/topic/167815-is-there-a-way-to-print-to-the-browser-from-a-mysql-query/#findComment-885066 Share on other sites More sharing options...
shedokan Posted July 28, 2009 Author Share Posted July 28, 2009 I am currently doing this: <?php $r=mysql_query('SELECT FROM names WHERE id='.$id); $a=mysql_fetch_array($r,MYSQL_ASSOC); ?> Your Name Is <?=$a['name']?> Where $id is the user's id. so I am looking for a way to do it easier. Quote Link to comment https://forums.phpfreaks.com/topic/167815-is-there-a-way-to-print-to-the-browser-from-a-mysql-query/#findComment-885076 Share on other sites More sharing options...
BLaZuRE Posted July 29, 2009 Share Posted July 29, 2009 Is there a way to print to the browser from a mysql query? I heard that on the mysql command line you can do: mysql> print "something" so is there a way to do it from mysql, so i don't have to get a mysql array and echo it? thanks. The MySQL command line won't do that for you. Think of it as similar to the Windows command prompt or the Linux terminal. MySQL is just like any other language, verbal (English, French) or computer (PHP, C++). You have to learn the language to use its functionality, there's no shortcut. Quote Link to comment https://forums.phpfreaks.com/topic/167815-is-there-a-way-to-print-to-the-browser-from-a-mysql-query/#findComment-885602 Share on other sites More sharing options...
shedokan Posted July 30, 2009 Author Share Posted July 30, 2009 I'm not asking for a shortcut, I am asking for a different way of doing something. Quote Link to comment https://forums.phpfreaks.com/topic/167815-is-there-a-way-to-print-to-the-browser-from-a-mysql-query/#findComment-886447 Share on other sites More sharing options...
BLaZuRE Posted July 30, 2009 Share Posted July 30, 2009 I'm not asking for a shortcut, I am asking for a different way of doing something. To my knowledge, there's no "easier" way to do this. Basically, you have to: 1) Get and choose the data from the database (which you did using a MySQL query) 2) Format your data so that PHP can handle it (which you did by saving only the first row into a variable) 2) Output the data into a presentable format (which you did by echo'ing) If you're looking for alternatives though, you may want to look at mysql_fetch_assoc() or mysql_fetch_row(). Please further clarify your question if it wasn't answered. Quote Link to comment https://forums.phpfreaks.com/topic/167815-is-there-a-way-to-print-to-the-browser-from-a-mysql-query/#findComment-886556 Share on other sites More sharing options...
fenway Posted August 3, 2009 Share Posted August 3, 2009 Well, from the CLI, you can specify how you want your output to be show -- either with \G or with pager. Quote Link to comment https://forums.phpfreaks.com/topic/167815-is-there-a-way-to-print-to-the-browser-from-a-mysql-query/#findComment-889956 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.