close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Formatting text retrieved from MySql db with php

Thread begun 1/04/2012 10:52 pm by maftouh | Last modified 1/05/2012 10:31 am by Jason Byrnes | 5949 views | 3 replies |

maftouh

Formatting text retrieved from MySql db with php

Hi. I'm working on Dreamweaver CS3 and using Mac OS X 10.4.11 (Tiger) with Safari 4.1.3 web browser

I'd like to know how to format data retrieved from a MySql Data base using PHP.
For Example, in a Basic Contact form, when i want to view the messages, i've used this code :

===================================================
<?PHP
mysql_connect("localhost", "root", "root") or die(mysql_error());
mysql_select_db("contact") or die(mysql_error());

$data = mysql_query("SELECT * FROM client")
or die(mysql_error());

$info = mysql_fetch_array( $data );
?>

<?php
Print "<table border cellpadding=3 align='center' bgcolor='#FFFFFF'>";
while($info = mysql_fetch_array( $data ))
{
Print "<tr>";
Print "<th bgcolor='#0066FF'><font color='#FFFFFF'>Full Name:</font></th> <td>".$info['fullname'] . "</td> ";
Print "<th>eMail :</th> <td>".$info['<br />email'] . "</td> ";
Print "<th>Phone:</th> <td>".$info['phone'] . "</td> ";
Print "<th>Subject:</th> <td>".$info['subject'] . "</td> ";
Print "<th>Message:</th> <td>".$info['message'] . "</td></tr>";
}
Print "</table>";
?>
===================================================

of course, it works. And now, i want to formate the text on the retrieving page : set a customized font, color, size and so forth. Because, when the messages are printed in an array, they look like this :

=========================================================
Full Name: myname eMail :my email Phone: 123 Subject: the subject Message: text
Full Name: myname 2 eMail :my email2 Phone: 1234 Subject: the subject Message: text
=========================================================

So, it is not nice any more. And also the long is the message, is the width the page will take. And some time it larger the page width and user have to scroll the web browser to left and right in order to see the rest of the message.
So, I'd like to know how can i customize the view of messages retrieved from my MySql Data Base, either using PHP, HTML or CSS, if possible.

Thank you for all

Sign in to reply to this post

Jason ByrnesWebAssist

I'm not sure i understand the question.

the example code you give above will format the information from the database. Your example code is doing exactly what you are asking how to do.

Sign in to reply to this post

maftouh

Thank you Jason for responding.
As well as you have seen, this sample of code make a small formating : it only formate the array and not the content.
i've submitted two images to explain well what i mean. One (labeled: Basic_view_) showing how the database content is printed with a simple formating of the array (like the cells blue colored); and the second one (labeled: customized_view) show how i'd like to formate the content retrieved from the database.
Of course, i've made the sample of the SECOND PICTURE in a text editor to sweet best what i mean.

I think it will be more explicit.

Sign in to reply to this post

Jason ByrnesWebAssist

Use Dreamweavers design view to recreate the layout you want using the same dummy data from your screen shoot.

once you have created the layout in dreamweaver, replace the dummy data with the code for the recrdset column.


for example, replace the email address with:
<?php echo($info['email']); ?>

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...