Jump to content

zed420

Members
  • Posts

    160
  • Joined

  • Last visited

    Never

Everything posted by zed420

  1. Hi All I wonder if someone can help me I've created a table but I want it to start at 101 and not from 0, How do i do this? Thank you zed
  2. Hi ALL Can anyone tell me how can I use alert error messages without wiping out all the information that user has put in. eg. I have a form if user makes mistake inserting his/her password an error messages pop up (alert box) but it wipes out rest of the form too. Is there any way I can keep rest of the inserted information. Thanks Zed
  3. Thanks that has got rid of my error message but it still not Updating every time I press submit button it takes off the background color that I'm using.
  4. Thanks for replying but Where am I going wrong??? it no different than 2nd line so why error there and not in 2nd line? You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'blockbook.cust_address = 'Cancel' blockbook2.cust_address1 = 'Cancel' W' at line 3 Anyone any suggestions please. Thanks Zed
  5. Hi ALL Can anyone help me on this query please, all I'm trying to do is Update three tables in a same query. if($_POST['submit']) { foreach($_POST as $job_id) { mysql_query("UPDATE job_tb,blockbook,blockbook2 SET job_tb.cust_address = 'Cancel' blockbook.cust_address = 'Cancel' blockbook2.cust_address1 = 'Cancel' WHERE job_tb.job_id = '$job_id' AND blockbook.job_id = '$job_id' AND blockbook2.job_id = '$job_id'"); if (mysql_affected_rows() > 0) { // execute query print "<font color=red size=2> No. = $job_id has been Updated</font><p>"; } } } Thanks Zed
  6. Hi First Query validates if there is a 'id' in user table else error the Second one I'm trying to validate and failing baddly if the user is inserting his own 'id' if not error msg. Thanks Zed
  7. Anyone any suggestions please. ??? zed
  8. Yes even if you insert wrong user_id. Zed
  9. Yes its echoing the right values. Right id for each user. Its matter of comparing id with user_id and if they don't match pop out the error msg. Zed
  10. Thanks for your reply but no this one doesn't give out any error messages at all even with wrong Acc no. Thanks Zed
  11. Hi All Can someone please help me with this code, there are two MySQL tables ‘user_tb’ and ‘job_tb’ id is the primary key in user_tb and user_id is the foreign key in job_tb. A user populates the user_id by form as his Acc no. All I’m trying to do is to prevent him inserting the wrong Acc no (user_id) if he does an error message pop up. With code below I’m getting error message both times whether he inserts Right or Wrong Acc no. there are no other errors, I have also echo the id from user it bring out the right one for the current session user. Some help will be greatly appreciated. if (isset($_POST['user_id'])) { $user_id= mysql_real_escape_string($_POST['user_id']); $query = "SELECT id FROM user WHERE id ='$user_id'"; $result = mysql_query($query)or die(mysql_error()); // If the user was found, if (mysql_num_rows($result) < 1) { error_message("Your Account number was NOT found in our database!"); }else{ if ($name = $_SESSION['name']){ $query = "SELECT id FROM user WHERE username = '$name'"; $result = mysql_query($query) or die ("Couldn't execute query for collecting your data."); if (mysql_num_rows($result) != 'user_id') { error_message("Sorry your inserted Account no. Does Not match with your username"); }else{ Query= INSERT ..... } } } } Thanks Zed
  12. Barand I've tryied your query works like charm Thank you chuck Thanks Zed
  13. johntp my special thanks to you mate its worked of course $user_id is that is being posted. Barand my appreciation to you too. Thanks Zed
  14. This is where the user post his/her own ID (Primary key of user table (id)). Basiclly what I'm saying is if posted number is equel to user.id bring out those records but the devil's bring me everything from other user's records too. <td width="13%">User ID</td> <td width="14%"><input name="user_id" type="text" id="user_id" size="7" /></td> Thanks Zed
  15. Thanks Barand for replying to my post I've just did what you told me, made the second query as query2 and the results as result2 I'm getting the same answer as before. I'm using php5. Thanks Zed
  16. Hi ALL Can someone please tell me why isn't my select query working properly, there are NO errors but its bringing out all the records even those are NOT user_id = id. Same query I'm checking it with phpMyAdmin and it works like charm.Its been three whole days can some take me out of this misery. Thanks Zed function validation(){ $job_id = $_POST['job_id']; $user_id = $_POST['user_id']; $typeOfcustomer = $_POST['typeOfcustomer']; $typeOfvehicle = $_POST['typeOfvehicle']; $noOfVehicle = $_POST['noOfVehicle']; $regul = $_POST['regul']; $cust_name = $_POST['cust_name']; $cust_address = $_POST['cust_address']; $post_code = $_POST['post_code']; $cust_tel = $_POST['cust_tel']; $des = $_POST['des']; $dateDay = $_POST['dateDay']; $dateMO = $_POST['dateMO']; $dateYr = $_POST['dateYr']; $timeHr = $_POST['timeHr']; $timeMin = $_POST['timeMin']; $query = "INSERT INTO blockbook VALUES (NULL,'$user_id','$typeOfcustomer', '$typeOfvehicle','$noOfVehicle','$regul','$cust_name','$cust_address','$post_code','$cust_tel', '$des','$dateDay','$dateMO','$dateYr','$timeHr','$timeMin')"; $result = mysql_query($query)or die(mysql_error()); ?> /*****************************************************************************************/ $query = "SELECT * FROM blockbook, user WHERE blockbook.user_id = user.id "; $result = mysql_query($query)or die(mysql_error()); ?> <div class="smallerText"> <TABLE BORDER=0 WIDTH=100% CELLSPACING=3 CELLPADDING=3 ALIGN=CENTER bgcolor="#99CC99"> <TR ALIGN=CENTER bgcolor="#CCFF66"> <td><font color=red><b>C/A</b></font></TD> <td><font color=red><b>JN</b></font></TD> <td ><font color=red><b>TOC</b></font></TD> <td ><font color=red><b>TOV</b></font></TD> <td ><font color=red><b>NOV</b></font></TD> <td ><font color=red><b>Regu</b></font></TD> <td ><font color=red><b>Multi Days Book</b></font></TD> <td ><font color=red><b>Cust Name</b></font></TD> <td ><font color=red><b>Pick Address</b></font></TD> <td ><font color=red><b>Destination</b></font></TD> <td ><font color=red><b>Tel</b></font></TD> <td ><font color=red><b>WR</b></font></TD> <td ><font color=red><b>Date</b></font></TD> <td ><font color=red><b>Time</b></font></TD> <td ><font color=red><b>Comments</b></font></td> </tr> <? while ($row = mysql_fetch_array($result)) { extract($row); echo "<tr align=center> <td>" . $row['user_id'] . "</td> <td>" . $row['job_id'] . "</td> <td>" . $row['typeOfcustomer'] . "</td> <td>" . $row['typeOfvehicle'] . "</td> <td>" . $row['noOfVehicle'] . "</td> <td>" . $row['regul'] . "</td> <td>" . $row['mon'] . "," . $row['tue'] . "," . $row['wed'] . ", " . $row['thur'] . "," . $row['fri'] . "," . $row['sat'] . ", " . $row['sun'] . "</td> <td>" . $row['cust_name'] . "</td> <td>" . $row['cust_address'] . "</a></td> <td>" . $row['des'] . "</td> <td>" . $row['cust_tel'] . "</td> <td>" . $row['reqVehicle'] . "</td> <td>" . $row['dateDay'] . "/" . $row['dateMO'] . "/" . $row['dateYr'] . "</td> <td>" . $row['timeHr'] . ":" . $row['timeMin'] . "</td> <td>" . $row['comment'] . "</td> </tr>"; } ?></table></div><? } /*****************************************************************************************/ function blockBook(){ ?> <center> <h1>Block Bookings facility is only available for registered customers and Account holders. </h1> </center> <div class="smallerText2"> <form name="blockbook" method="post" action="<?php echo $PHP_SELF ?>"> <table width="100%" border="0" cellspacing="1" cellpadding="0"> <tr> <td></td> <td><input name="Job_id" type="hidden" id="id" size="40" /></td> </tr> <tr> <td width="13%">User ID</td> <td width="14%"><input name="user_id" type="text" id="user_id" size="7" /></td> <td width="6%">Date:</td> <td width="22%"><?php /******************************** Dropdown box for Date ******************/ $today = Time(); //stores today's date $f_today = date("d-M-Y",$today); //formats today's date echo "<div align='center'>\n"; echo "<div align='center'>\n"; /* create form containing date selection list */ //echo "<form action='processform.php' method='post'>\n"; /* build selection list for the day */ $todayDay= date("d",$today); //get the day from $today echo "<select name='dateDay' > \n"; for ($n=1;$n<=31;$n++) { echo " <option value=$n"; if ($todayDay == $n ) { echo " selected"; } echo "> $n\n"; } echo "</select>"; /* create an array of months*/ $monthName = array(1=> "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"); /* build selection list for the month */ $todayMO = date("m",$today); //get the month from $today echo "<select name='dateMO' >\n"; for ($n=1;$n<=12;$n++) { echo "<option value=$n\n"; if ($todayMO == $n) { echo " selected"; } echo "> $monthName[$n]\n"; } echo "</select>"; /* build selection list for the year */ $startYr = date("Y", $today); //get the year from $today echo "<select name='dateYr' >\n"; for ($n=$startYr;$n<=$startYr+5;$n++) { echo " <option value=$n"; if ($startYr == $n ) { echo " selected"; } echo "> $n\n"; } echo "</select>\n"; ?></td> <td width="13%">Name:</td> <td width="32%"><input name="cust_name" type="text" id="cust_name" size="40" /></td> </tr> <tr> <td>Type of Customer:</td> <td><select name="typeOfcustomer" onchange="accountCust('parent',this,0)"> <option value="cash" selected="selected">Cash</option> <option value="authAc.php">Account</option> </select></td> <td>Time</td> <td> Hr <select name="timeHr" > <option>00</option> <option>01</option> <option>02</option> <option>03</option> <option>04</option> <option>05</option> <option>06</option> <option>07</option> <option>08</option> <option>09</option> <option>10</option> <option>11</option> <option>12</option> <option>13</option> <option>14</option> <option>15</option> <option>16</option> <option>17</option> <option>18</option> <option>19</option> <option>20</option> <option>21</option> <option>22</option> <option>23</option> </select> Min <select name="timeMin" > <option>00</option> <option>05</option> <option>10</option> <option>15</option> <option>20</option> <option>25</option> <option>30</option> <option>35</option> <option>40</option> <option>45</option> <option>50</option> <option>55</option> </select></td> <td>Pick up Address:</td> <td><input name="cust_address" type="text" id="cust_address" size="50" /></td> </tr> <tr> <td>Type of Vehicle Req:</td> <td><select name="typeOfvehicle" > <option value="4Seater">4 Seater Vehicle</option> <option value="7Seater">7 Seater Vehicle</option> </select></td> <td> </td> <td> </td> <td>Post Code:</td> <td><input name="cust_postCode" type="text" id="cust_postCode" size="15" /></td> </tr> <tr> <td>No. of Vehicles Req:</td> <td><select name="noOfVehicle" > <option value="1" selected="selected">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> <option value="10">10</option> </select></td> <td> </td> <td> </td> <td>Tel / Mobile:</td> <td><input name="cust_tel" type="text" id="cust_tel" size="20" /></td> <tr> <td>Booking Regularity:</td> <td><select name="regul" > <option value="0" selected="selected">Select</option> <option value="once">Once</option> <option value="daily">Daily</option> <option value="weekly">Weekly</option> <option value="monthly">Monthly</option> </select></td> <td> </td> <td> </td> <td>Destination:</td> <td><input name="des" type="text" id="des" size="50" /></td> </tr> </table> <hr> <tr> <td> <input name="submit" type="submit" value="Submit" /> </td> <td> <input name="reset" type="reset" value="Reset" /> </td></form> </tr></div> <? } if (! isset($_POST['submit'])){ blockBook(); }else{ validation(); } ?>
  17. Sorry mate fairly new to this where do you want me to place thid code.
  18. Thanks Barand its still the same. I need to know how to fetch the user tables primary key value (which is auto incre) to blockbook table's user_id (the foreign key) of this table. thanks zed
  19. Thanks for reply I've just enabled InnoDB in phpMyAdmin and droped the database recreated db and tables but It didn't work. Thanks anyway Zed
  20. Hi All Can some please enlighten me how to populate the foreign key in php. I have two tables; CREATE TABLE `user` ( `id` smallint(5) unsigned NOT NULL auto_increment, `fullname` varchar(60) NOT NULL, `username` char(15) NOT NULL, `pswd` char(32) NOT NULL, `address` varchar(70) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; CREATE TABLE `blockBook` ( `user_id` smallint(5) unsigned NOT NULL, `job_id` smallint(5) unsigned NOT NULL auto_increment, `cust_name` varchar(40) NOT NULL, `cust_address` varchar(60) NOT NULL, PRIMARY KEY (`job_id`), FOREIGN KEY (user_id) REFERENCES user(id) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; This is how I'm INSERTING into the table; $user_id = $_POST['user_id']; $job_id = $_POST['job_id']; $cust_name = $_POST['cust_name']; $cust_address = $_POST['cust_address']; $query = "INSERT INTO blockbook VALUES ('user_id','job_id','$cust_name','$cust_address')"; $result = mysql_query($query)or die(mysql_error()); } And this is my SELECT query; $query = "SELECT * FROM blockbook, user WHERE user_id= id"; $result = mysql_query($query)or die(mysql_error()); But it’s not working the foreign key value is always 0. How the devil do I populate it? I've even tried manually it doesn't work. Thanks Zed
  21. Any suggestions anyone???????? ??? Thanks Zed
  22. By posting a HTML form; ]<form name="blockBook" method="post" action="<?php echo $PHP_SELF ?>"> <table width="100%" border="0" cellspacing="1" cellpadding="0"> <tr> <td width="13%">Customer/Acc no.</td> <td width="14%"><input name="user_id" type="text" id="user_id" size="10" /></td> </tr> <tr> <td width="13%"></td> <td width="14%"><input name="Job_id" type="hidden" id="id" size="40" /></td> </tr> <tr> <td>Type of Customer:</td> <td> <select name="typeOfcustomer" onchange="accountCust('parent',this,0)"> <option value="cash" selected="selected">Cash</option> <option value="authAc.php">Account</option> </select></td> <td width="6%">Date:</td> <td width="22%"><?php /******************************** Dropdown box for Date ******************/ $today = Time(); //stores today's date $f_today = date("d-M-Y",$today); //formats today's date echo "<div align='center'>\n"; echo "<div align='center'>\n"; /* create form containing date selection list */ //echo "<form action='processform.php' method='post'>\n"; /* build selection list for the day */ $todayDay= date("d",$today); //get the day from $today echo "<select name='dateDay' > \n"; for ($n=1;$n<=31;$n++) { echo " <option value=$n"; if ($todayDay == $n ) { echo " selected"; } echo "> $n\n"; } echo "</select>"; /* create an array of months*/ $monthName = array(1=> "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"); /* build selection list for the month */ $todayMO = date("m",$today); //get the month from $today echo "<select name='dateMO' >\n"; for ($n=1;$n<=12;$n++) { echo "<option value=$n\n"; if ($todayMO == $n) { echo " selected"; } echo "> $monthName[$n]\n"; } echo "</select>"; /* build selection list for the year */ $startYr = date("Y", $today); //get the year from $today echo "<select name='dateYr' >\n"; for ($n=$startYr;$n<=$startYr+5;$n++) { echo " <option value=$n"; if ($startYr == $n ) { echo " selected"; } echo "> $n\n"; } echo "</select>\n"; ?></td> <td width="13%">Name:</td> <td width="32%"><input name="cust_name" type="text" id="cust_name" size="40" /></td> </tr> <tr> <td>Type of Vehicle Req:</td> <td> <select name="typeOfvehicle" > <option value="4Seater">4 Seater Vehicle</option> <option value="7Seater">7 Seater Vehicle</option> </select></td> <td>Time</td> <td> Hr <select name="timeHr" > <option>00</option> <option>01</option> <option>02</option> <option>03</option> <option>04</option> <option>05</option> <option>06</option> <option>07</option> <option>08</option> <option>09</option> <option>10</option> <option>11</option> <option>12</option> <option>13</option> <option>14</option> <option>15</option> <option>16</option> <option>17</option> <option>18</option> <option>19</option> <option>20</option> <option>21</option> <option>22</option> <option>23</option> </select> Min <select name="timeMin" > <option>00</option> <option>05</option> <option>10</option> <option>15</option> <option>20</option> <option>25</option> <option>30</option> <option>35</option> <option>40</option> <option>45</option> <option>50</option> <option>55</option> </select></td> <td>Pick up Address:</td> <td><input name="cust_address" type="text" id="cust_address" size="50" /></td> </tr> <tr> <td>No. of Vehicles Req:</td> <td><select name="noOfVehicle" > <option value="1" selected="selected">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> <option value="10">10</option> </select></td> <td> </td> <td> </td> <td>Post Code:</td> <td><input name="cust_postCode" type="text" id="cust_postCode" size="15" /></td> </tr> <tr> <td>Booking Regularity:</td> <td><select name="regul" > <option value="0" selected="selected">Select</option> <option value="once">Once</option> <option value="daily">Daily</option> <option value="weekly">Weekly</option> <option value="monthly">Monthly</option> </select></td> <td> </td> <td> </td> <td>Tel / Mobile:</td> <td><input name="cust_tel" type="text" id="cust_tel" size="20" /></td> <tr> <td> </td> <td> </td> <td> </td> <td> </td> <td>Destination:</td> <td><input name="des" type="text" id="des" size="50" /></td> </tr> </table> <hr> <tr> <td> <input name="submit" type="submit" value="Submit" /> </td> <td> <input name="reset" type="reset" value="Reset" /> </td><a href="blockBook.php">Make another Booking</a></form> </tr></div> <? } [/code
  23. Yeah I think this is where the real difficulty is, I'm not so sure how to populate this user_id in blockBook table. Any suggestion would be greatly appreicated. Zed
  24. Thanks rhodesa, there's (id) in the user table and blockBook.user_id is the reference of it in blockBook table of course.
×
×
  • 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.