hi this question is linked to this post ive made in the mysql section. http://bytes.com/topic/mysql/answers...le#post3499253
simply i want to use a form to populate a table with the locations of images, thumbnails and their corresponding captions. i want to populate the table like this:
id image location thumbnail location caption
1 folder/image1.jpg folder/t/image1.jpg just a test
2 folder/image2.jpg folder/t/image2.jpg just the test
3 folder/image3.jpg folder/t/image3.jpg just to test
is it possible to loop php to insert data into more than one row in a mysql table like shown above?
Jul 14 '09
14 3767 dlite922 1,584
Recognized Expert Top Contributor
Dorm,
Don't worry, when i was learning PHP, if you had slapped me in the face then gave me the wrong answer, I'd still would have loved you for it :)
But that's just me, I love learning,
Dan
Dormilich 8,658
Recognized Expert Moderator Expert
yea, sometimes I wish I had a teacher for PHP… anyways, thanks Dan
Dorm the Worm *harhar*
apology accepted....bei ng new to php doesn't exactly help me in any case.
thanks for the tip, ill give it a try as well
ok ive done a test using prepared statements..... nice and fast but one problem....i dont know whether my loop is correct for this, it has worked when i done a multiple INSERT but only inserts 1 row with the prepared statements..
here is my code -
<?php error_reporting(E_ALL);
-
-
$returnURL = $_POST['returnURL'];
-
-
if(isset($_POST['create_xml'])){
-
-
// configuration
-
$dbtype = "sql";
-
$dbhost = "localhost";
-
$dbname = "theau10_resources";
-
$dbuser = "theau10_tawUser";
-
$dbpass = "auction10";
-
-
// database connection
-
$conn = new PDO("mysql:host=$dbhost;dbname=$dbname",$dbuser,$dbpass);
-
-
// query
-
$sql = "INSERT INTO flashGallery (id,imageLoc,thumbLoc,imageCap) VALUES (:id,:imageLoc,:thumbLoc,:imageCap)";
-
$q = $conn->prepare($sql);
-
-
foreach ($_POST['random_digit'] as $key => $random_digit)
-
{
-
$q->execute(array(':id'=>$random_digit,
-
':imageLoc'=>$_POST['imageT'][$key],
-
':thumbLoc'=>$_POST['thumbnailT'][$key],
-
':imageCap'=>$_POST['captionT'][$key]));
-
-
}
-
-
}
-
?>
-
problem solved....just had to change id to tempID for the project number and add a column id to auto increment
here is the final code -
<?php error_reporting(E_ALL);
-
-
$returnURL = $_POST['returnURL'];
-
$random_digit = $_POST['random_digit'];
-
-
// configuration
-
$dbtype = "sql";
-
$dbhost = "localhost";
-
$dbname = "theau10_resources";
-
$dbuser = "theau10_tawUser";
-
$dbpass = "auction10";
-
-
// database connection
-
$conn = new PDO("mysql:host=$dbhost;dbname=$dbname",$dbuser,$dbpass);
-
-
// query
-
$sql = "INSERT flashGallery (imageNo,tempID,imageLoc,thumbLoc,imageCap) VALUES (:imageNo,:tempID,:imageLoc,:thumbLoc,:imageCap)";
-
$q = $conn->prepare($sql);
-
-
foreach ($_POST['picT'] as $key => $value)
-
{
-
$q->execute(array(':tempID'=>$random_digit,
-
':imageNo'=>$value,
-
':imageLoc'=>$_POST['imageT'][$key],
-
':thumbLoc'=>$_POST['thumbnailT'][$key],
-
':imageCap'=>$_POST['captionT'][$key]));
-
-
}
-
?>
-
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Jason |
last post by:
I have a client that would like to have drop down menus added to a nav
bar that is generated from MySQL. Is it possible to have a dynamically
driven DHTML menu from MySQL?
example link
http://www.msnbc.msn.com/Default.aspx?p1=0
|
by: Robert Kattke |
last post by:
I'm designing a site for local music and entertertainment and have a
few ?s that need to be cleared up. Currently, I'm working on the Club
part and have a Contact Person form, and a Club form. For the Club
form, I'd like to have up to 4 Contacts with various roles, {Booking,
Manager, Owner, All}.
Ideally, I'd like to have a frameset and have Contact form filled out
1st, allowing me to set a cookie that would populate the...
|
by: Ward B |
last post by:
Greetings.
I'm somewhat new to this whole MySQL/PHP thing and need a little help.
My web hosting service uses phpMyAdmin and at the bottom of the screen
iis an area where I can upload a text file to populate a table.
I have a table named groups with two fields:
groups_id auto-increment primary
groups_name
|
by: kurty |
last post by:
Hello all,
I am currently working on a project (a web based database) which entails the use of HTML, PHP and MySQL. I am new to all of these languages and would like some assistance in solving the following problem that I have encountered:
The project entails ADDing ,EDITing, DELETing records from a web based database. However the main objective of this project is to allow users to perform queries on the data in the database and then view the...
|
by: prosad |
last post by:
hello,
Just solved a problem using Javascript onclick, can click on any cell in a dynamic table and it will pass the innerText object value to my form text field. parts of code given below:
<script type="text/javascript">
function select_cell(obj)
{
document.getElementById('complaint').value = obj.innerText;
document.getElementById('selected_form');
}
| |
by: xhermit |
last post by:
I'm creating a wiki-style website with a mysql database.
I'm not to this point yet, but I'm thinking ahead of when I'll
need to start populating the database. Obviously the point
is for users to populate it themselves, but I've been to
several travel wiki websites and it seems like they almost
share identical information. Is there some sort of central
data I could tap into? Or just wishful thinking? For
instance, lets say I wanted...
|
by: eihabisaac |
last post by:
Hi everyone
I'm using VS2005 C# with MySQL to do a windows application
i'm also using Devart for MySQL
i was able to populate a combobox from the database
but i really want to populate the other combobox based on the first combo value
|
by: eihabisaac |
last post by:
hi all
im using C# with mysql
i want to populate the menustrip items based on the select statement bellow
i can select the items from the table and show them but how to popule the MenuStrip
private void Form2_Load(object sender, EventArgs e)
{
textBox1.Text = general.profile.getX().ToString();
|
by: Philth |
last post by:
Hi there,
I've essentially got a form with several drop down, each populated by columns in various tables.
The populating bit works fine - the column rows appear as they should in the menu.
Ideally the user needs to make their selections, and enter the form into a new database table.
The problem is, when the selection is entered into the new table, only the first word of the string is entered. For example, the drop down may have...
|
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: 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...
|
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: 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...
| |