Current location: Hot Scripts Forums » Programming Languages » PHP » Question About Array Showing...


Question About Array Showing...

Reply
  #1 (permalink)  
Old 11-04-07, 04:30 AM
w2n's Avatar
w2n w2n is offline
Newbie Coder
 
Join Date: Jan 2006
Posts: 76
Thanks: 0
Thanked 0 Times in 0 Posts
Exclamation Question About Array Showing...

Hi everyone,

What I have is a multi-dimensional array in a plain text database, like follows...

Code:
Film Name | Director | Country | Synopsis | Runtime | Venue | Date | Time
Movie 1 | Director 1 | USA | Text goes here | 180 Minutes | London | November 11 | 6 PM
Movie 2 | Director 2 | Belgium | Text goes here | 90 Minutes | New York | November 13 | 4 PM
Movie 3 | Director 3 | India | Text goes here | 120 Minutes | Paris | November 17 | 8 PM

Now, with my code, I can show all these film details, in a HTML table, where I can put these data fields. This is DONE.

What I am trying to achieve is...

If I want to show 'all the films', for which the venue is LONDON (for example, total 5 films), or all the films to be shown on November 15, what should be the piece of code.

I know, there must be an use of 'in_array' or 'array_search', but I am not being able to finalize the shortest and simplest code to be used for this.

This should be an function, where I can mention, 'what field to be sorted' and what is the field value. To be more specific, if I want to show all the films in LONDON as the venue, the function should be like this...

films('Venue', 'London'); // To show all the films, in London

-OR-

films('Date', 'November 15'); // To show all the films shown on November 15.


Then, this function will return an multi-dimensional array, consisting of similar structure as the original and full array like above, and the function will return something like this (for London Venue)...

Code:
Film Name | Director | Country | Synopsis | Runtime | Venue | Date | Time
Movie 1 | Director 1 | USA | Text goes here | 180 Minutes | London | November 11 | 6 PM
Movie 32 | Director 32 | Belgium | Text goes here | 90 Minutes | London | November 14 | 4 PM
Movie 46 | Director 46 | India | Text goes here | 120 Minutes | London | November 17 | 8 PM
Notice, these are the films, where 'London' is common as 'Venue' field.

Please help me writing this small piece of code.

Thanks in advance,
__________________
SWAGATO GANGOPADHYAY
Founder/Owner/CEO
The Rozaleenda Group, Inc.



Last edited by w2n; 11-04-07 at 04:35 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 11-04-07, 07:08 AM
End User's Avatar
End User End User is offline
Level II Curmudgeon
 
Join Date: Dec 2004
Posts: 3,027
Thanks: 14
Thanked 35 Times in 33 Posts
This would be trivial to do in a real database, but in a plain text format it becomes much more complicated. Is there a reason you don't want to put this into a real database system?
__________________
I don't live on the edge, but sometimes I go there to visit.
-------------------------------------------------------------------------
Sanitize Your Data | Oracle Date & Substring Functions | Code Snippet Library | [url=http://www.codmb.com/Call Of Duty[/url]
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 11-04-07, 07:58 AM
Jay6390's Avatar
Jay6390 Jay6390 is offline
Code Master
 
Join Date: Apr 2007
Location: United Kingdom
Posts: 1,330
Thanks: 0
Thanked 0 Times in 0 Posts
I would suggest you use a foreach loop and add the rows to an array that correspond to the query however without seeing any code for how you have set up the multidimensional array i cant really expand on that

Jay
__________________
Useful Tutorials
[ PHP Video-1-2-3 ] [ MySQL 1-2-3 ]
For any php function reference type

www.php.net/FunctionName
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 11-04-07, 03:19 PM
w2n's Avatar
w2n w2n is offline
Newbie Coder
 
Join Date: Jan 2006
Posts: 76
Thanks: 0
Thanked 0 Times in 0 Posts
Dear everyone,

I wanted to use plain text database, as the film numbers are somewhere around 300. And, I thought, doing it in plain text database will be easier than MySQL, since I don't know MySQL much.

Anyway, I came with a solution on my own and it's working perfectly now. It is using in_array and preg_match and it's working fully, exactly like the way I wanted it.

Thanks again for all the help!
__________________
SWAGATO GANGOPADHYAY
Founder/Owner/CEO
The Rozaleenda Group, Inc.


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ')' Dr. Forensics PHP 3 07-15-06 04:54 PM
array question stealth04 C/C++ 4 05-17-06 03:35 PM
Serializing a set of arrays dannyallen PHP 2 10-11-04 04:04 AM
linking to iframe not working :( j0d JavaScript 5 01-19-04 09:14 PM


All times are GMT -5. The time now is 06:54 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.