473,403 Members | 2,366 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

How do I insert specified time as a query?

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

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 1621
Markus
6,050 Expert 4TB
while($i=01:00; $i<=01:10; $i++){
$query= "INSERT INSERT INTO $January_Ad1 (Day, Time) VALUES ('1','$i')";
$result= mysql_query($query);
}

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($something < $somethingElse){
//execute code
}
[/php]
a FOR loop:
[php]
for($i = 1; $i < 100; $i++){
//eecute code
}
[/php]
Dec 22 '07 #2
Markus
6,050 Expert 4TB
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
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_query($query);
Dec 22 '07 #4
nvm, found that there were two inserts in the query.


thanks again though for the help!
Dec 22 '07 #5
Markus
6,050 Expert 4TB
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
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');...
10
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...
2
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. ...
2
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 - ...
8
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,...
2
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 :...
4
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...
6
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...
5
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
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,...
0
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...
0
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...
0
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,...
0
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...

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.