Problem with PHP - MySQL Coding


Below the data(coloured red) is stored in my Database(MySQL) on particular field(Term). And also it has been viewed as same as i stored(by viewing data through Query).

Code: <Some Spaces> Name:
CYM <Some Spaces> Cayman Islands
CAN <Some Spaces> Canada
CHL <Some Spaces> Chile
CRI <Some Spaces> Costa Rica
BVT <Some Spaces> Bouvet Island
IRQ <Some Spaces> Iraq
AFG <Some Spaces> Afghanistan

(the Data is Stored, table like structure (code & Name) on single field(Term))

But i viewed the same data through PHP code. It will displayed like below.

CYM Cayman Islands
CAN Canada
CHL Chile
CRI Costa Rica
BVT Bouvet Island
IRQ Iraq
AFG Afghanistan

<No spaces were found between the code & name>

What have to do to display the same data via PHP as viewed in the database?
I think u understand what im trying to say…

Please help me out…

Thanks & Regards,

HTML doesn’t recognize additional spaces without using  .

You could try converting spaces to &nbsp entities.

str_replace(’ ', ’ ', $str);

That might work. Or you have to get a little more complex. The basic idea is you need to convert the spaces in your data into   when you display it on a web page.

If I understand you correctly, you want to use a html table to display your data in. It would make most sense. Read up on tables with

Best of luck!

Here is a quick and nasty KLUDGE which will make the CSS Purists cringe but it does work:)

  <title>John's KLUDGE</title>
  <style type='text/css'>
    #ww b {display:inline-block; width:4em}

<div id='ww'>
	<b>Code:</b>Name: 		<br />
	<b>CYM</b> Cayman Islands	<br />
	<b>CAN</b> Canada		<br />
	<b>CHL</b> Chile			<br />
	<b>CRI</b> Costa Rica		<br />
	<b>BVT</b> Bouvet Island	<br />
	<b>IRQ</b> Iraq			<br />
	<b>AFG</b> Afghanistan	<br />


Partial screendump

HTML and CSS purist cringing here : )

here is a quick and beautiful kludge which will make the html and css purists smile – and it does work

your terms here


I like your<pre KLUDGE very much and will try and utilise along with my dynamic PHP scripts.


Thanks cheesedude… it works good.:slight_smile: