Jump to content

paddy_fields

Members
  • Posts

    172
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by paddy_fields

  1. Ok thanks, I understand. Good to know!
  2. That's great, thank you. Just to get my head around that... is $result an array with one value? And then list($totalJobCount) assigns that array item to $totalJobCount?
  3. Hi. I was using the method below to count the rows in a table, but I've since learnt I should be using SQL Count. Old method.... //total number of jobs if ($result = $db->query("SELECT * FROM jobBoard")) { $totalJobCount = $result->num_rows; $result->close(); echo $totalJobCount; } I've now changed this to.... //total number of jobs if ($result = $db->query("SELECT count(*) AS jobCount FROM jobBoard")) { $findCount = $result->fetch_assoc(); $totalJobCount = $findCount['jobCount']; $result->close(); echo $totalJobCount; } Is my new method the best way of doing this? It provides the correct result but I'm new to mysqli and I'm not sure if fetch_assoc() is the right way to go? Thanks. Pat.
  4. The PHP and HTML is quite seperated in the code you've posted. If you want the page to 'look nicer' then learn CSS and control the look and feel of the page that way. You can use a template if you wish, and then just copy your PHP code into it. You would just need to make sure that your form elements are still included to communicated with the PHP script. Otherwise, employ a designer. Also, put your PHP in the <head></head> of your document, it's much clearer and will cause you less problems in the long run if you try and echo data from PHP into the body of the HTML page.
  5. Good luck
  6. Note that you will need to read up on techniques to avoid SQL injection, as what I've suggested above is open to abuse if the GET value is not escaped correctly. Preferably learn mysqli or PDO, and read up on the use of prepared statements.
  7. Yes, you will use $_GET. So for example if your page id was '123' your url will be 'mypage.com/page.php?id=123' Then you would use $_GET to pull the id from the URL... $pageId = $_GET['id']; ... and using MySQL you would then look up in the database all of the details associated with the id '123' , with a query such as below; SELECT * FROM mytable WHERE `id` = '$pageId'
  8. SOLVED, sorry. ... but i can't work it out. all i want to do is; if ( $this_item exists within the table ) { do a } else { do b } for example, $this_item = 'john', and i want the script to do (a) if he's in the table, or (b) if he isn't. thank you!
  9. i am aware of that. i was using example you gave me to test the concept.
  10. yes, i was. my sql value is called eventgenre, not genre.
  11. ah, can't seem to get it working. it is telling me that this is an invalid sql argument. <?php include("connect.php"); $_GET['genre'][] = 'rock'; // simulate some data $_GET['genre'][] = 'pop'; $_GET['genre'][] = 'dance'; $genres = "'".implode("','",$_GET['genre'])."'"; $query = mysql_query("SELECT * FROM gig WHERE genre IN('$genres')"); $row = mysql_fetch_array($query); echo $row['gigid']; ?> am i being stupid?
  12. hi, happy new year. i am using an html form and checkboxes so a user can select one or more genres they want returned in a search. the values are sent via GET under the name genre[] so they are stored as an array. however, how do i use this with my sql query to select records that consist of any of the values of the array, eg... searching for rock, pop, dance will return any relevant events. i can assign each array value to it's own variable, but then i don't see how this works with SQL if i don't already know the number of genres being searched for. headache. any advice would be great. Pat.
  13. Hi there. I'm trying to create my own search function for users to search for events between certain dates. One option I have is 'within next 7 days'. So, within the SQL function I am searching "... WHERE eventdate between $from and $to.." The $from variable I figured would be $from = date('d-m-Y',time()); (ie- todays date)... but how would I find the date in 7 days?. I've seen strtotime mentioned about the web but can't figure how this applies. Any help would be marvelous! Cheers, Paddyfields.
  14. Typical. I search then internet for ages, post the question, then find the answer. FYI: http://net.tutsplus.com/tutorials/javascript-ajax/create-a-twitter-like-load-more-widget/
  15. Hi. I'm looking for a script similar to that used on Facebook when selecting the 'older posts' button to then call more comments from a database. I've seen Javascript with 'show/hide' functionality, but I don't think that's how this is achieved... as the load time would be huge if loading all the comments when the page is first loaded. I'm confident with SQL and PHP, but not with Javascript (which I believe this would require?) If anyone could point me in the right direction as how to achieve this I'd be grateful. Many thanks. Many thanks.
  16. Noted. I've updated that as well - working perfectly.
  17. Thank you. I was storing them in utc so I could sort by date.. but clearly what you've said would sort as well. I'll store them in the correct format from now on. Many Thanks.
  18. Hi there, I have dates saved in my database in utc format ie- 20100901 (yyyymmdd) for sorting purposes. Currently when I display them I use substr to grab the year, month and day. I was wondering if it's possible to use the date() function to manipulate the data into something like '01 September 2010'. I understand how to format with date(), such as D d Y etc.. but is it possible to apply this to my utc data? Cheers! paddyfields.
  19. FYI: Solved with the use of if(isset($_POST['submit'])).
  20. Hello everyone, this is my first post here! My question covers a PHP, SQL, and HTML so I apologise if this isn't the appropriate section to post this message. Outline to my problem: A user can search my database for a variety of events, which are then listed on a results form. Next to each result I have an option to add this event to the users personal area as a 'saved event' for future reference. Currently I have a solution whereby an HTML form sends an action to '#', inserts the event ID and member ID into the 'savedevent' table via a PHP/SQL function. The page then displays 'event added'. THIS WORKS. However, if the user navigates away from the page, and then back to it again, the PHP script is obviously run again, ie- a 'resend data' dialog box is displayed to the user, which I really don't want. This website:http://www.bandsintown.com/event/3988178-nme-awards-tour-2011-london-united-kingdom-live-at-o2-academy-brixton-on-february-19-2011 achieves exactly what I am trying to do with the 'attending' button, but I cannot figure out how they accomplish this. Any help and ideas would be greatly appreciated. Hello again, and thanks! paddyfields.
  21. You need to edit your permissions. Depending on the host, this can often be done via the user control panel they provide.
  22. You really should be asking the database to look for records where a USER ID is present, not the USER NAME. If you have more than one user named John Smith you are going to run into a hell of a lot of problems. Make USER ID the primary field in your table, with an AUTO_INCREMENT so that it will be unique.
×
×
  • 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.