Jump to content

tariq2009

Members
  • Posts

    11
  • Joined

  • Last visited

    Never

Everything posted by tariq2009

  1. Hi its ok thanks for your reply and help now i have used echo $id;[/code] it is picking the id number and the errors is gone now when i submit the changes it is giving me new error which is UPDATE Persons SET firstname='', lastname='', staffno='', line='', Sunday='201', Monday='', Tuseday='', Wednesday='', Thursday='', Friday='', Saturday='', Duty='', starttime='', finishtime='', WHERE id=0ERROR <?php $host="localhost"; // Host name $username="techhom1_test"; // Mysql username $password="pro176"; // Mysql password $db_name="techhom1_test"; // Database name $tbl_name="Persons"; // Table name // Connect to server and select database. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $firstname=$_POST['firstname']; $lastname=$_POST['lastname']; $staffno=$_POST['staffno']; $line=$_POST['line']; $Sunday=$_POST['Sunday']; $Monday=$_POST['Monday']; $Tuseday=$_POST['Tuseday']; $Wednesday=$_POST['Wednesday']; $Thursday=$_POST['Thursday']; $Friday=$_POST['Friday']; $Saturday=$_POST['Saturday']; $Duty=$_POST['Duty']; $starttime=$_POST['starttime']; $finishtime=$_POST['finishtime']; $id=$_POST['id']; // update data in mysql database $id = intval($_POST['id']); $sql="UPDATE $tbl_name SET firstname='$firstname', lastname='$lastname', staffno='$staffno', line='$line', Sunday='$Sunday', Monday='$Monday', Tuseday='$Tuseday', Wednesday='$Wednesday', Thursday='$Thursday', Friday='$Friday', Saturday='$Saturday', Duty='$Duty', starttime='$strattime', finishtime='$finishtime', WHERE id=$id"; echo $sql; $result=mysql_query($sql); // if successfully updated. if($result){ echo "Successful"; echo "<BR>"; echo "<a href='list_records.php'>View result</a>"; } else { echo "ERROR"; } ?> the above code to update but it is not and giving id0=error and not updating the database i have tried almost every thing :'( please see if you can spot any error i am sorry to annoy you but i am starter and trying my best with your help Thanks
  2. can someone please help me with this error Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/techhom1/public_html/rota/update.php on line 28 and online 28 the code is $rows=mysql_fetch_array($result); <?php $host="localhost"; // Host name $username="**"; // Mysql username $password="**"; // Mysql password $db_name="****"; // Database name $tbl_name="Persons"; // Table name // Connect to server and select database. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); // get value of id that sent from address bar $id=$_GET['id']; // Retrieve data from database $sql="SELECT * FROM $tbl_name WHERE id='$id'"; $result=mysql_query($sql); $rows=mysql_fetch_array($result); ?> <table width="400" border="0" cellspacing="1" cellpadding="0"> <tr> <form name="form1" method="post" action="update_ac.php"> <td> <table width="100%" border="0" cellspacing="1" cellpadding="0"> <tr> <td> </td> <td colspan="3"><strong>Update data in mysql</strong> </td> </tr> <tr> <td align="center"> </td> <td align="center"> </td> <td align="center"> </td> <td align="center"> </td> </tr> <tr> <td align="center"> </td> <td align="center"><strong>firstname</strong></td> <td align="center"><strong>Lastname</strong></td> <td align="center"><strong>Staff No</strong></td> </tr> <tr> <td> </td> <td align="center"><input name="firstname" type="text" id="firstname" value="<? echo $rows['firstname']; ?>"></td> <td align="center"><input name="lastname" type="text" id="lastname" value="<? echo $rows['lastname']; ?>" size="15"></td> <td><input name="staffno" type="text" id="staffno" value="<? echo $rows['staffno']; ?>" size="15"></td> </tr> <tr> <td> </td> <td><input name="id" type="hidden" id="id" value="<? echo $rows['id']; ?>"></td> <td align="center"><input type="submit" name="Submit" value="Submit"></td> <td> </td> </tr> </table> </td> </form> </tr> </table> <? // close connection mysql_close(); ?>
  3. Ok i have worked out how to add more days and lines now need lil help with stop adding information in time order i want it to add it by line order plus how to fetch sql to add staff number as the duties will stay same you can have look at it here http://proremotesupport.co.uk/rota/sampleschedule.php
  4. Hi can you please help me to add Sunday and Saturday and i want to add 30 lines for each day where i can fetch info from sql can you please help me with commands thanks
  5. Hi i liked the Lightweight PHP Schedule Maker sorry i am going to be little annoying but how can use it with the MYSQL and insert my data by mysql in each day of the week i hope you understand what i mean thanks for your help
  6. Thanks fortnox007 that helped a lot this what i did below Inserting into database below <head> <title></title> </head> <body> <form action="insert.php" method="post"> line: <input type="text" name="line" /> staff no: <input type="text" name="staffno" /> Firstname: <input type="text" name="firstname" /> Lastname: <input type="text" name="lastname" /> Sunday: <input type="text" name="Sunday" /> Monday: <input type="text" name="Monday" /> Tuseday: <input type="text" name="Tuseday" /> Wednesday: <input type="text" name="Wednesday" /> Thursday: <input type="text" name="Thursday" /> Friday: <input type="text" name="Friday" /> Saturday: <input type="text" name="Saturday" /> <input type="submit" /> </form> </body> </html> Insert code below <html> <head> <title></title> </head> <body> <?php $con = mysql_connect("localhost","******", "******"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("*****", $con); $sql="INSERT INTO Persons (line, staffno, firstname, lastname, Sunday, Monday, Tuseday, Wednesday, Thursday, Friday, Saturday) VALUES ('$_POST[line]','$_POST[staffno]','$_POST[firstname]','$_POST[lastname]','$_POST[sunday]','$_POST[Monday]','$_POST[Tuseday]','$_POST[Wednesday]','$_POST[Thursday]','$_POST[Friday]','$_POST[saturday]')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "1 record added"; mysql_close($con) ?> </body> </html> Display data <html> <head> <title></title> </head> <body> <?php $con = mysql_connect("localhost","*****","*****"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("t*****1_test", $con); $result = mysql_query("SELECT * FROM Persons"); echo "<table border='1'> <tr> <th>Staff No</th> <th>Line</th> <th>Firstname</th> <th>Lastname</th> <th>Sunday</th> <th>Monday</th> <th>Tuseday</th> <th>Wednesday</th> <th>Thursday</th> <th>Friday</th> <th>Saturday</th> </tr>"; while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['staffno'] . "</td>"; echo "<td>" . $row['line'] . "</td>"; echo "<td>" . $row['firstname'] . "</td>"; echo "<td>" . $row['lastname'] . "</td>"; echo "<td>" . $row['Sunday'] . "</td>"; echo "<td>" . $row['Monday'] . "</td>"; echo "<td>" . $row['Tuseday'] . "</td>"; echo "<td>" . $row['Wednesday'] . "</td>"; echo "<td>" . $row['Thursday'] . "</td>"; echo "<td>" . $row['Friday'] . "</td>"; echo "<td>" . $row['Saturday'] . "</td>"; echo "</tr>"; } echo "</table>"; mysql_close($con); ?> </body> </html> What i want is that all the week days to show allocated duties into it but how is the best way to create duties in database and stored with start time and finish time when i add the duty number it fetches the information in the day of the week i want to allocate it .Any tutorial or guide that will help me to do this task will be nice thanks .
  7. [/code] Hi //open the connection $conn = mysql_connect("localhost", "techhom1_test", "pro176"); //pick the database to use mysql_select_db("testDB", $conn); //create the sql statement $sql = "INSERT INTO master_name values ('', '$firstname')"; //execute if (mysql_query($sql,$conn)){ echo "Record Added!"; } else{ echo "Somethin went wrong"; } the code above is insert code and working with out any errors but when i am submitting text into data using method below it is sending echo back Somethin went wrong.I think i am confused with the write name of the user table database is ***_test my tables are duty_number master_name in this _test user i am trying to add first name in master_name field so here is the submit code <FORM ACTION=insert.php METHOD=POST> <P>text to add:<br> <input type=text name=master_name size=30> <p><input type=submit name=submit value=Insert Record></p> </FORM> My table below in Data base [code]Field Type Null Default Comments name_id smallint(5) Yes NULL name_dateaddedn datetime Yes NULL name_datemodified datetime Yes NULL firstname varchar(75) Yes NULL lastname varchar(75) Yes NULL can someone please look at the code and find the error for me Thanks
×
×
  • 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.