Jump to content

roldahayes

Members
  • Posts

    287
  • Joined

  • Last visited

Everything posted by roldahayes

  1. No, awr100-1322.php is the page URL. I want the code within the page to read the url and populate itself with the page url (minus the .php) i.e $CODE = "Page URL Here"; At the moment, I have to manually open the page and change the $CODE to what ever the page Url is - I want this to happen dynamically
  2. I just want to make sure that I have explained myself correctly in my original post. My full URL's are like this: http://mysite.com/PPP/awr99-1322.php Within my code I have: $CODE = "awr99-1322"; (This then generates everything on my page to be working correctly) I need the $CODE="---------"; to be generated every time depending on url name. So for example, if the url was: http://mysite.com/PPP/awr100-1322.php Then the code would end up as, $CODE = "awr100-1322";
  3. Yes, the htaccess appears to be loading (I have it doing other things to different urls on the site)
  4. Is there a way to test this is working? I was thinking I could use: echo 'Display: ' . htmlspecialchars($_GET["id"]); But not sure if this is just not working or it is wrong?
  5. Ok, so do I have to use .htaccess to set this up? I'm a little confused by different examples after searching URL rewriting.
  6. Hi, Is it possible to dynamically change a variable depending on the URL of the page? i.e my code on the page is: $CODE = "somethinghere"; if the page url is www.domain.com/654321.php it chages it to $CODE = "654321"; I hope I've explained this correctly!
  7. Sorry, worked it out again.... // For each value pair, output value to LOG $firstvalue=TRUE; foreach ($_POST as $key => $value) { if (!$firstvalue) { fwrite($log, "\n") ; }
  8. Just one last question, how would I be able to get a line break after each output to make it more readable? I'm assuming I need "\n" somewhere in // For each value pair, output value to LOG $firstvalue=TRUE; foreach ($_POST as $key => $value) { if (!$firstvalue) { fwrite($log, ", ") ; }
  9. Solved, // Open LOG File$log = fopen ("formdata.log" , "a"); // For each value pair, output value to LOG$firstvalue=TRUE;foreach ($_POST as $key => $value) {if (!$firstvalue) { fwrite($log, ", "); } // If value is array (multiple select list)// Output array to LOG (elements sep by -)if (is_array($value) ) {$firstelement=TRUE;fwrite ($log, "\" ");foreach ($value as $element) {if (!$firstelement) {fwrite ($log, "-");$firstelement=FALSE;}fwrite ($log,$element); }} else { // Not array, output simple valuefwrite ($log, "\" $value ");$firstvalue=FALSE;} } // Line Feed and Close LOG fwrite ($log, "\n");fclose ($log); Thanks for looking
  10. Hi, I am having an issue with certain browsers not being able to receive the data from a $POST form. Could anyone advise a way of getting it to log what is being passed from the form and place it in a text file please? <html> <body onLoad="document.myForm.submit();"> <form action="https://secure2.epdq.co.uk/cgi-bin/CcxBarclaysEpdq.e" method="post" name="myForm"> <?php $user_agent = "Mozilla/5.0 (compatible; MSIE 5.01; Windows NT 5.0)";?> <? foreach($_POST as $i => $v) { ?> <input type="hidden" name="<?= $i ?>" value="<?= $v ?>" /> <? } ?> <input type="submit" value="If you are not automatically redirected, please click here" /> </form> </body> </html>
  11. ​Ha! Thats what I am finally getting round to doing! Please ignore the html and the way I have posted, I have just cleared out the code to post here. I'll go through your post and see what I can do, Many thanks for helping (again)
  12. Hi, I have this code that runs a simple shopping cart. I'm having an issue where the basket quantities are only updating when there is 1 or 2 lines of products in there. Any more than that and the line keep defaulting back to quantity 1 Is there anything obvious that I have got wrong here? Thanks. <?phpheader("Content-type: text/html; charset=utf-8");session_start(); include_once("head.php");include_once("usr_conn.php");if(!connectDB()) { echo "<p>Unable To Connect To Database</p>"; return; } if (isset ($_GET['src'])) { $_SESSION['returnTo'] = $_GET['src']; } $urlref = $HTTP_REFERER; $prodID = htmlentities ($_GET['productID']); $delete = htmlentities ($_GET ['delete']); $quantity = htmlentities ($_GET['quantity']); $updateQuantity = htmlentities ($_GET['updateQuantity']); $update = htmlentities ($_GET ['update']); $currency = "£"; // maximum querys per user basket $MAXBASKETQUERY = 25; // start the html table?> <?php// check if user has no cookie set if ($userID == "") { ?><div class="alert alert-danger">No Product Querys made yet </div> <?php return; } //if the updated quantity is 0 or blank remove item from basket if ($updateQuantity == '0'){ $delete = 'yes'; } if (($update == 'yes')&& ($updateQuantity == '')){ $delete = 'yes'; } // if delete parameter set to yes run the delete code if ($delete == 'yes') { // if prodID is set, delete that specific product from this userID's basket if ($prodID != "") { $sqlquery = "DELETE FROM basket WHERE userID = '" . $userID . "' AND productID = '" . $prodID . "'"; $result = mysql_query($sqlquery); if ($result) { ?> <div class="alert alert-danger">Item Deleted. Click <a href="update.php"><font color="#990000">Here</font></a> to refresh the basket </div><?php } else { ?> <div class="alert alert-danger">Unable To Delete <br /> Item Click <a href="update.php">Here</a> to refresh the basket</div> <?php } mysql_close(); return; } } //update the shopping basket quantity if ($update == 'yes') { // if prodID is set, delete that specific product from this userID's basket if ($prodID != "") { $sqlquery = "UPDATE basket SET quantity = '" . $updateQuantity . "' WHERE productID = '" . $prodID . "'AND userID = '" . $userID . "'"; $result = mysql_query($sqlquery); if ($result) { ?> <div class="alert alert-danger">Your basket has been updated.</div> <?php } else { ?> <div class="alert alert-danger">Your basket has NOT been updated</div> <?php } } } // find the number of rows in this userID's basket $sqlquery = "SELECT * FROM basket WHERE userID = '" . $userID . "'"; $result = mysql_query($sqlquery); if (!$result) { echo "<p><font class=error>Could not find any entrys for this Basket</small></p>"; mysql_close(); return; } else $rowCount = mysql_num_rows($result); // if prodID is set new product is passed in, add/update the userID's basket if ($prodID != "") { // find if the prodID already exists in this userID's basket $sqlquery = "SELECT * FROM basket WHERE userID = '" . $userID . "' AND productID = '" . $prodID . "'"; $result = mysql_query($sqlquery); $rowCount = mysql_num_rows($result); // if no matches insert the product into the userID's basket if ($rowCount == 0) { // find number of items in basket $sqlquery = "SELECT * FROM basket WHERE userID = '" . $userID . "'"; $result = mysql_query($sqlquery); $rowCount = mysql_num_rows($result); // check if the maxquery's has been reached if ($rowCount > ($MAXBASKETQUERY - 1)) { echo ("<p><font class=error>Only $MAXBASKETQUERY overall orders are allowed, your product could not be added to basket</font></p>"); } else { $expiretime = time() + 7200; $sqlquery = "INSERT INTO basket" . $basketFields . "VALUES ('" . $prodID . "', '1', '" .$userID . "', '" . $expiretime . "')"; $result = mysql_query($sqlquery); if (!$result) echo "<font class=error><p>Could not add item to Basket</p></font>"; } } } // select the userID's basket query and the Product Reference relating to each of the basket's productID's $sqlquery = "SELECT products.Prod_REF, basket.productID, basket.quantity, products.Prod_Make, products.Prod_Model, products.Prod_Type, products.Car_Make, products.Car_Model, products.Price_ExVat, products.Post_ID, Product_Desc FROM basket INNER JOIN products ON basket.productID = products.Prod_ID WHERE ((basket.userID) = '" . $userID . "')"; $result = mysql_query($sqlquery); $rowCount = mysql_num_rows($result); // echo $sqlquery; // *debug // assign the table headers //$dbFields = array( "Reference", "Product Query"); // check if no entries in basket if (!$result || (mysql_num_rows($result) == 0)){ ?> <div class="alert alert-danger">No Product Queries In Basket.</div> <?php } else //*************display contents of basket////////////////////////////////////////////////////// { // echo each header from array //foreach ($dbFields as $headIndex) // echo an extra blank header for the delete item column // fetch each row as an associative array $counter = 1; $price = 0; //set default postage value outside loop$postagerate = 15.00; while ($row = mysql_fetch_assoc($result)){ //decide which postage value is the highest and use that to calculate overall price //get the postage values for each product $sqlpostquery = "SELECT * FROM postage WHERE Post_ID = '" . htmlspecialchars($row['Post_ID']) . "'"; //get the postage values from the database $postresult = mysql_query($sqlpostquery); $rowpost = mysql_fetch_assoc($postresult); // check if postage value was available if ($postresult || !(mysql_num_rows($postresult) == 0)) { $rawpostage = htmlspecialchars($rowpost['Post_Cost']) ? htmlspecialchars($rowpost['Post_Cost']) : 0.00; //get the lowest postage rate. if ($postagerate > $rawpostage) { $postagerate = $rawpostage; } } else { $postagerage = 0.00; } //round postage rate of 2 decimal places $postagerate = $postagerate; //release the postage resultset array mysql_free_result($postresult); echo "<form action=basket.php method=get name=form".$counter."> <input name=update type=hidden value=yes> <input name=productID type=hidden value=". $row['productID'] ."><tr class=stdtable>"; ?> <form method="post" action=""> <table border="0" cellspacing="0" cellpadding="0" width="100%" class="responsive shop_table cart" data-responsive-mode="stack"> <thead> <tr> <th>Part No.</th> <th >Description</th> <th>QTY</th> <th>ex vat</th> <th>inc vat</th> <th>Total Price</th> <th>Remove</th> </tr> </thead> <tbody> <tr> <!-- This is the block that will echo the basket columns --> <td class= partno table-striped mb-none><?php echo("" . htmlspecialchars($row['Prod_REF']) . "");?></td> <td class= descrip table-striped mb-none><?php echo("" . htmlspecialchars($row['Product_Desc']) . "");?></td> <td class= table-striped mb-none><?php echo (" <input name=updateQuantity onchange=submit(); type=text size=2 value=". htmlspecialchars($row['quantity']));?> </td> <td class= table-striped mb-none><?php echo ("". $currency . number_format(htmlspecialchars($row['Price_ExVat']), 2) ."");?></td> <td class= table-striped mb-none><?php echo ("". $currency . number_format(calcVAT($row["Price_ExVat"]), 2) ."");?></td> <td class= table-striped mb-none><?php echo ("". $currency . number_format(((calcVAT($row["Price_ExVat"]* $row['quantity']))), 2) ."");?></td> <td class= table-striped mb-none><?php echo " <a href=\"basket.php?delete=yes&productID=" . $row['productID'] . "\"> <i class=\"fa fa-times\">"; ?></td> </tr> </table> <!-- End of this section --> <?php $counter ++; //get a cumulative value of the price as items are added to the basket and multiply by quantity as we go. $price = $price + (calcVAT (htmlspecialchars($row['Price_ExVat']))) * htmlspecialchars($row['quantity']); } //assign subtotal and round to 2 decimal places $subtotal = $price; $total = $subtotal + $postagerate; //pick overall postage type if ($postagerate == 5) $postage = 3; else if ($postagerate == 9) $postage = 2; else if ($postagerate == 10) $postage = 1; } //update shopper table with new/changed info $sqlshopper = "SELECT * FROM shopper WHERE User_ID = '" . $userID . "'"; //echo "query: " . $sqlshopper; $result = mysql_query($sqlshopper); $rowCount2 = mysql_num_rows($result); //add shopper if ($rowCount2 == 0) { $sqladd = "INSERT INTO shopper" . $shopperFields . "VALUES ('" . $userID . "', '" . $total . "', '" . $postage . "')"; //echo "noshopper: " . $sqladd; $shopadd = mysql_query($sqladd); if (!$shopadd) echo "<font class=error><p>Your basket has not been processed</p></font>"; } else { //update details $sqlupdate = "UPDATE shopper SET Basket_total = '" . $total . "', Postage = '" . $postage . "' WHERE user_ID = '" . $userID . "'"; //echo "shopper: " . $sqlupdate; $shopupdate = mysql_query($sqlupdate); if (!$shopupdate) echo "<font class=error><p>Your basket has not been updated</p></font>"; } // finish table ?> <?php echo $currency; echo number_format($subtotal, 2); ?></span></td></tr><tr class="shipping" style="font-size: 18px"><th>Delivery</th><td><span class="header"> <?php echo $currency; echo number_format($postagerate, 2); ?></span></td></tr><tr class="total"><th><strong>Order Total</strong>(inc vat)</th><td><strong><span class="amount"><?php echo $currency; echo number_format($total, 2); ?></span></strong> </form><?php mysql_free_result($result); mysql_close(); ?>
  13. Ok, That makes sense. That is exactly what I am trying to do - doing it is another thing altogether! I will start to clear up the code as you have suggested and see what I can do.
  14. This code was written years ago so I am now trying to sort the styling out with CSS and removing all the inline stuff. Also, there is so much code that as you've advised, needs streamlining...... Ok, I have made a quick example image of what I am trying to achieve, The database is populated by uploading a CSV file. Each section of the results has a unique code (RB, BH, RA etc) I want each section to appear in the divs as in the picture (div-RB, div-BH, div-RA)
  15. Thanks, I do want the data displayed in a table but I want the sections separated into different coloured divs. At the moment, the code just tells each section which header image to use.
  16. Hi, Please have a look at this code that I have - it is the results page of a "make" & "model" vehicle search. It displays the product results in a table in sections depending on the case that has been entered to populate the database. I am trying to clean up all of this code and incorporate it into Divs instead of tables. My question is how would I go about structuring this to display the results in different divs rather than the coloured tables that it is now doing. Any help would be great. <?php //info bars colour$color_info="#D6D685"; // Almost Silver //FFFFCC$color1="#E9E9E9";// Light Blue$color2="#EAD5FF";// Light Blue include_once("func_lib.php");include_once("usr_conn.php");if (!connectDB()){echo "<p>Unable To Connect To Database</p>";return;}if (($_GET ['make'] == "MAKE") or ($_GET ['model'] == "MODEL")){$errMessage = "<br><br><b><font class=small>Your search hasn't returned any results, please re-enter your search again.</font></b><br><br><a href=van_accessories.php>Search again</a><br><br>"; }else{$strMake = mysql_escape_string($_GET ['make']);$strModel = mysql_escape_string($_GET ['model']);}$strDefaultProd = "XD";//write query string that will pased in paging links$strQuery = "make=".$strMake."&model=".$strModel."&";//echo $strQuery;$page = mysql_escape_string($_GET ['page']);$sqlSelect = "SELECT Prod_ID, Prod_Type, Prod_Model, Prod_Make, Prod_REF, Product_Desc, Price_ExVat, image_name FROM products";$criteria = " WHERE (Car_Make = '".$strMake."' AND Car_Model = '".$strModel."' AND Default_Code = 'CV') OR (Car_Make = '".$strMake."' AND Car_Model = '".$strModel."' AND Default_Code = 'LE') OR (Car_Make = 'all' AND Default_Code = 'RA')";$sqlquery = $sqlSelect . $criteria; $result = mysql_query($sqlquery);$count = mysql_num_rows($result);$full_count = $count; $records_per_page = 999;$total_pages = ceil( $count / $records_per_page );if ( $page == "" ) { $page = 1; }if ( $page == 1 ) { $naviagation = "<font color=\"#666666\">First</font> | <font color=\"#666666\">Prev</font> | "; } else { $prev_page = $page - 1; $navigation = "<a href=\"van_roof_rack_results.php?".$strQuery."page=1\">First</a> | <a href=\"van_roof_Rack_results.php?".$strQuery."page=".$prev_page."\">Prev</a> | ";}if ( $page == $total_pages ) {} else { $next_page = $page + 1; $navigation .= "<a href=\"van_roof_rack_results.php?".$strQuery."page=".$next_page."\">Next</a> | <a href=\"van_roof_rack_results.php?".$strQuery."page=".$total_pages."\">Last</a>";}$offset = ( $page - 1 ) * $records_per_page;$sqlSelect = "SELECT Car_Make, Car_Model, Prod_ID, Prod_Type, Prod_Model, Prod_Make, Priority, Prod_Code, Prod_REF, Product_Desc, Price_ExVat, Link, image_name FROM products";$criteria = " WHERE (Car_Make = '".$strMake."' AND Car_Model = '".$strModel."' AND Default_Code = 'CV') OR (Car_Make = '".$strMake."' AND Car_Model = '".$strModel."' AND Default_Code = 'LE') OR (Car_Make = 'all' AND Default_Code = 'RA')"; $limit = " ORDER BY Priority ASC, Prod_Code ASC, Prod_ID ASC LIMIT $offset, $records_per_page";$sqlquery = $sqlSelect . $criteria . $limit ;$result = mysql_query($sqlquery);if (!$result || (mysql_num_rows($result) == 0)){}else{$count = mysql_num_rows($result); }?> <h1><?php echo("<font class=vehicle> " . $strMake . " " . $strModel ."</p>"); ?></h1> <!--Start of results code --> <?php $title .= "</tr>"; //set the counters for the records results display screen$cnt = 0;$headercount1 = 0;$headercount2 = 0;$headercount3 = 0;$headercount4 = 0;$headercount5 = 0;$headercount6 = 0;$headercount7 = 0;while ($row = mysql_fetch_assoc($result)){$strLength = strlen ($row["Prod_Type"]);$strPrefix = substr($row["Prod_Type"], 0, 2);$strSuffix = substr($row["Prod_Type"], 2, $strLength);echo "<tr align=center><td colspan=7 class=small>"; //set bg cell color diff for BH makeswitch ($strPrefix){case "BH":$color=$color2;break; default:$color=$color1;break;}//end switch switch ($strPrefix){ case "BH": if ($headercount1 == 0) { echo "<img border=0 src=bulkheads.jpg alt=Bulkheads></td></tr>";echo $title;}$headercount1 ++; //$headercount1 break; case "RB": if ($headercount2 == 0){echo "<img border=0 src=roofracks.jpg alt=Roof-Bars></td></tr>";echo $title;} $headercount2 ++; //$headercount1 break; case "BX": if ($headercount3 == 0){ echo "<img border=0 src=bulkheads.jpg alt=Roof-Boxes></td></tr>";echo $title;}$headercount3 ++; //$headercount1 break;case "BR": if ($headercount4 == 0) { echo "<img border=0 src=bulkheads.jpg alt=Bike-Racks></td></tr>"; echo $title; } $headercount4 ++; //$headercount1 break;case "SR": if ($headercount5 == 0) {echo "<img border=0 src=bulkheads.jpg alt=Ski-Rack></td></tr>";echo $title;} $headercount5 ++; //$headercount1 break;case "CR": if ($headercount6 == 0) {echo "<img border=0 src=bulkheads.jpg alt=Canoe-Rack></td></tr>"; echo $title;} $headercount6 ++; //$headercount1 break; case "XD": if ($headercount7 == 0) { echo "<img border=0 src=general.jpg alt=General-Accessories></td></tr>";echo $title; } $headercount7 ++; }//print a product row if the prodtype isn't set to INFO$pop_link = "";if ($strSuffix != "INFO"){//test to see if an image exists for the productif ($row["Link"] <> NULL){$pop_link = " <a href=\"products/".$row["Link"]."?iframe=true&width=650&height=500\" rel=\"prettyPhoto\" >More information >>>></a>";}?> <?PHP if (isset($errMessage)){echo $errMessage;}if (!$result || (mysql_num_rows($result) == 0))echo ("<b><font class=small>Product Tyoe Not Found For Your Vehicle.</font></b><br><br>");// display the resultselse{// use rowcount to display total results found//*debugecho $navigation;}?> <?php $title = "<tr align=\"center\" class=\"headertable\" height=\"32\">"; $title .= "<td width=\"2%\"><img src=\"images/transparent.gif\" width=\"95\" height=\"1\" /></td>"; $title .= "<td width=\"2%\">Make</td>"; $title .= "<td width=\"1%%\">Ref No.</td>"; $title .= "<td width=\"1%\">Title/Description</td>"; $title .= "<td width=\"1%\">Price Ex VAT</td>"; $title .= "<td width=\"73\">Price Inc VAT</td>"; $title .= "<td width=\"60\"><img src=\"2003/basket.gif\" width=\"21\" height=\"14\"></td>"; $title .= "</tr>"; $cnt = 0;$headercount1 = 0;$headercount2 = 0;$headercount3 = 0;$headercount4 = 0;$headercount5 = 0;$headercount6 = 0;$headercount7 = 0;while ($row = mysql_fetch_assoc($result)){$strLength = strlen ($row["Prod_Type"]);$strPrefix = substr($row["Prod_Type"], 0, 2);$strSuffix = substr($row["Prod_Type"], 2, $strLength);echo "<tr align=center><td colspan=7 class=small>"; //set bg cell color diff for BH makeswitch ($strPrefix){case "BH":$color=$color2;break; default:$color=$color1;break;}//end switch switch ($strPrefix){ case "BH": if ($headercount1 == 0) { echo "<img border=0 src=bulkheads.jpg alt=Bulkheads></td></tr>";echo $title;}$headercount1 ++; //$headercount1 break; case "RB": if ($headercount2 == 0){echo "<img border=0 src=roofracks.jpg alt=Roof-Bars></td></tr>";echo $title;} $headercount2 ++; //$headercount1 break; case "BX": if ($headercount3 == 0){ echo "<img border=0 src=bulkheads.jpg alt=Roof-Boxes></td></tr>";echo $title;}$headercount3 ++; //$headercount1 break;case "BR": if ($headercount4 == 0) { echo "<img border=0 src=bulkheads.jpg alt=Bike-Racks></td></tr>"; echo $title; } $headercount4 ++; //$headercount1 break;case "SR": if ($headercount5 == 0) {echo "<img border=0 src=bulkheads.jpg alt=Ski-Rack></td></tr>";echo $title;} $headercount5 ++; //$headercount1 break;case "CR": if ($headercount6 == 0) {echo "<img border=0 src=bulkheads.jpg alt=Canoe-Rack></td></tr>"; echo $title;} $headercount6 ++; //$headercount1 break; case "XD": if ($headercount7 == 0) { echo "<img border=0 src=general.jpg alt=General-Accessories></td></tr>";echo $title; } $headercount7 ++; } //print a product row if the prodtype isn't set to INFO $pop_link = "";if ($strSuffix != "INFO"){//test to see if an image exists for the productif ($row["Link"] <> NULL){$pop_link = " <a href=\"products/".$row["Link"]."?iframe=true&width=650&height=500\" rel=\"prettyPhoto\" >More information >>>></a>";}echo "<tr class=stdtable align=center height=25>"; //DISPLAY THUMB IMAGE IF ONE WAS LISTED IN THE image_name FIELD$p_image_name = htmlspecialchars($row["image_name"]);//echo "p_image_name:$p_image_name";if ($p_image_name != "")echo "<td bgcolor=$color width=\"95\"><img src=\"images/product_images/$p_image_name\" border=\"0\" /></td>";elseecho "<td bgcolor=$color width=\"95\"><img src=\"images/transparent.gif\" width=\"95\" height=\"50\" border=\"0\" /></td>";echo "<td bgcolor=$color width=\"60\">". htmlspecialchars($row["Prod_Make"]) ."</td><td bgcolor=$color width=\"60\">" . htmlspecialchars($row["Prod_REF"]) . "</td><td bgcolor=$color align=left class=\"infolink\" width=\"550\">" . htmlspecialchars($row["Product_Desc"]) .$pop_link . "</td><td bgcolor=$color width=\"73\">£" . number_format(htmlspecialchars($row['Price_ExVat']), 2) ."</td><td bgcolor=$color width=\"73\">£" . number_format((calcVAT (htmlspecialchars($row['Price_ExVat']))), 2) ."</td><td class=\"btn btn-default btn-sm\"><a href=basket.php?src=".urlencode($_SERVER['REQUEST_URI'])."&productID=" . $row["Prod_ID"] . ">BUY</a></td></tr>";}// if the prod type is set to INFO then print out a new row for that informationelse { echo "<tr class=stdtable align=center height=25 ><td colspan=7 bgcolor=$color_info><em><strong>" . htmlspecialchars($row["Product_Desc"]) . "</strong></em></td></tr>"; } } ?> <?phpmysql_free_result($result);mysql_close();}}?>
×
×
  • 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.