Jump to content

rajaahsan

Members
  • Posts

    24
  • Joined

  • Last visited

    Never

Everything posted by rajaahsan

  1. ya it is sure i have auto incremented checked in database and my id is primary id key but i dont understand what the problem is why my database jumble id's up and down...
  2. no boss, i have already auto increment checked in database on my primary key which is "id" but problem remains the same why is it happening as my data successfully been saved but only sequence problem distirb me please help guyz..
  3. HY every one , i am having problem with my phpmysql database , i save different values form form but when i save multi values at a time the values saved in database successfully but the sequence of my praimary id changes , e.g id firstname lastname dob 1 abc abc abc 3 abc abc abc 2 abc abc abc 4 abc abc abc 5 abc abc abc so own but as you see 2 must be before the value 3 so any one tell me what is the problem in database ?
  4. hy every one i have two files one is index.php and second insert.php as follow, index.php <html> <body> <form action="insert.php" method="post"> Time <input type="text" name="time" /> <input type="submit" /> </form> <?php $ctime = date('h:i:s A'); echo "Current time is : " . $ctime ; echo "<br>"; $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("time", $con); $result = mysql_query("SELECT * FROM time"); while($row = mysql_fetch_array($result)) { echo date('h:i:s A', strtotime($row['time'])); echo "<br />"; } mysql_close($con); ?> </body> </html> here is my insert.php file code, <?php $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("time", $con); $sql="INSERT INTO time (time ) VALUES ('$_POST[time]')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "1 record added"; echo "<br>"; echo "<a href='index.php'>Home</a>"; mysql_close($con) ?> this code work fine but the form which submit the value of time in database whos code is in index.php file above, i have to enter time in the form text field like this 17:00 and it save the value in database but, i want to enter time in the form text field like this 05:00 PM which automatically save the value in database as 17:00 what should i do with the code help me please thanks
  5. i mean to say that , code is working f9 know but , i have to putt the time value in this format in text box 17:00 i want to put 05:00 PM in text box which automatically save my time value in sql like 17:00
  6. thanks it worked but now tell me that i have to put the time like this 17:00 i want to enter time in like this 5:00 PM format as i view 5:00 PM
  7. Hy every one i have this two file code one is index.php and second is insert.php here is index.php code , <html> <body> <form action="insert.php" method="post"> Time <input type="text" name="time" /> <input type="submit" /> </form> <?php $ctime = date('h:i:s A'); echo "Current time is : " . $ctime ; echo "<br>"; $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("time", $con); $result = mysql_query("SELECT * FROM time"); while($row = mysql_fetch_array($result)) { echo $row['time']; echo "<br />"; } mysql_close($con); ?> </body> </html> here is insert.php code , <?php $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("time", $con); $sql="INSERT INTO time (time ) VALUES ('$_POST[time]')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "1 record added"; echo "<br>"; echo "<a href='index.php'>Home</a>"; mysql_close($con) ?> This code work fine but when it returns me the ouput in this format Time (inputbox) submit Current time is : 07:25:53 PM 10:55:00 10:55:00 i saved one value with 10:55 AM in my field box and one value with 10:55 PM but no effect what is the problem i want to display the output as like this, 10:55:00 AM 10:55:00 PM Hope you understand what i want... thanks
  8. Your are right that i am not an english speaker but i can understand very well but the php is little newer to me so thats why it creat problem to explain any body well let me explain my code , this i my insert.php file which takes simple values from user using form and form action is this php code....hope understand. <?php include ("connect.php"); //connect database sucessfully $selecteddate = $_POST['sdate']; // date variable set which comes from my form $sql1 = "select date from game1"; $query1 = mysql_query($sql1) or die(mysql_error()); while($row = mysql_fetch_assoc($query1)) // this is while code which i think may work well for me but unfortunately not { $rowdate = $row['date']; if($selecteddate == $rowdate) // compare values previously saved date in database with my new one { echo "Date already Exists"; } else { echo "Weldone there is no date"; } } ?> the problem is that which is minor , this code also work fine it displays my date values from database which i have already saved before ,this code displays again and again because of while loop ,what should i do with this code so that is just only search all the value from date field and display once not again and again...hope now you got my point....
  9. gizmola soory i didnt understand please guide me i have writen code also :'( thank you
  10. i have tryed this code before, while($row = mysql_fetch_assoc($query1)) { $rowdate = $row['date']; if($selecteddate == $rowdate) { echo "Date already Exists"; } else { // form insertion data code here which i have and working fine } } but when i do this my else part repeats hole and then show all the else values again and again...only on one value echo "Date already Exists" that matches my date value else repets its code again again for all values and displays again and again.
  11. i have php code, <?php include ("connect.php"); $selecteddate = $_POST['sdate']; $sql1 = "select date from game1"; $query1 = mysql_query($sql1) or die(mysql_error()); while($row = mysql_fetch_assoc($query1)) { $rowdate = $row['date']; // problem here i this while loop only compare my latest last value in database. i want a code here which search all the data in "date" field. } if($selecteddate == $rowdate) { echo "Date already Exists"; } else { // form insertion data code here which i have and working fine } SHINSTAR is online now Add to SHINSTAR's Reputation Report Post Edit/Delete Message
  12. thanks for your sweet help but now when i use, while { it repeats the same code again and again here....! i am confused here because i need to search only from database that the date selected by user exist already or not if it exist already then data must not be save in database.. }
  13. i have enters some data using form which submit data in sql table1 like this, Fields name in table -->> id First name Lastname Date data saved -->> 1 user 1 2011-05-10 2 user 2 2011-05-11 3 user 3 2011-05-12 now i dont want to duplicate date in database let say while inserting data using form, Firstname : ____________ Lasename : ____________ Date : ____________ (i dont want this date to b save if the date alredy exist in database, it should prompt user "Date already exist and to edit click here (this will be the link to that date which is already exist so that we can edit) " ) SAVE i user files , form.php , insert.php(so insert values in database) , so tell me what function should i use to solve my problem....
  14. thank you vvvvvvvvvvv much 4end....
  15. FIrst of all thank for replying..... my variables are as under $cdate = date("d-m-y"); // current server date $ctime = date("h:i:s"); // current server time i have upload sql database table as well in pic you can understand then.... [attachment deleted by admin]
  16. i just want to display the value for 30second as my code displays only for a second and then disapper till the next value comes and so own... as i have used while statement which check continuously the time value from database , so thats is why my value disappers is there any trick which i can perform i between this while loop code , while($row = mysql_fetch_array($re)) { // Beganing 1 include("variables.php"); echo "<br>"; echo $row['value']; // value to be displayed for 30Sec after displayed on site as in this condition it show for 1 sec and disappers. } //Closing 4
  17. please explain it more clearly... you are rite i want to display values all the time but when the specific time comes, i didnot get your point what should i do with this code, SELECT * FROM datatable WHERE time >= '$ctime' ORDER BY time ASC LIMIT 1 // what does this line will do now? explain this code ( ORDER BY time ASC LIMIT 1 ) what does it do? i just want to display the value not for 30second as my code displays only for a second.
  18. This is the php code i have wrote but i need some help....as this code is displaying my value from database when time(which is saved in database too) is equal to current server time. let say e.g : time saved in database is 6:00:00, so when current time is equal to database time which is 6:00:00 it then display my stored value(e.g 40 (int) ) from database. which is : 40 so i need help out here when the value shows : 40 on exact 6:00:00 (time) but disappear after a second i want to be display this value for 30 more sec.after that a new value from database will come and diplay as the time goes to 6:00:30 hope friend you will help me out soon thank you below is the code of php file. // First Connect to database echo "<meta http-equiv='refresh' content='20'>"; $link = mysql_connect("$dbhost","$dbuser","$dbpass") or die(mysql_error()); // Connection starts here mysql_select_db("$dbname") or die(mysql_error()); $sql = "SELECT * FROM datatable WHERE time = '$ctime' "; // simple sql example echo $cdate; echo "<br>"; echo $ctime; $re = mysql_query($sql) or die(mysql_error()); // Here's where you'll get an error if the SQL is invalid. while($row = mysql_fetch_array($re)) { // Beganing 1 include("variables.php"); echo "<br>"; echo $row['value']; // value to be displayed for 30Sec after displayed on site. } //Closing 4 mysql_close($link); // code ends here..:-)
  19. i just want a simple code which does this, 1. Takes my form values(values can be char,int e.g 10,20,30) and save them in database. 2. Then value that has been saved before, i want to be displayed those values when the specific time comes,e.g if server time is let say 10:00am display my value which is 10 , then when time is 10:30 display my second value automatically in to 20 and so on... note : i just have to enter my values(10,20,30,40...) one time let say for all the week from 10:00am to 4:00pm daily bases. but those values are to be displayed on there accurate time as explained earlier.
  20. what should i do if i want to display the record like this with data and time both, database value is 10,20,30,40 Site output should be like this let say, date-------------------time-------------------value 12-04-11--------------3:00 pm---------------10 12-04-11--------------3:30 pm---------------20 12-04-11--------------4:00 pm---------------30 12-04-11--------------4:30 pm---------------40 give me code thanks with comments
  21. i just want to display the values form database which i have saved before and just want to be displayed when specific time comes as i told above in e.g if i have stored some thing like value let say ( 10,20,30,40 and so on ) in database now i just want a php code to display it on site but on specific time only like this, i time = 10:00am display value = 10 when time = 10:30am display value = 20 when time = 11:00am display value = 30 and so own simple.
  22. Helloo ever one i need know In PHP the function giving the current time stamp value is time(). So we can write a line like below to get the current time stamp value. <? echo time(); ?> my Question is how to display any value on specific time( where value is stored in database )...
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.