| | |||||
| ||||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | THREAD STARTER #1 (permalink) |
| CEO ![]() Join Date: Jun 2005 Location: Tennessee
Posts: 1,894
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | Returning MySQL data in PHP array via function. I am creating a function and I'm coming to a bit of an issue. In the function i need to return ordered data into an array and return that array via a function. I have 3 columns on each row I have to return. Then i need to display them using the foreach loop. Im a bit new to arrays.. any help..
__________________ GIFTARD.com | CSDATE.com | INVOLVEX.com | SYATCH.com |
| | |
| | #2 (permalink) |
| NamePros Expert Join Date: Nov 2003 Location: Scotland
Posts: 5,074
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | What have you done so far? also which mysql function are you using to retrieve the data?
__________________ Manage your portfolio using my new Domain Portfolio Management script. Securing Your Domain Name From Theft |
| | |
| | THREAD STARTER #3 (permalink) |
| CEO ![]() Join Date: Jun 2005 Location: Tennessee
Posts: 1,894
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | im trying to make a message box. im using the mysql array. what exactly im trying to do is take the mysql results and put them in an array. ex subject message id and sender. Then i want to expand the results outside of the custom php function.
__________________ GIFTARD.com | CSDATE.com | INVOLVEX.com | SYATCH.com |
| | |
| | #4 (permalink) |
| Tech Support Join Date: Mar 2005
Posts: 4,944
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | So if I am understanding you correctly, something like this? PHP Code: |
| | |
| | THREAD STARTER #5 (permalink) | ||||
| CEO ![]() Join Date: Jun 2005 Location: Tennessee
Posts: 1,894
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
__________________ GIFTARD.com | CSDATE.com | INVOLVEX.com | SYATCH.com | ||||
| | |
| | #6 (permalink) |
| NamePros Expert Join Date: Nov 2003 Location: Scotland
Posts: 5,074
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | it retrieves the data from the database in and puts it into a multidimensional array. Each row in the database is a row in the array with a key that matches the ID. Each row in itself is an array with the following keys: id sender subject message The value of course for each is the data pulled from the the row. If you want to see it in the raw form within the array you could always do: print_r(messages);
__________________ Manage your portfolio using my new Domain Portfolio Management script. Securing Your Domain Name From Theft |
| | |
| | THREAD STARTER #7 (permalink) |
| CEO ![]() Join Date: Jun 2005 Location: Tennessee
Posts: 1,894
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | gotcha.. i understand now.. i was trying to put it into a multidimensional array ---------- Post added at 07:20 PM ---------- Previous post was at 07:15 PM ---------- several*
__________________ GIFTARD.com | CSDATE.com | INVOLVEX.com | SYATCH.com |
| | |
| | THREAD STARTER #8 (permalink) |
| CEO ![]() Join Date: Jun 2005 Location: Tennessee
Posts: 1,894
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | okay.. i uploaded it and everything, but for some reason its only displaying one row.. this is what i have. using print_r i only get one result, so for some reason its only passing one var in the array. PHP Code:
__________________ GIFTARD.com | CSDATE.com | INVOLVEX.com | SYATCH.com
Last edited by Ray; 07-24-2011 at 09:05 AM.
|
| | |
| | #9 (permalink) |
| NamePros Member Join Date: Aug 2008 Location: Solar System \ Earth \ Ukraine \ Kiev
Posts: 43
![]() | First of all, you should edit your code to this: Code: ...
$messages["{$result[id]}"] = $result;
... ????: NamePros.com http://www.namepros.com/showthread.php?t=723956 Then, you should be very careful about your table fields. Watch this: 1) Code: $messages["$result[id]"] = $result 2) Code: $sql = "select * from messages order by msgid ASC"; 3) Code: echo "Sender: $data[uidsen] ... Is this an error, or you really need all these three id's?
__________________ Tired playing Freecell, Klondike or Spider? Discover 800 solitaire games at SolitairesUnlimited.com and play'em all! |
| | |
| | THREAD STARTER #11 (permalink) |
| CEO ![]() Join Date: Jun 2005 Location: Tennessee
Posts: 1,894
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | sweet.. it works.. thanks everyone
__________________ GIFTARD.com | CSDATE.com | INVOLVEX.com | SYATCH.com |
| | |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| [4HIRE] PHP / MySQL / Javascript - Frameworks and OOP | alecksmart | Developers For Hire | 0 | 06-24-2011 12:47 AM |
| Domainate Weekly 6/9: SeniorsGroups(.)com, MigraineRemedies(.)org + 28, < $130 each | Domainate.com | Domains For Sale - Fixed Price | 1 | 06-13-2011 11:40 AM |
| Great Scripts for Sale With Resale Rights! | Zeeble | Scripts For Sale | 20 | 01-04-2006 01:39 AM |
| Tutorial: How to Install Apache2 MySQL and PHP on Windows | deadserious | Webmaster Tutorials | 35 | 09-21-2005 09:46 PM |
| Tutorial: Getting Started With MySQL (The Basics) | deadserious | Webmaster Tutorials | 3 | 04-18-2004 01:17 PM |