Jump to content

psychowolvesbane

Members
  • Posts

    204
  • Joined

  • Last visited

    Never

Everything posted by psychowolvesbane

  1. You could also try placing session_start() at the very top of the page above the <html> tag and tidy up some redundant php tags as well on line 41
  2. You will need to show your current code to help make this quicker to help with.
  3. Okay I want to know how I can use the date function to query against records in a table, and to show only records that are 2 weeks old compared to todays date. So the table record is set to date(Y-m-d), so how do I go about comparing it with the current date and finding any records older than 14 days old? I don't need to worry about the sql, just get it so there is a variable to compare against.
  4. Hi, I've made a form for my users to edit their personal details once they are registered. This includes a section called NUS and NUS Number (National Union of Students in UK) and every time the user clicks on the NUS check button it hides/unhides the NUS Num section below it. Now what's wrong with it is that if the user has selected NUS it activates the checkbutton and fills out the NUS Number field, but for some reason it stops the check button from being clicked on and using the function again. This produces no errors in my Error Console in Fire Fox and the strange thing is that if the user doesn't have NUS selected prior to this then the check button and function works fine. Here's the function code: function NUSHide(f){ var mode; <?php if($Cont == false) { if($NUS == 1) { ?> document.Edit_Details_Form.NUS.checked = true mode="block"; <?php } else { ?> if(document.Edit_Details_Form.NUS.checked == true) { mode="block"; } else if(document.Edit_Details_Form.NUS.checked == false) { mode="none"; document.Edit_Details_Form.NUSNum.value=""; } <?php } ?> return document.getElementById('NUSHide').style.display=mode; <?php } else { ?> return false; <?php } ?> } and here is the form code with the NUS part at the bottom: <body onLoad="javascript:NUSHide(document.getElementById('NUSHide'));"> <div class="MainContainer"> <?php require('admin/header.inc'); require('menu.inc') ?> <div class="DivMain"> <?php if($Cont==true) { ?> <span class="head2"><?php echo $MsgEdited?></span><br><br> <a href="my_account.php">Back to My Account</a> <?php $conn = mysql_connect($Host,$Username,$Password) or die(mysql_error()); $db = mysql_select_db($Dbname, $conn); $sql2 = "SELECT Email FROM UserAccount WHERE UserID='$EditThisUser'"; $rs2 = mysql_query($sql2, $conn)or die('Problem with query: ' . $sql2 . '<br />' . mysql_error()); $row2 = mysql_fetch_array($rs2); $Email = $row2['Email']; mysql_close($conn); $message=""; $message=$message."<html>"; $message=$message."<body>"; $message=$message."<span style=\"font-family:Comic Sans MS; font-size:24pt; text-align:center; background-color:#E61732; color:white; font-weight:bold\">A&WC Clothing Line</span><br>"; $message=$message."This is a confirmation that you changed your account details.<br><br>"; $message=$message."Your new Password is: $NewPass"."<br>"; $message=$message."If you were not the one responsible for changing this password then please contact The Hub immediately and we will try to sort the problem out for you."; $message=$message."</body>"; $message=$message."</html>"; if (mail($UserEmail,"$User - Change Account Details Confirmation - A&WC Clothing Line",$message,"Content-Type:text/html;charset=us-ascii")) { $MsgChange= "Your password has been changed successfully!"; } else { $MsgChange= "Can't send e-mail on this system... Doh!"; die(); } } else { ?> <span class="head2">Edit Account Details Form</span><br> <span class="errmsg">All fields marked with an * are required</span><br> <?php echo $MsgUser; echo $MsgForename; echo $MsgSurname; echo $MsgCampus; echo $MsgCourse; echo $MsgNUSNum; ?> <span id="mySpan1a" class="mySpan1a"><br></span> <span id="mySpan2a" class="mySpan2a"><br></span> <span id="mySpan3a" class="mySpan3a"><br></span> <span id="mySpan4a" class="mySpan4a"><br></span> <span id="mySpan5a" class="mySpan5a"><br></span> <span id="mySpan6a" class="mySpan6a"><br></span> <br> <form method="post" name="Edit_Details_Form" action="edit_details_form.php" onSubmit="return Validate(this);"> <table style="width:auto; position:absolute;"> <table> <tr><td><?php echo $Err1?><span id="mySpan1b" class="mySpan1b"></span><span class="head4">Username:(Max Length 15 chars)</span><span class="errmsg"> *</span></td> <td><label><input type="text" maxlength="15" name="Username" value="<?php echo $User?>"/></label></td></tr> <tr><td><?php echo $Err2?><span id="mySpan2b" class="mySpan2b"></span><span class="head4">Forename:</span><span class="errmsg"> *</span></td> <td><label><input type="text" maxlength="15" name="Forename" value="<?php echo $Forename?>"/></label></td></tr> <tr><td><?php echo $Err3?><span id="mySpan3b" class="mySpan3b"></span><span class="head4">Surname:</span><span class="errmsg"> *</span></td> <td><label><input type="text" maxlength="20" name="Surname" value="<?php echo $Surname?>"/></label></td></tr> <tr><td><?php echo $Err4?><span id="mySpan4b" class="mySpan4b"></span><span class="head4">Campus based at: </span><span class="errmsg"> *</span></td> <td><label><select name="Campus"/><option value="">Please Select a Campus</option> <?php $conn = mysql_connect($Host,$Username,$Password) or die(mysql_error()); $db = mysql_select_db($Dbname, $conn); $sql = "SELECT Campus FROM Campus ORDER BY Campus"; $rs = mysql_query($sql, $conn) or die(mysql_error()); while($row = mysql_fetch_array($rs)) { $Camp = $row['Campus']; echo"<option value='$Camp'"; if($Campus == $Camp) {echo"Selected";} echo">$Camp</option>"; } mysql_close($conn); ?> </select></label></td></tr> <tr></tr> <tr><td><?php echo $Err5?><span id="mySpan5b" class="mySpan5b"></span><span class="head4">Course Name:</span><span class="errmsg"> *</span></td> <td><label><input type="text" size="45" name="Course" value="<?php echo $Course?>"/></label></td></tr> <tr></tr> <tr><td><span class="head4">NUS:</span></td> <td><label><input type="checkbox" name="NUS" <?php if($NUSChk == "on"){echo"Checked";}?> id="NUS" onclick="NUSHide(this)"/></label> </td></tr> </table> <table width="564" class="TableHidden" id="NUSHide"> <tr width="340px"><td width="266"><?php echo $Err6?><span id="mySpan6b" class="mySpan6b"></span><span class="head4">NUS Number: (18 Chars)</span></td> <td width="240"><label><input type="text" maxlength="21" name="NUSNum" value="<?php echo $NUSNum?>"/></label></td></tr> </table> <table> <tr><td><label><input type="submit" style="overflow:visible; width:auto" class="buttonS" name="SubmitB" value="Submit" onMouseOver="OverMouse(this)"; onMouseOut="OutMouse(this)"/> </label> </td></tr> </table> </form> <br><br> <a href="my_account.php">Back to My Account</a> <?php } ?> </div> </div> </body> P.S. $Cont is only used after the form has been submitted successfully so I added that to stop the undefined function error.
  5. Ah got it sorted, here is the code based on you're first post: var checked = false; var Sizes = document.BuyProduct.Sizes; if (Sizes.length){ for (var i=0; i<Sizes.length; i++) { if (Sizes[i].checked) { checked = true; } } } else if(Sizes.checked) { checked=true; } if(!checked) { Errors++ document.getElementById('mySpan1a').style.display='block'; document.getElementById('mySpan1a').innerHTML='Please Select a Size!'; document.getElementById('mySpan1b').style.display='inline'; document.getElementById('mySpan1b').innerHTML='! '; } else { document.getElementById('mySpan1a').style.display='none'; document.getElementById('mySpan1a').innerHTML=''; document.getElementById('mySpan1b').style.display='none'; document.getElementById('mySpan1b').innerHTML=''; }
  6. Unfortunately Sizes.length is only defined with the multi selection, it says it's undefined otherwise.
  7. I have a piece of code that validates whether one button has been selected from a bunch of dynamically created radio buttons. //Validation Code var checked = false; var Sizes = document.BuyProduct.Sizes; for (var i=0; i<Sizes.length; i++) { if (Sizes[i].checked) { checked = true; } } if(!checked) { Errors++ document.getElementById('mySpan1a').style.display='block'; document.getElementById('mySpan1a').innerHTML='Please Select a Size!'; document.getElementById('mySpan1b').style.display='inline'; document.getElementById('mySpan1b').innerHTML='! '; } else { document.getElementById('mySpan1a').style.display='none'; document.getElementById('mySpan1a').innerHTML=''; document.getElementById('mySpan1b').style.display='none'; document.getElementById('mySpan1b').innerHTML=''; } // Form code <?php echo $Err1?><span class="mySpan1b" id="mySpan1b"></span><span class="head4">Available Sizes:</span><span class="errmsg"> *</span> <table style="position:relative;"><tr> <?php $counter=0; $X=0; $i=0; $IsEmpty1 == false; while ($IsEmpty1 == false) { if($AvailableSizes[$X] != "") { $id1 = "Size".$i; if($counter%6==0&&$counter!=0) echo "</tr><tr>"; echo"<td>$AvailableSizes[$X]</td>"; echo "<td><label><input type='radio' id='$id1' name='Sizes' value='$AvailableSizes[$X]'"; if($AvailableSizes[$X] == $SizeSel){echo "Checked";} echo"></label></td></tr><tr>"; ++$counter; } else { $IsEmpty1 = true; } $i++; $X++; } ?> </tr></table> The validation code works, but to a point. This code assumes that there will be more than 1 radio button to choose from and becomes an array, however occassionally there will be only a single button which doesn't turn the selection into an array, and thus stops the validation code from working and displaying the error message for that option. So what I need is a modified version of the validation that can account for when the selection is an array and when it is only a single option as well.
  8. Yes I understand now about 231-1 being the largest possible integer number, so I just decided to change the max to 9 digits instead of 10 as there is no specific requirement for it.
  9. Try: <?php mysql_connect("localhost","adfsd","ssfdsdf"); mysql_select_db("rsffsd") or die("Unable to select database"); $art = $_GET['id']; $sql = "SELECT * FROM items WHERE id=$art"; $result = mysql_query($sql); $num_rows = mysql_num_rows($result); if($num_rows == 0) { echo "No results please try a different <a href=asearch.html>search</a>."; } else { while($row = mysql_fetch_array($result)) { $code1 = $row['code1']; $code2 = $row['code2']; } mysql_connect("localhost","dfssdfsd","sdffds"); mysql_select_db("dsfsdfsd") or die("Unable to select database"); $sql = "SELECT * FROM `$code1 by $code2` ORDER BY id DESC LIMIT 3"; $result = mysql_query($sql) or die(mysql_error()); $num_rows = mysql_num_rows($result); if($num_rows == 0) { echo ""; } else { $row = mysql_fetch_assoc($result) $CommAuth[] .= $row['name']; $Comment[] .= $row['message']; $horde[] .= $row['horde']; $title[] .= $row['title']; } } } mysql_connect("localhost","sdfdfssd","sfsdfds"); mysql_select_db("ssdfsdfsdf") or die("Unable to select database"); $sql2 = "SELECT * FROM ac_users WHERE username='$title' LIMIT 3"; $result2 = mysql_query($sql2); $num_rows2 = mysql_num_rows($result2); if($num_rows2 == 0) { echo "No results please try a different <a href=reports.php>search 2</a>."; } else { $CommAvatar = array(); while($row2 = mysql_fetch_array($result2)) { $CommAvatar[] .= $row2['avatar']; $count = 0; foreach ($CommAuth as $value){ print "<div id=\"comment\"> <img src=\"/avatar/{$CommAvatar[$count]}\" width=\"56\" height=\"56\" class=\"comment_photo\" /> <div id=\"comment_header\"><span class=\"comment_author\"> {$value} </span><span class=\"comment_wrote\">wrote...</span><span class=\"comment_stars\"><img src=\"stars_5.png\"/></span></div> <div class=\"comment_text\">{$Comment[$count]}</div> <div id=\"comment_footer\"><span class=\"comment_delete\">Report | Comment on {$value} Profile | Message {$value}</span></div> </div>"; $count++; } } } ?>
  10. I have an order capture page that takes details from my Shopping Cart and creates a Sales Order containing these fields: OrderID - int(6) - Primary CampusID - varchar(10) CollectionID - int(10) OrderDate - date TotalCost - decimal(5,2) I have a script that first of all creates an entry in this table, OrderID and CollectionID are both supposed to be rand(111111,999999) and rand(1111111111,9999999999) respectively, however when the time comes for CollectionID to be added into the record it always ends up as 2147483647 regardless of all the attempts I've made at understanding why it is doing this. The code for that part of my order_capture.php page is: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <?php session_start(); include "admin/connect_details.php"; if($_POST['CheckoutButton'] == "Checkout") { $OrderID = rand(100000,999999); $conn = mysql_connect($Host,$Username,$Password) or die(mysql_error()); $db = mysql_select_db($Dbname, $conn); while($OkOrderID == false) { $sql1 = "SELECT OrderID FROM SalesOrder WHERE OrderID='$OrderID'"; $rs1 = mysql_query($sql1,$conn) or die('Problem with query: ' . $sql1 . '<br />' . mysql_error()); if(mysql_num_rows($rs1)==1) { $OkOrderID = false; $OrderID = rand(100000,999999); } else { $OkOrderID = true; } } $Campus = $_POST['Campus']; $TotalCost = $_POST['TotalCost']; $sql2 = "SELECT CampusID FROM Campus WHERE Campus='$Campus'"; $rs2 = mysql_query($sql2,$conn) or die('Problem with query: ' . $sql2 . '<br />' . mysql_error()); $row = mysql_fetch_array($rs2); $CampusID = $row['CampusID']; $CollectID = rand(1000000000,9999999999); while($OkCollectID == false) { $sql3 = "SELECT CollectionID FROM SalesOrder WHERE CollectionID='$CollectID'"; $rs3 = mysql_query($sql3,$conn) or die('Problem with query: ' . $sql3 . '<br />' . mysql_error()); if(mysql_num_rows($rs3)==0) { $OkCollectID = true; $CollectionID = $CollectID; } else { $OkCollectID = false; $CollectionID = rand(1000000000,9999999999); } } echo "This is the CollectionID 1 (before query) ".$CollectionID."<br>"; $OrderDate = date("Y/m/d"); $UserID = $_SESSION['User_UserID']; $sqlAdd1 = "INSERT INTO SalesOrder (OrderID, CampusID, CollectionID, OrderDate, TotalCost) VALUES ('$OrderID', '$CampusID', '$CollectionID', '$OrderDate', '$TotalCost')"; $rsAdd1 = mysql_query($sqlAdd1,$conn); echo "This is the CollectionID 2 (after query) ".$CollectionID."<br>"; The strange things is that the echo of CollectionID before and after are exactly the same and are completely random, yet somehow the entry in the table is still 2147483647, and there are no other entries with that number, or entries it copies the number from. Can anyone see where this phantom number is coming from? ???
  11. Hi if you could take a few minutes of your time to just check to see if there are no errors (glaring or otherwise) in this page I would be grateful. It's not the kinda script I want to test blindly and ruin a lot of test data already in the ShopCart table. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <?php session_start(); include "admin/connect_details.php"; if($_POST['CheckoutButton'] == "Checkout") { $OrderID = rand(100000,999999); $conn = mysql_connect($Host,$Username,$Password) or die(mysql_error()); $db = mysql_select_db($Dbname, $conn); while($OkOrderID == false) { $sql1 = "SELECT OrderID FROM SalesOrder WHERE OrderID='$OrderID'"; $rs1 = mysql_query($sql1,$conn) or die('Problem with query: ' . $sql1 . '<br />' . mysql_error()); if(mysql_num_rows($rs1)==1) { $OkOrderID = false; $OrderID = rand(100000,999999); } else { $OkOrderID = true; } } $Campus = $_POST['Campus']; $TotalCost = $_POST['TotalCost']; $sql2 = "SELECT CampusID FROM Campus WHERE Campus='$Campus'"; $rs2 = mysql_query($sql2,$conn) or die('Problem with query: ' . $sql2 . '<br />' . mysql_error()); $row = mysql_fetch_array($rs2); $CampusID = $row['CampusID']; $CollectionID = rand(1000000000,9999999999); while($OkCollectID == false) { $sql3 = "SELECT CollectionID FROM SalesOrder WHERE CollectionID='$CollectionID'"; $rs3 = mysql_query($sql3,$conn) or die('Problem with query: ' . $sql3 . '<br />' . mysql_error()); if(mysql_num_rows($rs3)==1) { $OkCollectID = false; $CollectionID = rand(1000000000,9999999999); } else { $OkCollectID = true; } } $OrderDate = date(d/m/y); $sqlAdd1 = "INSERT INTO SalesOrder (OrderID, CampusID, CollectionID, OrderDate, TotalCost, Paid, DatePaid, OrderSent, DateSent, OrderReceived, DateReceived, OrderCollected, DateCollected, ValidOrder, OrderComplete) VALUES ('$OrderID', '$CampusID', '$CollectionID', '$OrderDate', '$TotalCost','0','','0','','0','','0','','0','0')"; $rsAdd1 = mysql_query($sqlAdd1,$conn); $sql4 = "SELECT * FROM ShopCart WHERE CustID='$_SESSION['User_UserID']'"; $rs4 = mysql_query($sql4,$conn); while($row2 = mysql_fetch_array($rs4)) { $sqlAdd2 = "INSERT INTO OrderDetails (OrderID) VALUES ('$OrderID')"; $rsAdd2 = mysql_query($sqlAdd2,$conn); if($row2['NUSDiscount'] == 1) { $NUSDiscount = "Price"; } else { $NUSDiscount = "NUSPrice"; } $sql5= "SELECT Description,$NUSDiscount,Quantity WHERE ProductID='$row2['ProductID']'"; $rs5 = mysql_query($sql5,$conn); $row3 = mysql_fetch_array($rs5); $sqlAdd3 = "UPDATE OrderDetails SET OrderID='$OrderID' CustID='$row2['CustID']', ProductID='$row2['ProductID']', NUSDiscount='$row2['NUSDiscount']', ProdTitle='$row3['Description']', ProdPrice='$row3['$NUSDiscount']', ProdQuantity='$row3['Quantity']'"; $rsAdd3 = mysql_query($sqlAdd3,$conn); $sqlDel = "DELETE FROM ShopCart WHERE CustID='$_SESSION['User_UserID']'"; $rsDel = mysql_query($sqlDel,$conn); } mysql_close($conn); } ?> <html> <head> <title>Clothing Line</title> <link href="admin/stylesheetCL.css" rel="stylesheet"> <?php require('admin/jscript.inc')?> </head> <body> <?php require('admin/header.inc'); require('menu.inc') ?> <div class="DivMain"> <?php if($_POST['CheckoutButton'] == "Checkout") { $sqlDis = "SELECT * FROM OrderDetails WHERE OrderID='$OrderID'"; $rsDis = mysql_query($sqDis,$conn); ?> <span class="head1">Sales Order</span><br><br> <span class="head4">Order No. </span><?php echo $OrderID?><br> <span class="head4">Date: </span><?php echo date('d/m/y')?><br> <table border="0"> <tr> <th>Item Number</th> <th>Title</th> <th>Size</th> <th>Colour</th> <th>Quantity</th> <th>Price</th> <th>Amount</th> </tr> <?php while($rowDis = mysql_fetch_array($rsDis)) { $OrderItem = $row1['ProductID']; $sqlProdDetails= "SELECT Description, Price, NUSPrice, Quantity, Colour, Size, CollegeLogo, FrontText, FTextColour, BackText, BTextColour FROM Products WHERE ProductID ='$OrderItem'"; $rsProdDetails = mysql_query($sqlProdDetails,$conn); $row2 = mysql_fetch_array($rsProdDetails); $OrderTitle = $row2['Description']; $OrderPrice1 = $row2['Price']; $OrderPrice2 = $row2['NUSPrice']; $OrderQuantity = $row2['Quantity']; $OrderColour = $row2['Colour']; $OrderSize = $row2['Size']; $CollegeLogo = $row2['CollegeLogo']; if($CollegeLogo == 0) { $CollegeLogo = "N"; } else { $CollegeLogo = "Y"; } $sqlDiscount = "SELECT NUSDiscount From ShopCart WHERE CustID = '$CustID'"; $rsDiscount = mysql_query($sqlDiscount,$conn); $row3 = mysql_fetch_array($rsDiscount); $NUSDiscount = $row3['NUSDiscount']; $Discount = false; if($NUSDiscount == 1) { $Discount = true; } echo "<tr> <td>$OrderItem </td> <td>$OrderTitle</td> <td>$OrderSize</td> <td><img src='/images/colours/$OrderColour.gif' align=right title='$OrderColour'/></td> <td><input type=\"text\" name=\"Q$OrderItem\" size=\"2\" class=\"qtybox\" value=\"$OrderQuantity\"></td>"; if($Discount==true) { $OrderAmount = $OrderPrice2*$OrderQuantity; echo"<td style=\"text-align:right\">£$OrderPrice2</td> <td style=\"text-align:right\">£$OrderAmount</td></tr>"; } else { $OrderAmount = $OrderPrice1*$OrderQuantity; echo"<td style=\"text-align:right\">£$OrderPrice1</td> <td style=\"text-align:right\">£$OrderAmount</td></tr>"; } $OrderTotal = $_POST['TotalCost']; } mysql_close($conn); ?> <tr><th colspan="6" style="text-align:right">Order Total </th> <td style="border-style:solid"><b>£<?php echo number_format($OrderTotal,2) ?></b></td></tr> </table> <?php } else { ?> <span class="head4">You do not belong here!</span> <?php } ?> </div> </body> </html>
  12. Well this is a shopping cart for a e-commerce site that I'm building. The shopping cart will only temporarily hold the details until the checkout, then they will be amended into the OrderDetails table but they will have a unique OrderNo added to each, so OrderNo, ProdID and CustID instead of just the last 2 in the shopping cart table.
  13. Try this, I just placed the 2nd half inside the while loops, it may be wrong as I'm not sure if Foreach loops work inside While Loops. <?php mysql_connect("localhost","adfsd","ssfdsdf"); mysql_select_db("rsffsd") or die("Unable to select database"); $art = $_GET['id']; $sql = "SELECT * FROM items WHERE id=$art"; $result = mysql_query($sql); $num_rows = mysql_num_rows($result); if($num_rows == 0) { echo "No results please try a different <a href=asearch.html>search</a>."; } else { while($row = mysql_fetch_array($result)) { $code1 = $row['code1']; $code2 = $row['code2']; } mysql_connect("localhost","dfssdfsd","sdffds"); mysql_select_db("dsfsdfsd") or die("Unable to select database"); $sql = "SELECT * FROM `$code1 by $code2` ORDER BY id DESC LIMIT 3"; $result = mysql_query($sql) or die(mysql_error()); $num_rows = mysql_num_rows($result); if($num_rows == 0) { echo ""; } else { $row = mysql_fetch_assoc($result) { $CommAuth[] .= $row['name']; $Comment[] .= $row['message']; $horde[] .= $row['horde']; $title[] .= $row['title']; } } } mysql_connect("localhost","sdfdfssd","sfsdfds"); mysql_select_db("ssdfsdfsdf") or die("Unable to select database"); $sql2 = "SELECT * FROM ac_users WHERE username='$title' LIMIT 3"; $result2 = mysql_query($sql2); $num_rows2 = mysql_num_rows($result2); if($num_rows2 == 0) { echo "No results please try a different <a href=reports.php>search 2</a>."; } else { $CommAvatar = array(); while($row2 = mysql_fetch_array($result2)) { $CommAvatar[] .= $row2['avatar']; $count = 0; foreach ($CommAuth as $value){ print "<div id=\"comment\"> <img src=\"/avatar/{$CommAvatar[$count]}\" width=\"56\" height=\"56\" class=\"comment_photo\" /> <div id=\"comment_header\"><span class=\"comment_author\"> {$value} </span><span class=\"comment_wrote\">wrote...</span><span class=\"comment_stars\"><img src=\"stars_5.png\"/></span></div> <div class=\"comment_text\">{$Comment[$count]}</div> <div id=\"comment_footer\"><span class=\"comment_delete\">Report | Comment on {$value} Profile | Message {$value}</span></div> </div>"; $count++; } } } ?>
  14. Hi, I was wondering if you could help me with creating an Amend table script that also involves adding new fields into the table being amended to. I have a ShopCart table with these fields CustID ProductID NUSDiscount OrderDate OrderQuantity and a table called OrderDetails that has the fields: OrderID CustID ProductID NUSDiscount ProdTitle ProdPrice ProdQuantity What I need is the fields CustID, ProductID, NUSDiscount, and OrderQuantity from the ShopCat table amended to the OrderDetails table based on the php variable $CustID (which you don't need to worry about) and then being able to hopefully in the same query string add the OrderID from another variable called $OrderID also obtained earlier. I will deal with the rest of the table later, it's just this amend part I need dealt with and I don't know how to do that with an INSERT as well. P.S. OrderQuantity is the same as ProdQuantity.
  15. I have noticed that the reason why $query is not being used in the mysql_query statement is because you missed out the php $ variable assignment so it looks like mysql_query(query) not mysql_query($query) <?php mysql_connect("localhost", "root", "") or die ("Could not connect"); mysql_select_db("itsupport") or die ("Could not connect to DB"); if ($_POST['User_ID']) { $User_ID = $_POST['User_ID']; $query = "DELETE FROM itsupport WHERE User_ID='$User_ID'"; // define the query string $result = mysql_query( //HERE---> $query) or die('Delete Query Failed. Error '. mysql_error(). ' with query '. $query); echo "The Row Number $User_ID has been Successfully Removed"; } ?>
  16. For now disable the link back to info.php on the anotherinfo.php (and remove the ? and ?tsk as they are not needed if only for show as you said) and try and concentrate on getting the form to work and displaying the "good" message.
  17. Okay for you're actions on both forms why do you have ?php referencing when they are not needed or used, especially the one on anotherinfo.php you have a loose ? at the end, and the ?tsk on the first. Okay that won't be the problem, just nitpicking. Anyway you could try disabling the link on the info.php temporarily and see if you can echo out the value of the $_session['ok'] once it has been set, or not set. So, echo"This is the session okay".$_SESSION['ok']; Then if that checks out okay try adding another = on the first if statement on the 2nd page, may help may not. if($_SESSION['ok'] !== 1 )
  18. You have missed out the if statement on line 15 and that leaves an empty bracket and it's causing havoc,
  19. I'm not too sure but do you need to have the brackets around the whole "Order By (round((sum_/count_),2))" part? When you just have no brackets with normal ORDER BY fields scripts.
  20. Add a field in your User Account table called Type and the values could be either 0, 1, 2 or Basic, Normal, Advanced or something else of your choosing. Then have some code in the <head> of your page that will redirect the users that don't belong there based on their Type.
  21. It might help to see the forms you are using for each, or at least the submit button sections and <form> sections to see if you are overlooking something.
  22. I've always done while($row = mysql_fetch_array($result)), try and see if that works instead of a do..while() loop.
  23. I ended up just using spaces between each grouping, also followed by giving the user a message beside the input to use spaces. Though the amount of people that cannot read signs properly in this day and age is horrendous!
×
×
  • 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.