473,387 Members | 1,592 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,387 software developers and data experts.

Text Wrapping Db Query

16
Ok Mods got another test for ya.. Since I know you are good at this stuff maybe you can help me out again..

I started getting my pages the way I wanted them to look last weekend, and got pretty far in what im trying to achieve basically, but I have a text issue now.

The text that I am putting into the db and the echo'ed text are running off the page and not staying in the table like I wanted. I tried many different ways of fixing it including using css to try and control it and using the table size to control it..

What should i add to my pages to fix the issue? and most importantly should I do it when I write it to the db (if possible) or should I do it when I print it out on the website.. here is what it is doing on the view page

http://www.elitegamers.us/Database_Test/view.php?id=27

here is the page that I am using to call the text from im sure you remember the pages pretty well since you helped me with the issues on the view page.

http://www.elitegamers.us/Database_Test/admin.php

feel free to add test items to the db and see how it reacts

The Code for the View.php
Expand|Select|Wrap|Line Numbers
  1.  
  2. <link rel="stylesheet" href="list.css" type="text/css"><center>
  3. <?php
  4.  
  5. $id = (int) $_GET['id'];
  6.  
  7. // change the username and password
  8. $db = mysql_connect("localhost", "User Name", "password");
  9.  
  10. // change the db name
  11. mysql_select_db("test_db",$db);
  12. $result = mysql_query("SELECT * FROM items WHERE id=$id",$db);
  13. $row = mysql_fetch_array($result);
  14. $wrappedtext = wordwrap;
  15. // make these any rows in the table that you want to show
  16.  
  17. echo " <table border='1'>
  18.  
  19.   <tr>
  20.     <th><h2>".$row["item_name"];
  21. echo "
  22.  <tr>
  23.     <td>
  24. </td></tr>
  25.   <tr>
  26.     <td>Location Found: ".$row["item_loc"];
  27. echo "</td></tr>
  28.   <tr>
  29.     <td>Properties: ".$row["prop"];
  30. echo "</td></tr>
  31.   <tr>
  32.     <td>Description: ".$row["description"];
  33. echo "</td></tr>
  34.   <tr>
  35.     <td><br>
  36.     <br></td></tr>
  37.   <tr>
  38.     <td height='30'><br></td></tr></table>";
  39.  
  40. ?>
  41. </center>
  42.  
  43.  
The coding for this and what I had before are pretty similar, just a few mods to the layout and added a few more items to it.

Let me know whats up and thanks again.

Laz
Sep 14 '07 #1
7 1870
ak1dnar
1,584 Expert 1GB
The problem is with your table properties. you have not specified the table width, height and <td> widths. this is HTML issue, not php. ask the question in the HTML/CSS forum.
Format your table with the table properties.
Sep 14 '07 #2
Lazoris
16
I tried that using the css for this page doesnt seem to help unless it has to be actually on the page and not in the css. if thats the case then I'm just a moron.
But, I just tried doing it directly in the page with no results what so ever. The text just has a mind of its own.

I'm thinking the solution is not html based at all. I havent been working with db stuff too much and have not played with this stuff in a few years but I know how to use html very well.

I think the solution is probably something to do with writing the code as it inserts the text into the db inserting breaks as they would appear in the input box used to input the data from the website. Or, forcing it to break the word into pieces small enough to fit into the page.

Have to keep in mind that the words running in the discription is actually one word, that is running off the page not many different words. And when it is many different words it sticks to the table size and doesnt break free.

So this tells me its the one run on word issue that I need to fix not the table properties. The tables are working as they should but the echo of the one word is telling it to ignore the table size since its one big word for some reason.

I'm slow but not completely out of it lol...

Laz
Sep 14 '07 #3
gregerly
192 Expert 100+
I tried that using the css for this page doesnt seem to help unless it has to be actually on the page and not in the css. if thats the case then I'm just a moron.
But, I just tried doing it directly in the page with no results what so ever. The text just has a mind of its own.

I'm thinking the solution is not html based at all. I havent been working with db stuff too much and have not played with this stuff in a few years but I know how to use html very well.

I think the solution is probably something to do with writing the code as it inserts the text into the db inserting breaks as they would appear in the input box used to input the data from the website. Or, forcing it to break the word into pieces small enough to fit into the page.

Have to keep in mind that the words running in the discription is actually one word, that is running off the page not many different words. And when it is many different words it sticks to the table size and doesnt break free.

So this tells me its the one run on word issue that I need to fix not the table properties. The tables are working as they should but the echo of the one word is telling it to ignore the table size since its one big word for some reason.

I'm slow but not completely out of it lol...

Laz
I'm fairly certain that a browser will render one line of text with no breaks, just as it is doing. Is that one line really neccessary? You mentioned that when it's regular text it's fine. I would suggest adding real content and see how your design holds up. Or if that line is neccessary, add a space or two for the text to wrap.

Greg
Sep 14 '07 #4
ak1dnar
1,584 Expert 1GB
If you are using a "singleword" as your dbcontents, you can try such a thing like this. There might be some other ways to wrap your lengthy "single word".

check this out:

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $text = "String1String2String3String4String5String6String7String8";
  3. $splittedString = implode(' ', str_split($text,14));
  4. ?>
  5. <table width="300" border="0" cellspacing="0" cellpadding="0">
  6.   <tr>
  7.     <td width="150"><?php echo $text; ?></td>
  8.     <td width="150"><?php echo $splittedString; ?></td>
  9.   </tr>
  10. </table>
  11.  
[EDIT:
There might be a bug with the forum software. on the first line on the php code "String8" has splitted.
]
Sep 14 '07 #5
Lazoris
16
ok thanks ajax. That will work I think.. and no its not really neccessary, but I'm trying to learn so i create problems just to solve them just in case I ever run into the problem ill have a better idea on how to solve it.

Thanks

laz
Sep 14 '07 #6
ak1dnar
1,584 Expert 1GB
Good luck ! Hope to see you again "shortly"! :)
Sep 14 '07 #7
gregerly
192 Expert 100+
ok thanks ajax. That will work I think.. and no its not really neccessary, but I'm trying to learn so i create problems just to solve them just in case I ever run into the problem ill have a better idea on how to solve it.

Thanks

laz
That's a great way to do things, and I applaud your desire to learn more. Let us know if we can help you again!

Thanks,

Greg
Sep 14 '07 #8

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

Similar topics

0
by: Ian Ward | last post by:
I hope to add support for multi-byte encoded and bidirectional text to my curses-based UI library: http://excess.org/urwid/ I would like to support whatever encoding the user likes. Are there...
1
by: Buddy | last post by:
Hello, Does anyone know how to stop labels from wrapping text. If the text is to long for the label then I want it to hide the text just like out the TextBox control works. Thanks,
5
by: le_mo_mo | last post by:
Hi, I am trying to have one label on a form with multi line display of the results from a database query. so my query looks like Select FirstName+" "+LastName+"\r\n"+Address as Info I want...
63
by: John Salerno | last post by:
I know there's a request for a good IDE at least once a week on the ng, but hopefully this question is a little different. I'm looking for suggestions for a good cross-platform text editor (which...
6
by: Markus Ernst | last post by:
Hi Searching for a possibility to display some text with preserved white space and line breaks, but with long lines being wrapped, I found this CSS declaration, which I found helpful: pre {...
7
by: Leon | last post by:
Hi, I'm creating a python script that can take a string and print it to the screen as a simple multi-columned block of mono-spaced, unhyphenated text based on a specified character width and...
3
by: bpd | last post by:
The text in my labels are now wrapping at runtime when they were not previously. In design mode, the text display fines. Did I accidentally change a setting? I implemented AJAX (appeared to be...
2
by: davidcm | last post by:
Last week, I found some code on-line that allows me to send email via SMTP from my VB 6.0 application. I had to add the Winsock control to the project and add the code that performs the SendData...
1
by: Leviathan via AccessMonster.com | last post by:
I'm trying to export an Access table to a pipe-delimited text file (with no text qualifier) and it keeps wrapping the text for one of the tables. None of the fields are particularly long, so I'm...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...

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.