473,509 Members | 2,963 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Raw SQL results

Hopefully someone can help.

If you query a mysql database with a command line, you get results.
eg: select * FROM table WHERE foo='bar' //would produce
+------------+
| foo |
+------------+
| bar |
+------------+
1 row in set (0.00 sec)

Is there anyway to use php to output this raw sql result?
I would simply like to echo out the whole lot (above)

Regards
Richard Grove
Jul 17 '05 #1
7 2714
"®ed Eye Media - ®ichard Grove" <in**@redeyemedia.co.uk> wrote in message
news:40***********************@mercury.nildram.net ...
Hopefully someone can help.

If you query a mysql database with a command line, you get results.
eg: select * FROM table WHERE foo='bar' //would produce
+------------+
| foo |
+------------+
| bar |
+------------+
1 row in set (0.00 sec)


If you need exactly that appearance, (wit -- + and |)I think you could
call from php shell command for mysql, and then capture output from it and
replace newlines with <br>. Look-up in manual for excuting shell commands.

rush
--
http://www.templatetamer.com/
Jul 17 '05 #2
®ed Eye Media - ®ichard Grove wrote:
X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
If you query a mysql database with a command line, you get results.
eg: select * FROM table WHERE foo='bar' //would produce
+------------+
| foo |
+------------+
| bar |
+------------+
1 row in set (0.00 sec)

Is there anyway to use php to output this raw sql result?
I would simply like to echo out the whole lot (above)

not tested on Windows

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $data = `echo "select * from database.table where foo='bar';" | mysql -uusername -ppassword -t`;
  3. echo "<pre>$data</pre>\n";
  4. ?>
  5.  
--
--= my mail box only accepts =--
--= Content-Type: text/plain =--
--= Size below 10001 bytes =--
Jul 17 '05 #3

"Pedro Graca" <he****@hotpop.com> wrote in message
news:c0*************@ID-203069.news.uni-berlin.de...
®ed Eye Media - ®ichard Grove wrote:
X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
If you query a mysql database with a command line, you get results.
eg: select * FROM table WHERE foo='bar' //would produce
+------------+
| foo |
+------------+
| bar |
+------------+
1 row in set (0.00 sec)

Is there anyway to use php to output this raw sql result?
I would simply like to echo out the whole lot (above)

not tested on Windows

Expand|Select|Wrap|Line Numbers
  1.  <?php
  2.  $data = `echo "select * from database.table where foo='bar';" |
  • mysql -uusername -ppassword -t`;
  •  echo "<pre>$data</pre>\n";
  •  ?>
  •  
  • --
    All this does it output the query, not the results.
    Regards
    RG
    Jul 17 '05 #4
    ®ed Eye Media - Richard Grove wrote:
    "Pedro Graca" <he****@hotpop.com> wrote in message
    news:c0*************@ID-203069.news.uni-berlin.de...
    ®ed Eye Media - ®ichard Grove wrote:
    X-Newsreader: Microsoft Outlook Express 6.00.2800.1106

    If you query a mysql database with a command line, you get results.
    eg: select * FROM table WHERE foo='bar' //would produce
    +------------+
    | foo |
    +------------+
    | bar |
    +------------+
    1 row in set (0.00 sec)

    Is there anyway to use php to output this raw sql result?
    I would simply like to echo out the whole lot (above)

    not tested on Windows

    Expand|Select|Wrap|Line Numbers
    1. <?php
    2. $data = `echo "select * from database.table where foo='bar';" |
  •  mysql -uusername -ppassword -t`;
  • echo "<pre>$data</pre>\n";
  • ?>
  • --

    All this does it output the query, not the results.
    Regards
    RG
    those are backticks (top left key on my keyboard) not apostrophes.

    backticks execute the string inside them and return the result.
    Jul 17 '05 #5
    Kevin Thorpe wrote:
    User-Agent: Mozilla/5.0 (Windows; ...
    "Pedro Graca" <he****@hotpop.com> wrote in message
    news:c0*************@ID-203069.news.uni-berlin.de...

    not tested on Windows

    Expand|Select|Wrap|Line Numbers
    1. <?php
    2. $data = `echo "select * from database.table where foo='bar';" |
  •  mysql -uusername -ppassword -t`;
  • echo "<pre>$data</pre>\n";
  • ?>

  • those are backticks (top left key on my keyboard) not apostrophes.

    backticks execute the string inside them and return the result.

    Does it work in Windows (I don't have PHP or MySQL here at work)?

    or do you have to do something like the following?

    Expand|Select|Wrap|Line Numbers
    1. $data = `mysql -uusername -ppassword -t < echo "select * from db.table"`;
    2.  

    I tried a few different things, it appears this syntax should work
    --
    --= my mail box only accepts =--
    --= Content-Type: text/plain =--
    --= Size below 10001 bytes =--
    Jul 17 '05 #6

    "Pedro Graca" <he****@hotpop.com> wrote in message
    news:c0*************@ID-203069.news.uni-berlin.de...
    Kevin Thorpe wrote:
    User-Agent: Mozilla/5.0 (Windows; ...
    "Pedro Graca" <he****@hotpop.com> wrote in message
    news:c0*************@ID-203069.news.uni-berlin.de...

    not tested on Windows

    Expand|Select|Wrap|Line Numbers
    1.  >>><?php
    2.  >>>$data = `echo "select * from database.table where foo='bar';" |
    3.  >>
    4.  >> mysql -uusername -ppassword -t`;
    5.  >>
    6.  >>>echo "<pre>$data</pre>\n";
    7.  >>>?>
    8.  >>>

    those are backticks (top left key on my keyboard) not apostrophes.

    backticks execute the string inside them and return the result.


    Does it work in Windows (I don't have PHP or MySQL here at work)?

    or do you have to do something like the following?

    Expand|Select|Wrap|Line Numbers
    1.  $data = `mysql -uusername -ppassword -t < echo "select * from db.table"`;
    2.  


    I tried a few different things, it appears this syntax should work
    --

    Doesn't work this end.
    Thanks anyway
    RG
    Jul 17 '05 #7
    ®ed Eye Media - Richard Grove wrote:

    "Pedro Graca" <he****@hotpop.com> wrote in message
    news:c0*************@ID-203069.news.uni-berlin.de...

    Expand|Select|Wrap|Line Numbers
    1.  $data = `mysql -uusername -ppassword -t < echo "select * from db.table"`;
    2.  
    Doesn't work this end.
    Thanks anyway


    What happens if you type that into a DOS command-prompt window?

    C:\DOS> mysql -hLOCALHOST -uUSERNAME -pPASSWORD -t < echo "select * from db.table"

    ( remember to replace LOCALHOST, USERNAME, and PASSWORD )
    --
    --= my mail box only accepts =--
    --= Content-Type: text/plain =--
    --= Size below 10001 bytes =--
    Jul 17 '05 #8

    This thread has been closed and replies have been disabled. Please start a new discussion.

    Similar topics

    6
    2000
    by: Francisco | last post by:
    I have this question: I have a simple search to a db, something like: "select description from games where year = '1990'" suppose I get 300 results, I would like to display this in pages of 30...
    4
    2164
    by: Aaron Reimann | last post by:
    I am trying to build a table using results from a database query. Right now (code below), the code displays each result in a new <tr>. I am wanted to display 3 results in one <tr> </tr>, and then...
    2
    3517
    by: CharitiesOnline | last post by:
    Hello, I have set this script up to add paging to a search results page. Which on the first page works fine. I calculates how many pages there should be depending on the number of results returned...
    5
    2954
    by: George | last post by:
    Hi, Anyone has the background for explaining? I have made a search on my name and I have got a link to another search engine. The link's title was the search phrase for the other search engine...
    6
    2300
    by: Jules | last post by:
    Hi: I have an Access 97 Search form set up - a couple of combo boxes, a couple of text fields and a command button. I want the command button to run an SQL script and then open the results form....
    1
    3529
    by: Don | last post by:
    I am new to Indexing Services, have been researching the MS Site as well as web articles on DevHood, etc. I have set up a seperate catalog ("KnowledgeBase") on Win XP with a number of files. I am...
    0
    1893
    by: Rob | last post by:
    I doubt this is the best way to do it, but what I came up with was to hide the XML in an HTML Comment then edit the file deleting the HTML stuff and keep the XML results. If anyone has a better...
    4
    1616
    by: jaYPee | last post by:
    I have downloaded some source code but I want this to convert the results into datagrid. dr = cmd.ExecuteReader() '**************************************** ' SHOW THE RESULTS...
    1
    1276
    by: oaklander | last post by:
    Is it okay to keep creating queries with the same ResultSet Object reference (results)? Here is what I am currently using in my Database statements with Oracle and everything works but was wondering...
    3
    1478
    by: Bigalan | last post by:
    Hello, i am relatively new to PHP and i am struggling with printing multiple search results on to different pages. The code below works ok but when you click on next page button, it brings up a blank...
    0
    7136
    by: Hystou | last post by:
    Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
    0
    7412
    jinu1996
    by: jinu1996 | last post by:
    In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
    1
    7069
    by: Hystou | last post by:
    Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
    0
    5652
    agi2029
    by: agi2029 | last post by:
    Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
    1
    5060
    isladogs
    by: isladogs | last post by:
    The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
    0
    3216
    by: TSSRALBI | last post by:
    Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
    0
    3203
    by: adsilva | last post by:
    A Windows Forms form does not have the event Unload, like VB6. What one acts like?
    0
    1570
    by: 6302768590 | last post by:
    Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
    0
    441
    bsmnconsultancy
    by: bsmnconsultancy | last post by:
    In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

    By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

    To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.