I'm tryin to display some info from a database. I have a table named test_table with three columns: key_id (a numbered column), name, and phone. I want to display just the field numbered 100 in the phone column. What I have is this which does work but displays the entire phone colunm, I just want entry number 100.
The other question I have is the information in block 100 is in three paragraphs but is displayed as a single paragraph when using the above code. How do I keep the pragraph formatting.Code:<?php $result = @mysql_query('SELECT phone FROM test_table'); if (!$result) { exit(' Error performing query: ' . mysql_error() . '</p>'); } while ($row = mysql_fetch_array($result)) { echo ' ' . $row['post_text'] . '</p>'; } ?>
+ Reply to Thread
Results 1 to 8 of 8
-
-
It's been a while since I did any database programming, but the query you are running is an open query against that column and table. You need to limit it by including a 'where id_column = row_no' - id_column being your key column and row_no being the row you want returned. Or, put the check in the while statement and pick it up when you go through the results array. At the moment you just don't have anything there to tell it row 100 is what you want.
Read my blog here.
-
Example?
I comprehend a little but I'm still learning. Heeeeeeeeeeelp me please, it's due tomorrow.
-
Code:
<?php $result = @mysql_query('SELECT * FROM test_table where key_id=100'); if (!$result) { exit(' Error performing query: ' . mysql_error() . '</p>'); } while ($row = mysql_fetch_array($result)) { echo ' '. $row['key_id']. $row['name'] . $row['phone'] . '</p>'; } ?>
-
Excellent, thanks Baldrick that works perfect. Can anyone answer my second question? How do I keep the formatting so the paragraphs don't run together?
If I open up that specific cell in MySQL Query Browser it displays the correctly. -
you can add a space between each,
. $row['key_id']. ' '. $row['name'] . ' ' .$row['phone'] . -
I guess I used the wrong terminology, what I'm trying to do is display a single post from phpbb post. It's in a hidden forum but I want to display it on other pages so I can't use phpbb fetchall. This is what I have in a file called test.php:
Code:<html> <head> <title>Test</title> </head> <body> <?php $result = @mysql_query('SELECT * FROM phpbb_posts_text where post_id=410'); if (!$result) { exit(' Error performing query: ' . mysql_error() . '</p>'); } while ($row = mysql_fetch_array($result)) { echo '<div>'. $row['post_text'] . '</div>'; } ?> </body> </html>
paragraph 1 paragraph 2
What I want is:
paragraph 1
paragraph 2 -
After about 100 tries I came up with this:
Code:<html> <head> <title>Test</title> </head> <body> <?php $result = @mysql_query('SELECT * FROM phpbb_posts_text where post_id=410'); if (!$result) { exit(' Error performing query: ' . mysql_error() . '</p>'); } while ($row = mysql_fetch_array($result)) { echo nl2br('<div>' . $row['post_text'] . '</div>'); } ?> </body> </html>
Similar Threads
-
Mencoder+PHP No streaming :(
By diduafka in forum Video ConversionReplies: 6Last Post: 3rd Aug 2011, 03:45 -
php-ffmpeg video conversion
By Tonybot in forum Video ConversionReplies: 6Last Post: 7th Jun 2011, 03:37 -
php-ffmpeg video conversion
By Tonybot in forum ProgrammingReplies: 1Last Post: 6th Jun 2011, 02:36 -
Changing .php files
By rotuts in forum MacReplies: 3Last Post: 28th Dec 2008, 14:35 -
php error - viewforumlatest.php?topicdays=1&start=100
By offline in forum FeedbackReplies: 9Last Post: 29th May 2008, 22:52