Jump to content

Recommended Posts

Hi so I'm trying to get a string of letters to print: abdfgkerhwkjhkwjher as the result of a query for each letter's ID.

 

it looks like this in the database:

n3_1, a

n3_2, b

n3_3, d

and so on...

 

$num3 = mysql_query("SELECT * FROM segment WHERE id LIKE 'n3%' ") or die(mysql_error()); 

 

while($row = mysql_fetch_array( $num3 )) {

$number3 =  $row['base'];

echo $number3;

}

 

This shows the string from the column "base" fine.

 

so I get "abdfgkerhwkjhkwjher"

 

However, when I try to query outside the php header code

 

Blah: <?php echo $number3 ?><br>

 

I only get the last letter of the string of letters so it prints

 

Blah: r

instead of Blah: abdfgkerhwkjhkwjher

 

Any idea what could be the problem?  :shrug:

Link to comment
https://forums.phpfreaks.com/topic/202540-mysql-query-string-doesnt-work/
Share on other sites

Actually I have an additional question--

 

When the string of letters prints, instead of breaking at the end of the DIV or even at the browser it just continues as a long unbroken string...

 

instead of RGQERGREGERGERGERGERGJUTWEONHEI

it should be like

 

RQHIEWRHEWR

WERWERWERWE

WERWERWEWWE

 

within the contstraints.

 

But I can't put <BR>s because they is coming from the database and I have no idea where the line should break. Any solutions?

So you want to split the character string every 11 characters?

 

Do something like this:

<?php
while($row = mysql_fetch_array( $num3 )) {
   $number3 .=  $row['base'];
}

echo implode("<br>\n",str_split($number3,11));
?>

 

Ken

No, that was an example, is there any way to have the string split in accordance with the space available not the characters? (linebreak)

 

I am producing something like this

 

CONSTANT [variable] CONSTANT [variable]

CONSTANT CONSTANT [variable]

 

and all the variables aren't the same length (using javascript to modify to variables).

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.