I need to dispaly a user's multiple images in one entry.Right now,say if a user uploads 3 images,three entries for the same id display to match 3 images.
I only want 1 entry to display all of a user's related images like below:
Id
First Name
Last Name
Title
Image1
Image2
Image3
Currently I get;
1
First Name
Last Name
Title
Image1
1
First Name
Last Name
Title
Image2
1
First Name
Last Name
Title
Image3
My select code is as follows:
[php]
include 'Con.inc.php';
$query = "SELECT Members.first_n ame,Members.las t_name,Members. category,Member s.title,Members .message,Images .name,Images.ty pe,Images.size, Images.path FROM Members LEFT JOIN Images ON Members.member_ id=images.membe r_id";
$result = mysql_query($qu ery);
while(list($fir st_name,$last_n ame,$category,$ title,$message, $file,$Type,$Si ze,$path)= mysql_fetch_row ($result))
{
echo "first_name :$first_name <br>" .
"last_name :$last_name<br> <br>".
"category :$category <br><br>".
"title :$title <br><br>".
"message:$messa ge<br><br>".
"<img src='../FileDir/$path' alt='$first_nam e s profile photo' /><br>";
}
mysql_close($co nn);
?>
[/php]
Thank you very much for your response in advance!
11 4152
Hi,
if you want the output you desire, you can't read/write all the information in one single loop. I'm guessing you need at least one more loop where you go though all the images that a user with the specific userid has linked to him/her.
Hope this helps.
Cheers
Thank you MarkoKlacar,for your response !
I havent done this before so I have no clue how to add a conditioned second loop in my code above
Hi,
just to get an understanding of your database structure. The $path variable reads from the "Images.pat h" in the database. How is this connected to the user id?
As I see it, it's from .."Members.memb er_id=images.me mber_id", right?
Now what you could do is not select the images, but instead inside the while-loop you have execute one more query saying:
[PHP]$queryForMatchi ng = "SELECT Images.part FROM Images WHERE Images.member_i d = '$firstName'";[/PHP]
In the case above I'm assuming that the $firstName is the id used to map a user with his uploaded images.
After this you loop though the result that you receive and print out all the pictures.
Hope this helps.
Cheers
thanks for your help
"As I see it, it's from .."Members.memb er_id=images.me mber_id", right?"
Yes.
member_id is what links a user to their images,not $firstname (I just missed it above)
Hi Jankie,
did you solve your problem, was I clear enough in my previous post?
Cheers
Sorry for not updating you
Not yet really,do you mean a nested loop ?
If i understood you correctly,I have to delete the image selection info from the select statement(then I dont need the join statement,too) .Instead,I should include your query code inside the outer loop,correct ?
or how does your code fit in my code above ?
Sorry to sound dumb,didnt do it before
and thank you very much for your follow up ! Appreciate it.
Hi Jankie,
Yes I mean a nested loop. The nested loop goes through a new result array that was received from a new query where you select all the image.ids bellonging to a key that you're currently working with in the outer loop.
Hope I didn't confuse you with my mediocre description.
Let me know.
MarkoKlacar
Thank you very much indeed
No,no your description is fine
yes,I got it to work with a nested loop inside the second query.
But I had to remove the join code along with image selection info from first query.
they are both linked now but just a where clause after I have stripped the table name part from the columns in the query.
[php]
"SELECT first_name,last _name,category, title,message FROM Members WERE member_id=membe r_id";
[/php]
[php]
"Select name,type,size, path FROM Images WERE member_id=membe r_id";
[/php]
I am just concerned the 2 tables are not now technically linked
Again,I do appreciate your staying with me,thanks a lot !
Hi Jankie,
they are linked using the primary keys, member id in this case.
Cheers
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: kingofkolt |
last post by:
I have a directory of images, called "random". In it are the following
files:
1.gif
2.gif
3.gif
4.gif
I use this script to choose a random image and display it:
|
by: Mathias |
last post by:
Dear NG,
I currently ty to switch from matlab to python/scipy but have a lot of
trouble with images. What I need is a function for subsequently
displaying a number of 2D-matrices as an image.
I tried:
- Image.show() which is nice but slow and I don't seem to be
able to either close the window nor draw again to the same
window, so I end up with 100 pictures on the screen...
- scipy.xplt.imagesc() and scipy.plt.imagesc() crash
|
by: ZZZupan |
last post by:
http://www.naveur.navy.mil/default_test.asp
I have tried with some success reorganizing the code and putting it
all on one line. However for some reason I cannot get rid of the
space on the last line.
<!--#INCLUDE FILE="include.htm" -->
<%
' Get News Table Left Info
Dim NLConn
Set NLConn = server.CreateObject("ADODB.Connection")
|
by: RAllsopp |
last post by:
I have a client who would like to have several pictures associated
with one system. I have read about storing only the pathname to save
OLE overhead and have set-up a form for my client to browse/add one
picture at a time to a system. Now he would like to 'view' all of the
thumbnails associated with any system on a single form.
I can setup a main/subform scenario, but how do I show all of the
pictures as thumbnails. I was using the...
|
by: Wadim Grasza |
last post by:
I want to store and display (on a form or a report) multiple pictures
per
record in an access database. The pictures are not stored within the
database. They are stored as files and the database contains the paths
to the
pictures.
The database consists of two tables:
TABLE DATA
ID Name LastName
| |
by: Martin Jørgensen |
last post by:
Hi,
I don't understand these errors I get:
g++ Persort.cpp
Persort.cpp: In function 'int main()':
Persort.cpp:43: error: name lookup of 'j' changed for new ISO 'for' scoping
Persort.cpp:37: error: using obsolete binding at 'j'
|
by: Dave |
last post by:
I have an ASP 3.0 website on which the images are displaying intermittently.
In other words, when I request a page, the image is blank. There is no
missing image place marker (rectangle with a red X).
The location where the image should be is just empty.
The code is there to display the image as can be seen when you view source
in the browser
|
by: Confused but working on it |
last post by:
Just wanted to say thanks for the posts helping me make ths work. Added
a few comments and after the readdir used a pattern match to test for
..jpg, and seems to work fine on my test setup. Maybe I should test for
gif, tiff, and png... Anyway, here's the code:
<?php
//Open images directory
$dir = opendir("images");
//read files in the dir
while (($file = readdir($dir)) !== false)
//test to make sure jpg
|
by: dfm |
last post by:
Hi, I cant change the header to display images from a database. It's giving me this error :
Warning: Cannot modify header information - headers already sent by (output started at /home/content/d/f/m/dfmcons/html/secwhouse/index.php:18) in /home/content/d/f/m/dfmcons/html/secwhouse/index.php on line 71
Here is the code :
<?
mysql_connect("$host","$username", "$password");
mysql_select_db("secwhouse");
?>
|
by: javasachin |
last post by:
Dear Friends,
I have a requirement like this:
In my JSP Page, I want to display some dynamic Arrow Images. While clicking on each of these Arrow Images, I want them to expand and create some dynamic controls like TextBoxes, Checkboxes, DropdownLists etc. User can enter/ check/ select data in these controls and submit. While clicking the Arrow Images, it should collapse again (something like a tree)
I think we can’t use a treeview...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |