473,787 Members | 2,938 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

mysql query split into array

55 New Member
Hi All,
I fetched a sequence from my database into mysql_query and then I want to split in the group of 60 and print it. I am using while loop and pushing into array and then trying to split it and print it on the web page but its nor working????

here is the code:
Expand|Select|Wrap|Line Numbers
  1. $res_fasta = mysql_query($fasta) or die('Query failed: ' . mysql_error());
  2.  
  3. while($seq = mysql_fetch_array($res_fasta))
  4. {
  5.     array_push($arr,"{$seq['sp_fasta']}");
  6. }
  7.  
For example: if the sequence is of 500 charecters and then i am trying to print it 60 charecters per line till the end of the sequence.
but when i echo the count in array ite gives me 1 as the value???

confused, any help....

thanks
kumar
Sep 14 '07 #1
5 4576
Atli
5,058 Recognized Expert Expert
Hi kumar,

Have you considered using the substr() function? Or maybe the wordwrap() function?

P.S Please use [code] tags when posting code!
Sep 14 '07 #2
kumarboston
55 New Member
Thanks Atli for your help..

the wordwrap is working and i think I will also try with substr...

thanks once again for the help....

kumar
Sep 14 '07 #3
Atli
5,058 Recognized Expert Expert
Glad I could help :)
Please don't hesitate to post again if you have any more questions or problems we can help you with!
Sep 14 '07 #4
kumarboston
55 New Member
Thanks,
I am able to generate the string of 60 characters in each new line but the edges are not smooth, i tried to use HTML "align = justify" attribute but no success.
here is the output:
MRPSGTAGAALLALL AALCPASRALEEKKV CQGTSNKLTQLGTFE DHFLSLQRMFNNCEV

VLGNLEITYVQRNYD LSFLKTIQEVAGYVL IALNTVERIPLENLQ IIRGNMYYENSYALA

VLSNYDANKTGLKEL PMRNLQEILHGAVRF SNNPALCNVESIQWR DIVSSDFLSNMSMDF


each line has 60 characters but the edges are not smooth....any help in this case....


thanks
kumar
Sep 15 '07 #5
Atli
5,058 Recognized Expert Expert
This can be fixed by using the right font. Like Courier New, for example.
Sep 15 '07 #6

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

Similar topics

0
5771
by: Phil Powell | last post by:
The table already has a fulltext index and from there I can use the MySQL fulltext search query to get results as well as the relevancy score. The problem I have is that MySQL has a default setting whereby the minimum amount of characters is 4 for a search. Being that we're government and full of TLA (three-letter acronyms), that is not practical, and furthermore, the app I'm building must be fully portable, so having MySQL tweaked...
1
2560
by: Cern | last post by:
Is it somebody out there who has made a migration from an Oracle server to an MySQL server?? The scenario is as simply: I've got a Oracle 8 server with a database with content that I want to transfer to a MySQL database. No special data, constraints etc that MySQL not will handle. My solution is to reverse engineer the database from ERStudio and then produce a SQL script that will insert the data into the MySQL engine. But I can't do...
9
1880
by: elyob | last post by:
Hi, I'm looking at storing snippets of details in MySQL about what credit cards a business excepts. Rather than have a whole column for Visa, another for Amex etc ... I am looking at having a column called payment types and inserting multiple codes ... e.g. ViAmBcCa Is this a good way of doing things? To me it'd be a lot cleaner and limit amount of Db work to be done. Is this a sensible way in your opinion? What's the best way of...
3
1801
by: Stephen Preston | last post by:
I can't get an $array to be used as a select query on a mySQL database. I have a 'parts list' which displays on a page (works fine) and is a form. At the end of each row is a input type='text' (quantity) cell with a default 0 The quantity can be altered. At the bottom of the table (form) is a submit to basket Button echo "<form action='basket.php' method='POST'>\n";
7
2735
by: Daz | last post by:
Hi. I am trying to select data from two separate MySQL tables, where I cannot use join, but when I put the two select queries into a single query, I get an error telling me to check my syntax. Both of the queries work fine when I use them to query the MySQL server directly. My guess is that the MySQL extension only expects a single resource back from the database, but get's several, or that it just checks the statement first, and decides...
12
4448
by: mantrid | last post by:
Hello Can anyone point me in the right direction for the way to read a text file a line at a time and separate the fields on that line and use them as data in an INSERT to add a record to a mysql table. Then read the second line in text file and repeat. Thanks for your time Ian
10
2650
by: Lloyd Harold | last post by:
I'm very new to PHP and attempting to put together a simple script for retrieving MySQL data of personal records. The MySQL table I'm using consists of: 0: id 1: name 2: location (an integer relating to a separate table of locations). 3: details
21
3708
by: bruno_guedesav | last post by:
I've made a function to fetch all results as an array of result- arrays. Getting the result arrays is easy, via mysql_fetch_array, and function itself is quite simple, as follows: function db_query($db, $query) { $result = mysql_query($query, $db); $res_array = array(); if ($result) //it is a search
2
16985
by: poreko | last post by:
I am connecting to my database using Object oriented PHP. My query is returning results but at the end of my table,at the bottom of the page I keep having this error when I run my program: Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in C:\xampp\htdocs\mysql_class_2.php on line 45. Can anyone help me? The following is my PHP class: <?php class mysql {...
1
10110
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9964
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8993
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7517
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6749
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5398
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5535
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4069
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3670
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.