473,322 Members | 1,714 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

how to display mysql_fetch_array results with a template.php file

I am trying to use show_post.php to display records from a MySQL database.
Expand|Select|Wrap|Line Numbers
  1. while ($row = mysql_fetch_array ($result)) {
  2.         $count++;
  3.         $link = 'show_post.php?post=' . $row['post_ID'];
  4.         echo '<a href="' . $link . '" >' . $row['post_ID'] . '</a>';
  5.     }
  6.  
The file show_post.php takes post to retrieve data.
Expand|Select|Wrap|Line Numbers
  1. $post_ID = $_GET['post'];
  2.     $query = "SELECT * FROM posts WHERE post_ID = '". $post_ID . "'";
  3.     $result = @mysql_query($query) or die ("<p>Errpr : " . mysql_error());
  4.     if ($row = mysql_fetch_array ($result))
  5.  
A single item will be displayed by show_post.php. How can I get show_post.php to

display all of the data? Thanks for your help.
Aug 30 '10 #1
4 2456
If your query,
Expand|Select|Wrap|Line Numbers
  1. $query = "SELECT * FROM posts WHERE post_ID = '". $post_ID . "'";
returns multiple data then this should show all the returned data,

Expand|Select|Wrap|Line Numbers
  1. while ($row = mysql_fetch_array ($result)) {
  2. print_r($row);
  3. //use it like this $row['key']
  4.      }
Aug 31 '10 #2
A belated thanks for your help. It works. I appreciate your help.
Sep 10 '10 #3
Canabeez
126 100+
Just a suggestion.

Use addslashes($post_ID) in your query, in order to keep your database safe.

Good luck.
Sep 10 '10 #4
Thanks for the tip. I'll check it out. J
Sep 12 '10 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: lanny.moffett | last post by:
To all, I am using a macro in Access 2000 to run a report, merge the results with an HTML template, and store the results. All of this works fine as long as the "Template File" field contains a...
3
by: Greg | last post by:
I have a web page with a datalist in it that binds to a datatable. Within the template I call a function to process one of fields and return the data. This worked perfectly until I moved the...
2
by: Steven Smith | last post by:
Hi guys What I'm trying to do today is display the results from an SQL query on one table in a Datagrid I'm using the following code to query the table. \\\ Try If...
1
by: JackM | last post by:
I'm not sure if this qualifies as a mysql or a php question so I'm asking in both groups. I am pulling the results of a mysql query from my database and want to print the results into a two...
1
by: geckobtz | last post by:
Hi Guys, I am trying to build a page in ASP/MSsql with the aid of dreamweaver, the page contains total of 6 Questions, each question has 3 choices, of which one of the choice contains the right...
1
by: sherryjob | last post by:
Hi I wanted to display the results of a SP in excel The Sp returns 2 values - the count of no of records in 2 tables I got the results in a Recordset but when i tried to display it only the...
1
by: callsupport1 | last post by:
How can i open and display a power Point File with an extention of .ppt Thanks Steve
16
by: dougmeece | last post by:
Good day everyone, I have a database with 2 main forms. The first form is used to add records to the database and contains a command button that opens the 2nd form for records searching. On...
2
by: Amie | last post by:
Hi, how do you display the results of an sql query and display it onto the html form or html table Thanks
4
by: kstevens | last post by:
(Yes... i capitalized the S on purpose) I didnt know before today that dlookup only found the first result. I am actually trying to display the results of a query in a report, but there are...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.