473,813 Members | 3,014 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How do I insert specified time as a query?

16 New Member
while($i=01:00; $i<=01:10; $i++){
$query= "INSERT INSERT INTO $January_Ad1 (Day, Time) VALUES ('1','$i')";
$result= mysql_query($qu ery);
}

I want to insert 11 rows that say the Day is 1 and the time is incremented by 1 such that the time would read 01:00, 01:01, 01:02... 01:10.
Dec 22 '07 #1
5 1638
Markus
6,050 Recognized Expert Expert
while($i=01:00; $i<=01:10; $i++){
$query= "INSERT INSERT INTO $January_Ad1 (Day, Time) VALUES ('1','$i')";
$result= mysql_query($qu ery);
}

I want to insert 11 rows that say the Day is 1 and the time is incremented by 1 such that the time would read 01:00, 01:01, 01:02... 01:10.
What you are using there is incorrect.

i.e.
a while loop:
[php]
while($somethin g < $somethingElse) {
//execute code
}
[/php]
a FOR loop:
[php]
for($i = 1; $i < 100; $i++){
//eecute code
}
[/php]
Dec 22 '07 #2
Markus
6,050 Recognized Expert Expert
After changing a few things i got the code to work :)
The revised code:
[php]
<?php
for($i='01:00'; $i<='01:10'; $i++){
#$query= "INSERT INSERT INTO $January_Ad1 (Day, Time) VALUES ('1','$i')";
echo $i."<br />";
}
?>
[/php]
1. I changed the loop to a FOR loop.
2. 01:00 is not a valid interger, so i wrapped it with single qoutes to change it into a string.
3. Echoed out the string to show it works.

-- just uncomment the query line (remove the #) and give it a run

:)
Dec 22 '07 #3
cherryst152
16 New Member
that worked very well and thanks for the fast response! only problem i am still having is getting it to insert into the database. it prints it out fine separately, but it's not being queried into the database even after i added in the line $result=mysql_q uery($query);
Dec 22 '07 #4
cherryst152
16 New Member
nvm, found that there were two inserts in the query.


thanks again though for the help!
Dec 22 '07 #5
Markus
6,050 Recognized Expert Expert
nvm, found that there were two inserts in the query.


thanks again though for the help!
No problem my friend :)
Dec 22 '07 #6

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

Similar topics

1
3687
by: Matthew Paterson | last post by:
Ok I'm having a problem with a SQL insert going to a Access database...here is the connection code: // PHP db connection $db = 'C:\\Phpweb\\test.mdb'; $conn = new COM('ADODB.Connection'); $conn->Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=$db"); $query = $conn->Execute($sql); Here is the print out of the SQL:
10
2611
by: johnnyboy10017 | last post by:
I am having a hell of a time with what I think is a very simple query: It won't actually insert a new record into the specified table, but returns no error, in fact it returns "1" (or true) that the query was successful. Things to know: 1. id field is auto-incrementing primary key 2. Other queries SELECT, UPDATE, and DELETE all work no problem 3. INSERT works via phpMyAdmin 4. Query generated by phpMyAdmin and pasted into my PHP...
2
13401
by: george | last post by:
This is like the bug from hell. It is kind of hard to explain, so please bear with me. Background Info: SQL Server 7.0, on an NT box, Active Server pages with Javascript, using ADO objects. I'm inserting simple records into a table. But one insert command is placing 2 or 3 records into the table. The 'extra' records, have the same data as the previous insert incident, (except for the timestamp).
2
11738
by: Elvira Zeinalova | last post by:
Hei, We have 2 MS SQL SERVER 2000 installed on 2 different servers (2 separated machines). I am triing to connect them så that when one row is added to the table in the database in main server - then the same row is added to the same table in the second server database. I made the insert trigger on the table in the first server ( the second server is added as a linked server):...
8
2566
by: Josué Maldonado | last post by:
Hello List, I'm importing some data from Foxpro to Postgres, there is atable wich contains aprox 4.8 million rows and it size about 830MB. I uploaded it to Postgres using dbf2pg and worked fine, it tooks about 10-15 minutes. Now I'm inserting some data from that table to a brand new table in Postgresql, for that I'm doing insert into ... select from. The point is inserting this data from one table to another table in Postgresql took...
2
3213
by: Geoffrey KRETZ | last post by:
Hello, I'm wondering if the following behaviour is the correct one for PostGreSQL (7.4 on UNIX). I've a table temp_tab with 5 fields (f1,f2,f3,...),and I'm a launching the following request : INSERT INTO temp_tab VALUES (1,2,3)
4
1620
by: Tara83 | last post by:
Hi everyone i'm trying to put 2 sql queries in my code, i have two tables journal, journal1. one query will insert values in the journal table and the othe query will insert value in the journal1 table <?php $self = $_SERVER;
6
3479
by: rn5a | last post by:
During registration, users are supposed to enter the following details: First Name, Last Name, EMail, UserName, Password, Confirm Password, Address, City, State, Country, Zip & Phone Number. I am using MS-Access 2000 database table for this app. Note that the datatype of all the fields mentioned above are Text. Apart from the above columns, there's another column in the DB table named 'RegDateTime' whose datatype is Date/Time which is...
5
13537
by: sticky | last post by:
Hi I need to be able to lock a table against INSERT and UPDATE, but not SELECT, for the duration of a transaction. The transaction will be defined at the application level in c#, and then use stored procedures to make multiple selects and then an insert. What is the best way of doing this? Description of the system:
0
9734
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...
0
10669
Oralloy
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...
0
10408
jinu1996
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...
1
10426
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
9225
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7686
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
6897
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
5570
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...
3
3030
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.