473,788 Members | 2,807 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Retrieve an image based on mysql_insert_id in its name

58 New Member
Hi and wish all moderators and members are doing well i
Back with a question after a long while,hope to find the valuable typical support from thescripts people and members.

My host does not offer foreign key feature on tables,so what I did is stick the corresponding submission id in the member's uploaded file when renaming the file.

Each member can upload up to 6 files.

Now,I'm clueless how to retrieve those matching images(or just 1 image) based on the corresponding mysq_insert_id in the image name.

Needless to say I would be extremely grateful to the person(s) who can share me the way(if any) to do it.

Many thanks in advance.


The relevant pieces of code below:


[php]
include 'Con.inc.php';

$sql = "INSERT INTO members (member_id,firs tname,lastname, category,title, message) VALUES ('$member_id',' $firstname','$l astname','$cate gory','$title', '$message')";

$member_id=mysq l_insert_id();
$newfilename = $original_name. $filename[$x].$member_id.'.' .$filename[$x+1];

$sql = "INSERT INTO images (imagename,imag etype,imagesize ,image_data) VALUES ('$newfilename' ,'$imagetype',' $imagesize','$i mage_data')";
[/php]

As you can see the images are in a second table(1member=6 images)
Nov 17 '07 #1
2 1531
ak1dnar
1,584 Recognized Expert Top Contributor
Hi there,
You should add the member id with each image record in the in your image table. then you can use MySQL "joins" to retrieve them easily.

members table
<1001> <name>
<1002> <name>

images table
<1> <image_records> <1001>
<2> <image_records> <1001>
<3> <image_records> <1001>
..........
..........
<7> <image_records> <1002>
Nov 17 '07 #2
Jankie
58 New Member
Thank you so much ajaxrand !
Nov 19 '07 #3

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

Similar topics

0
2398
by: kain | last post by:
hi there, I'm currently converting a MySQL application to PostgreSQL, and I hacked this app to support PEAR::Db . after some good coding days, I've found a problem: mysql_insert_id on pear::db . I've those two piece of code, the first is part of a class: --------- function connect($layer,$host,$db_port,$db_name,$user,$pass) { $dsn = "$layer://$user:$pass@$host:$db_port/$db_name";
1
1909
by: yawnmoth | last post by:
how could i reduce the following piece of code: for ($num=0;$num<50;$num++) { mysql_query($db,"INSERT INTO whatever (stuff) VALUES (somevalue);"; mysql_query($db,"INSERT INTO sometable VALUES (".mysql_insert_id().");"; } to something where only two sql queries are made (as opposed to 100?). ie. where the first line could be converted to something like this:
0
955
by: Mevar81 | last post by:
Hi to all.I have a big problem.I have a propertygrid im my application to configure some control.I want to change runtime the image of a control and store the name of the file that holds the image chosen.Anyone know how to retrieve the name of the image chosen with the propertygrid control.I've already tryed with the ImageConverter it returns only the type (System.Drawing.Image).I don't want to save everytime the image chosen.
2
1865
by: FayeC | last post by:
I have created a site in Joomla with a login (no self registration, users are provided with username and password by the admin). The users are supposed to login to a specific page where they can see 4 images. I have the following code: <?php // define directory path $dir = "images/user1/"; // iterate through files
6
4691
by: opt_inf_env | last post by:
Hi, I would like to insert a data (row) into database (MySQL) and than to generate file whose name contains the ID of the inserted row (ID is declared as AUTO_INCREMENT). I wanted to extract ID by mysql_insert_id() function. However, the problem is that my web site can visit many users and many of them can initiate the describe procedure. It can happen that between the first user inserts something into database and executes...
2
2586
by: SueA | last post by:
Can anyone help me with the code to retrieve the name of the table that a control on a form (that's built off a query) refers to? For instance: qryMfrsAndBrands is based on the tables: tblBrands and tblMfrs formMfrsBrands is based on qryMfrsAndBrands fieldBrandName is on the form and comes from tblBrands via qryMfrsAndBrands.
2
4134
by: Adam Teale | last post by:
hey guys Is there a builtin/standard install method in python for retrieving or finding out an image's dimensions? A quick google found me this: http://www.pythonware.com/library/pil/handbook/introduction.htm but it looks like it is something I will need to install - I'd like to be able to pass my script around to people without them needing any
4
2313
chumlyumly
by: chumlyumly | last post by:
Hi - I'm working with PHP5 MySQL Mac OSX I've developed two pages where a user can input his/her info, which goes to a MySQL database. The first page is supposed to pass the newly created 'member_id' (which is an auto-increment field in the 'members' table) to the second page, where I have records going into another table that uses 'member_id' as a foreign key. I've downloaded and used the Dreamweaver Server Behaviour...
7
2689
by: =?Utf-8?B?UVNJRGV2ZWxvcGVy?= | last post by:
I have a C# logging assembly with a static constructor and methods that is called from another C# Assembly that is used as a COM interface for a VB6 Application. Ideally I need to build a file name based on the name of the VB6 application. A second choice would be a file name based on the # COM interface assembly. I have tried calling Assembly.GetCallingAssembly() but this fails when I use the VB6 client. Is there a way to get this...
0
9656
marktang
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...
1
10118
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
9969
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...
1
7519
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
6750
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
5403
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
5538
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3677
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2897
bsmnconsultancy
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...

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.