Jump to content

paddy_fields

Members
  • Posts

    172
  • Joined

  • Last visited

  • Days Won

    1

paddy_fields last won the day on February 28 2014

paddy_fields had the most liked content!

Profile Information

  • Gender
    Not Telling
  • Location
    Brighton

paddy_fields's Achievements

Member

Member (2/5)

8

Reputation

  1. I haven't read back through all of the pages of posts so sorry if this has been coverered - but it seems more sensible to not use forms, and just put your viewing counter processing code on the page of wherever you're hosting the movie itself Just loop out a set of url's instead of submit buttons <?php while($row = mysql_fetch_array( $result )) { $output.= "<a href='alldaymovies.php?filename=$row[filename]' target='_blank'>$row['filename']</a>"; $output.= "<br>"; } echo $output; The use of '_blank' forces a new window to be opened in the browser. Then at the top of the actual movie page... $filename = $_GET['filename']; $result2 = mysql_query("UPDATE DayMovie SET Counter=Counter+1 WHERE FileName='$filename'") or die(mysql_error()); you need to escape $filename as it's open to SQL injection
  2. I code in my own time, have done for many years. Although degree level at Computer Science I found myself in an unrelated job, but now want to make the jump into being a web dev. From the job vacancy specifications I see, most dev jobs don't just require PHP, OO, etc, they specifically ask for framework experience like Zend, or experience in platforms such as Joomla, Magneto etc. I don't have experience in any frameworks. Could anyone give me some advice on what it is I should focus my attention on learning to begin with? Is a framework like Zend a worthwhile starting point?
  3. I've finished the front end design of my application and now intend to provide a version to my potential users to gain feedback. Does anyone have any experience with the best methods of capturing this feedback? What methods have you used in the past? Questionnaires? I want feedback on things like the colour scheme, layouts, ease of use etc. From what I've read I can do things like a 1-5 satisfaction scale on multiple questions, but this seems a little vague
  4. You can use something like Whisk that allows you to add a widget to your site. It then sources the prices from the supermarkets.
  5. Hi. I have an HTML template that I'm going to use for my CMS, and need some advice on the best way to split it up into common elements used across all pages. I've identified the common HTML and have written functions to include each. I've used functions instead of directly including them on the page for flexibility in the future.(wise?) /* functions.php */ function show_style() { include_once 'module-style.php'; } function show_header() { include_once 'module-header.php'; } function show_sidebar() { include_once 'module-sidebar.php'; } function show_footer() { include_once 'module-footer.php'; } function show_js() { include_once 'module-js.php'; } And then on the page itself... <?php include_once 'functions.php'; ?> <!DOCTYPE html> <html lang="en"> <head> <title>My CMS</title> <meta charset="utf-8"> <?show_style()?> </head> <body> <?show_header()?> <!-- start section content--> <section class="section-content"> <?show_sidebar()?> <!-- start content --> <div class="content"> // PAGE CONTENT </div><!--/ end content --> </section> <!-- /end section content--> <?show_footer()?> <?show_js()?> </body> </html> A few questions - are there any issues with using the <? tag as opposed to <?php.... I've seen it used in templating before and want this to be as clean and readable as possible. Also would it be better to use a class for this, and include all of my functions within that class? Any advice or alternatives on the method used above would be great
  6. Turn on error reporting, and let us know which row is producing an error. error_reporting(E_ALL | E_NOTICE); ini_set('display_errors', '1');
  7. You won't learn unless you try to do it yourself, otherwise there's no point
  8. What exactly is it that you're struggling with? Do you want to know how to store information into a database? You need to read up on either Mysqli or PDO to learn how to insert the data. In terms of your script, you will make the database insert at the part where your validation returns no errors, ie the file type/size was accepted. You will then insert the variable which holds the file name into your database. Or create a flag such as $errors = FALSE at the start of the script; and any time the validation fails, make the flag TRUE. Then at the end simple do the following; if(!$errors){ // script to insert into database }
  9. Disead, you're making a connection called $mysqli, and then using $db.... $mysqli = new mysqli("localhost", "guestuser", "guestuser", "SMQ"); if ($mysqli->connect_errno) { echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error; } Update your query to this.... $stmt = $mysqli->prepare Also, is the table called 'SMQ', the database, or both? As you connect to a database called 'SMQ' and use it in your query also.
  10. Sorry, they were both typo's on my behalf while($row = $result->fetch_assoc()){ As CroNiX says you need to turn your error reporting on to see what the problem is... from what I can see you have a stray closing bracket in your bind_param() $stmt->bind_param('s',$validScott]);
  11. Actually, the table I've made is wrong, as the <tr> should be in the loop. But regardless you could also build the HTML immediately after the query like this: while($row = $result->fetch_accos()){ $queryResult.= " <tr> <td>$row[Scott]</td> <td>$row[Den]</td> <td>$row[Color]</td> </tr> "; } And then in the HMTL just echo out the $queryResult <table> <tr> <td>Scott</td> <td>Den</td> <td>Color</td> <tr> <?php echo $queryResult; ?> </table>
  12. Hi Firstly mysql_query is deprecated, so use a newer method like mysqli As this is just a search form and their doesn't appear to be any password data etc being queried i'd suggest using GET instead of POST for this (uses the URL instead) Here's something to get you started... it's untested but should give you an idea of how it works the form <form name="searchForm" method="GET" action="#"> <input type="text" name="scott"> <input type="submit" name="submit" value="Search"> </form> Put your processing PHP before the HTML, as it will need to execute first and then display the data within the HTML. To get the results (using prepared statements) // $db is the database connection, which you'll need to read up on // note: you need to validate the $_GET['scott'], this is just an example so i've left that out $validScott = $_GET['scott']; $stmt = $db->prepare('SELECT Scott, Den, Color FROM SMQ WHERE Scott = ?'); $stmt->bind_param('s',$validScott]); $stmt->execute; $result = $stmt->get_result(); $stmt->close(); Within the body of HTML <table> <tr> <td>Scott</td> <td>Den</td> <td>Color</td> </tr> <tr> <?php while($row = $result->fetch_assoc()){ ?> <td><?php echo $row['Scott']?></td> <td><?php echo $row['Den']?></td> <td><?php echo $row['Color']?></td> <?php } ?> </tr> </table>
  13. You could do something like this? $documentaries = array("A Great Film","A Not So Great Film","Brilliant Film","Chirpy Film"); $currentHeader = ''; foreach($documentaries as $documentary){ $headerCheck = substr($documentary,0,1); if($currentHeader!==$headerCheck){ echo '<h2>'.$headerCheck.'</h2>'; } $currentHeader = $headerCheck; echo $documentary; echo "</br>"; }
×
×
  • 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.