Jump to content

PaulRyan

Members
  • Posts

    876
  • Joined

  • Last visited

  • Days Won

    4

Everything posted by PaulRyan

  1. I see what you mean, you could try having hidden form fields in each form, to keep the data that has been selected already maybes? Look for the the code similar to this below and replace with the code below: <li><a href="searchtestingv6.php">All Acts</a></li> <li><a href="<?PHP echo '?categories=rockandpop&upto='. $upto .'&sort='. $sort .'';?>">Rock and Pop</a></li> <li><a href="<?PHP echo '?categories=tributebands&upto='. $upto .'&sort='. $sort .'';?>">Tribute Bands</a></li> <div id="sortingcontainer"> <span class="sortbyheader">Sort By:</span> <form action='?' method='get' name='form_filter' class="sortoptions" > <input type="hidden" name="upto" value="<?PHP echo $upto;?>"> <input type="hidden" name="categories" value="<?PHP echo $category;?>"> <select name="sort"> <option value="all">All</option> <option value="PriceLow">Price (Low to High)</option> <option value="PriceHigh">Price (High to Low)</option> </select> <br /> <input type='submit' value = 'Re-Order your results'> </form> <form action='?' method='get' name='form_filter' class="sortoptions" > <input type="hidden" name="sort" value="<?PHP echo $sort;?>"> <input type="hidden" name="categories" value="<?PHP echo $category;?>"> <select name="upto"> <option value="upto100">Up to £100</option> <option value="upto200">Up to £200</option> <option value="upto300">Up to £300</option> </select> <input type='submit' value = 'Re-Order your results'> </form> </div> Regarding the code to select all records, it should work with the code I have given you, I'm guessing you maybes overwrite the query with your own code? Or don't have my code in the correct place.
  2. I'm guessing when selecting all, that you don't actually use a term when getting all records, so you don't need the last elseif in the code you posted. //### Check which category we are searching in if($category == 'rockandpop') { $queryOptions[] = "`category` = 'Rock and Pop'"; } else if($category == 'tributebands') { $queryOptions[] = "`category` = 'Tribute Bands'"; } It will return the following MySQL query, which is exactly what is needed to return all the records: SELECT * FROM `searchacts` Note: You should't use " * ", you should select only the columns you actually require to save on overhead and response. You do not need to touch the values of the select options, leave them as they were. Just plain values, the forms action takes care of everything else. You need to put my code BEFORE the links you output to the page, so before All Acts, Rock and Pop ect. This allows the links to take the values of the variables that are set based on the GET values in the URL. Also, like I said, COMMENT OUT the following lines: echo $finalQuery; echo '<br>'.$urlParameters; They should look like this: //echo $finalQuery; //echo '<br>'.$urlParameters;
  3. Hello again, I'm glad you found my code useful. You can comment out the following lines: echo $finalQuery; echo '<br>'.$urlParameters; These are only used to display the values of the the query and url parameters. The variable $finalQuery is used in the MySQL, like this: $result = mysql_query($finalQuery); This part: <li><a href="?categories=rockandpop">Rock and Pop</a></li> Should look like this, add the href to the other links and change the category to the correct value: <li><a href="<?PHP echo '?categories=rockandpop&upto='. $upto .'&sort='. $sort .'';?>">Rock and Pop</a></li> The backticks are used in the MySQL query to surround the table and column names, it also allows you to use keywords as both the table and column names (I think) I just use them as it makes it look neater as you know where the names of the table and column start and end. Regards, PAulRyan.
  4. Try something like this: Edit: I hate the code formatter. <?PHP //### Initialize variables $category = isset($_GET['categories']) ? $_GET['categories'] : FALSE ; $sort = isset($_GET['sort']) ? $_GET['sort'] : FALSE ; $upto = isset($_GET['upto']) ? $_GET['upto'] : FALSE ; //### Create the URL parameters $urlParameters = '?categories='. $category .'&upto='. $upto .'&sort='. $sort .''; //### Start the query variable $query = 'SELECT * FROM `searchacts`'; //### Initialize query options $queryOptions = array(); //### Now check each of the sorting values //### Check which category we are searching in if($category == 'rockandpop') { $queryOptions[] = "`category` = 'Rock and Pop'"; } else if($category == 'tributebands') { $queryOptions[] = "`category` = 'Tribute Bands'"; } //### Check what value upto we are returning if($upto == 'upto100') { $queryOptions[] = "`price` <= 100"; } else if($upto == 'upto200') { $queryOptions[] = "`price` <= 200"; } //### Create final query $finalQuery = $query. ' WHERE '.implode(' AND ', $queryOptions); //### Add the order by to the end of the query if($sort == 'PriceLow') { $finalQuery .= ' ORDER BY `price` ASC'; } else if($sort == 'PriceHigh') { $finalQuery .= ' ORDER BY `price` DESC'; } //### Final query to search and return records from database echo $finalQuery; //### URL parameters, add this to the form action echo '<br>'.$urlParameters; ?> <form method="GET" action="<?PHP echo $urlParameters;?>"> <input type="text" name="sort" value="<?PHP echo $sort;?>"> <input type="text" name="upto" value="<?PHP echo $upto;?>"> <input type="text" name="categories" value="<?PHP echo $category;?>"> <input type="submit" value="Submit"> </form>
  5. You use $_POST['Submit'] to check for the form being posted, yet you haven't actually set the submit buttons name to "Submit". Try that, or using: if($_SERVER['REQUEST_METHOD'] == 'POST') { //### Process for here }
  6. You should read the information on positing. You have not psoted any relevant information, for example the table structure, full code and not a snippet. You also need to tell us exactly what's happening, error messages ect.
  7. This: if($profileid = $followerid) { Should be: if($profileid == $followerid) {
  8. You need to put quotes around your input values: <input type="text" name="FName" value="<?php echo $FName;?>"> Otherwise it will only show up to the first space as it thinks that is the end of the value.
  9. What is your table structure? Post it here, so I can have a play about.
  10. <?PHP include('../config.php'); if($_SERVER['REQUEST_METHOD'] == 'POST') { $Name = isset($_POST['Name']) ? mysql_real_escape_string($_POST['Name']) : false ; $LessonDate = isset($_POST['LessonDate']) ? mysql_real_escape_string($_POST['LessonDate']) : false ; $StartTime = isset($_POST['StartTime']) ? mysql_real_escape_string($_POST['StartTime']) : false ; $EndTime = isset($_POST['EndTime']) ? mysql_real_escape_string($_POST['EndTime']) : false ; if(empty($Name) || empty($LessonDate) || empty($StartTime) || empty($EndTime)) { echo '1 or more of the required fields are missing.'; } else { $checkBookingQuery = "SELECT `LessonDate` FROM `booking` WHERE `LessonDate` = {$LessonDate} AND (StartTime >= '{$StartTime}' AND StartTime <= '{$EndTime}')"; $checkBooking = mysql_query($checkBookingQuery); if(mysql_num_rows($checkBooking)) { echo 'This booking slot has already been taken. <a href="booking1.php">Please select a different slot</a>'; } else { $insertBookingQuery = "INSERT INTO `booking` (`Name`, `LessonDate`, `StartTime`, `EndTime`) VALUES('{$Name}', '{$LessonDate}', '{$StartTime}', '{$EndTime}')"; $insertBooking = mysql_query($insertBookingQuery); if(!mysql_affected_rows()) { echo 'Unable to insert booking.'; } else { echo 'Booking has been successfully place. <br> <a href="text.php">Send reminder text?</a>'; } } } } ?>
  11. Again, you come up trumps! I've never done anything like this before, but now I know where to look, thanks again Barand (:
  12. echo ("<center> <font color=#FF0000 face=Verdana size=2><b>{$row['code1']}</b></font>"); *Edit: This is in response to your first post.
  13. Personally, I would run a cron job at the start of each day, to fetch the sunrise and sunset times, then either save the values to a text file, or in a database depending on your needs. Then you could use something like this: <?PHP //### Turn on error reporting error_reporting(E_ALL); ini_set("display_errors", 1); //### Set default timezone date_default_timezone_set('Europe/London'); //### Turn time into seconds [E.G. '7:10 AM' returns 25800] function timeToSeconds($time) { //### Check if it is AM or PM $timeOfDay = strtoupper(substr($time,-2)) == 'AM' ? 0 : 43200 ; //### Explode the time to get hours and minutes $explodeTime = explode(':', substr($time,0, -3)); //### Convert the hours to seconds $hoursToSeconds = (date('g') > $explodeTime[0]) ? (($explodeTime[0])*60*60)+$timeOfDay : (($explodeTime[0])*60*60); //### Convert the minutes to seconds $minsToSeconds = ($explodeTime[1]*60); //### Return the amount of seconds from time given return intval($hoursToSeconds+$minsToSeconds); } //### Convert the sunrise and sunset times to seconds $sunrise = timeToSeconds('7:10 AM'); $sunset = timeToSeconds('5:19 PM'); //### How many stages do you want? $stages = 10; //### Work out how long each stage is in seconds $stageSeconds = (($sunset-$sunrise)/$stages); //### Get the current time in seconds $currentSeconds = (timeToSeconds(date('g:i A'))+intval(date('s'))); //### Calculate the current stage of the day $currentStage = floor(($currentSeconds-$sunrise)/$stageSeconds); //### If the current stage is not valid, make it valid if($currentStage < 0 || $currentStage > $stages) { $currentStage = 0; } $stageColours = array(0 => '#111', //### This is the colour for when the sun has set or has not risen 1 => '#222', 2 => '#333', 3 => '#444', 4 => '#555', 5 => '#666', 6 => '#777', 7 => '#888', 8 => '#999', 9 => '#AAA', 10 => '#BBB'); echo $stageColours[$currentStage]; ?> You would obviously have to substitute the sunrise and sunset times that are hard coded with the values you have saved from where ever you get the sunrise and sunset times from. *Edit: Changed ROUND() to FLOOR() for better results.
  14. <?PHP //mysqli_stmt_fetch ($stmt); while (mysqli_stmt_fetch($stmt)) { $subject = $stmt['subject']; $cutOff = 70; //### Define how many characters you want to display. if(strlen($subject) > $position) { $findSpace = strpos($subject, ' ', $cutOff); //### Find first space after cutoff point $subject = substr($subject, 0, $findSpace); //### Get the substr of subjects to display } echo '<h4><span>Subjects / </span>'. $subject .'.....</h4>'; } ?>
  15. Just realised that I had error reporting turned off on my local dev setup. Not sure why, but it's back on, thanks.
  16. This is how I would do it, it prevents injection from a rogue $_GET['id'] value. You would have to add in some more detailed error messages and log any queries that don't execute. <?PHP mysql_connect('localhost', 'root', '') or die('Could not connect to the server'); mysql_select_db('mproject') or die("Could not find the database"); //### Type cast value for MySQL safety $id = (int)$_GET['id']; //### Check if the id is empty if(!empty($id)) { echo 'No ID selected.'; } else { //### Create and execute query to delete project $deleteProjectQuery = "DELETE FROM `project_details` WHERE `id` = {$id}"; $deleteProject = mysql_query($deleteProjectQuery); //### Check if the MySQL query was executed successfully if(!$deleteProject) { echo 'Unable to delete selected project.'; } else { echo 'Successfully deleted select project.'; } } ?>
  17. I didn't know IE6 was one of them, I'm not surprised though. Thanks for pointing that out.
  18. @Jazzman: I believe they are browsers that run on other Operating Systems other than PC. Such as MAC, Linux, Unix etc. @Worldcom: I myself use a hidden input for forms, it works great if you have multiple forms on a page as some of my applications do.
  19. You don't need array() in the function arguements, this will suffice: preg_replace('/[0-9]/', '', $title);
  20. @worldcom: You shouldn't rely on the submit button name to be sent along with the form. Some browsers don't send the submit button along with the form, so you could miss out on some form submissions. Checking the request method is probably the most reliable, but don't quote me on that.
  21. Change this: $personsname=stripslashes ($row['$name']); = FRED BLOGS - correct To this: $personsname=stripslashes ($row['name']); = FRED BLOGS - correct *Edit: Barand beat me to it... *Edit 2: As Barand said, you don't need WHILE() for a single returned row. <?PHP if($result->num_rows > 0) { $row = $result->fetch_assoc(); echo stripslashes($row['name']); $personsname = stripslashes($row['name']); //### FRED BLOGS - correct echo "<p>name=$personsname</p>"; //### Empty? } ?>
  22. I fully intend to help out best I can, but I will not go any further than that and will certainly not be refunding the purchase value. I do like the "demo" thing, made me chuckle, just wish I thought of that at the time I'm just going by what the buyer told me, I have linked them to the 5 ways to fix the issue, otherwise they have to head to the Apple Shop and get some support from them. Just hope this isn't dragged out over the course of the dispute (8 days I think), just want the hold removed and to be able to get my freelance earnings out
  23. Hello all, I have recently sold an item on eBay, an Apple iPod Classic 80Gb. Everything was fine and dandy until I logged into my PayPal to see the value of the item had been held back by PayPal. I quickly went onto eBay to see what this was about, I noticed I had a dispute in the eBay resolution center and quickly checked it out. The buyer had disputed the purchase as they stated that the item was received corrupt and was unusable in its current state, I knew for a fine fact the item was fine as I had used it myself the day I posted it to the buyer. We had a little chat between us, to discuss the matter further, to which the buyer told me, they removed the Photos and Music from the device and continued to format the iPod, from which the device was then perceived to be corrupt by iTunes. The buyer then said to me that the item was never usable is state it was when the packaging was opened because it had my Photos and Music on (Which I did forget to remove, I admit fault for that), for them to know I had anything on the iPod, it must have been in working condition. I'm trying to resolve this with the buyer now, by suggesting possible fixes for the error, but I will get the claim escalated if nothing comes of the solutions I suggest, would I be right in doing so? What do you think of the above? Who is to blame? Look forward to your replies.
  24. $sqlget = "SELECT * FROM `XAGT` WHERE `input_body` = 'sedan' WHERE `input_vin` LIKE 'JG33M%' ORDER BY `input_build` ASC";
×
×
  • 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.