
denno020
Members-
Posts
761 -
Joined
-
Last visited
-
Days Won
3
Everything posted by denno020
-
Have you tried adding background-size: cover; see http://css-tricks.com/perfect-full-page-background-image/ Hope that helps, Denno
-
If it only displays once, when you first login, and then never again, you will most likely want a database table which will store the ID's of users who have 'seen' the special offer. When your page loads, query the database, see if the user is in the table already, if not, use whatever method to like to display the special offer. If you choose to use javascript to animate a dialog (or whatever), then you will need to set a flag somewhere in your HTML that the javascript can check when the DOM is ready, which will indicate to the javascript to perform the code that will show the special offer. Hope that helps, Denno
-
What are some practical uses for callback functions?
denno020 replied to CrimpJiggler's topic in PHP Coding Help
Unlike when you execute php on the command line, output is only output once, at the end of the script execution. So when you execute your script, it will place all of your echo's into the output buffer, and then when the script has finished, it will then put print the output buffer to the screen. -
The reason is when you submit the form, $arrayIndex is populated with another random answer, because the script is run again from the start. What you need to do is store the answer some other way, and check against that. You can used a session variable for that. Also, move the answer check to the beginning of the script, so the first thing that it does is check for a submit. See the following: if (isset($_POST['submit'])) { if ($_POST['answer'] == $_SESSION['answer']) { echo "correct"; } else { echo "incorrect"; } } else { echo "Answer this:"; } $question = array( 0 => array( 'question' => "1+1=", 'answer' => 2 ), 1 => array( 'question' => "2+1=", 'answer' => 3 ), 2 => array( 'question' => "4+1=", 'answer' => 5 ) ); $arrayIndex = array_rand($question); $q = $question[$arrayIndex]['question']; $a = $question[$arrayIndex]['answer']; $_SESSION['answer'] = $a; print $a; print (" <form method='post'><br/> <input type='text name='" . $a . "' value='" . $q . "'> <input type='text' name='answer'><br/> <input type='submit' name='submit'><br/> </form> "); Denno
-
the html_table macro is expecting strings in a single array. You can achieve it like this: Your $table array needs to be a single array, with all of the elements that you want. Then in your smarty template, you tell the macro how many columns there are to be in the table, lets use 5 as an example. Smarty will then take the first 5 elements in the array, and print them in the first row, it will then print the next 5 elements on the next row, and so on. The trick with your table is that you will have empty strings in your array, which will be taking up the extra columns in the table for rows that have less fields. Have a crack at that and let us know how you go, if you need more help, come back with the code you've tried . Denno
-
Assuming that the field 'games played' represents that number of games that player with name 'name' played in the given year, set in the 'year' field, then you could do a simple SELECT COUNT() for each field that you need tallies for. This would obviously mean that for each player that's played more than one year, they'll have their name in the database more than one time. Usually the best idea would be to have the name in there only once, by normalizing your databases (I think it's called), to separate data out into related tables..
-
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean
denno020 replied to yoyo's topic in PHP Coding Help
Looks like your query has failed for some reason. Hence why a boolean (false) is being passed to mysql_fetch_array -
This is how I thought it had to be done: $assets = array(); $assets[] = array( 'locationID' => $row['locationID'], 'itemID' => $row1['itemID'], 'typeID' => $row1['typeID'], 'quantity' => $row1['quantity']); But apparently it doesn't have to be done that way..
-
Are you getting any errors when you run this code? You haven't initialised $assets as an array, so php won't like you trying to append to the end of it with $assets[] = ...
-
I have used jQuery Form Plugin for this purpose before. It works well. http://malsup.com/jquery/form/#getting-started Denno
-
Ahh yes, the non-attendees, I forgot about them..
-
If I were to create database tables for this kind of thing, I would create 3 tables. People table - containing information about the People who attend the meetings; name, phone, any other info Meeting table - which will contain the date of a meeting, maybe some meeting notes or something Attendance table - which will contain 3 fields, ID (auto-generated, primary key), people_id, meeting_id. So for every person who attends, put their ID into a row, along with the ID of the meeting they attended. Then in PHP, you can perform queries with joins to join the three tables, and have all information about the meetings and who attended, at your disposal, to display on your page however you like. I'm not sure how that fits with the Normalisation that was suggested earlier, but I think it would be a fairly simple and effective way to store the information. Hope that helps Denno
-
Pick a random email address out of a maillist
denno020 replied to ionicle's topic in PHP Coding Help
Oops! I didn't even think.. -
I learnt PHP using YouTube. Specifically, from Adam Khoury (aka Flashbuilding). I strongly suggest you check out his videos at http://www.youtube.com/channel/UCpzRDg0orQBZFBPzeXm1yNg. I'm sure there would be links to his website on his YouTube channel. Better than a uni course (I have completed uni so I can compare), and it was free! Denno
-
Pick a random email address out of a maillist
denno020 replied to ionicle's topic in PHP Coding Help
The way I would do it is as follows: Loop through all email addresses, matching the domain name for each, and using that as a key in an array... actually it'll just be easier if I show you code $emailAddresses = array() //This is the email addresses you have to start with, it will hopefully be an array. If it's a string, use explode() to get it into an array $sortedEmails = array(); //Will store the sorted email addresses foreach ($emailAddresses as $emailAddy) { preg_match("/.*@(.*)$/", $emailAddy, $matches); $domain = $matches[1]; if (!isset($sortedEmails[$domain])) { //If the domain doesn't already have it's own array, create it $sortedEmails[$domain] = array(); } $sortedEmails[$domain][] = $emailAddy; //Add the email address to the end of the array for the domain } //Pick random email foreach ($sortedEmails as $domain) { echo $domain[rand(0, count($domain)-1]; //Pick a random number between 0 and the size of the array minus 1, which will effectively be a random index } Hopefully that helps. Denno -
You could possibly remove it by just using a preg_replace. $table = preg_replace("~.*<ul><li><a href='/'>Parent Directory</a></li>(.*)</ul>.*~" ,"\${1}", $content); I have no idea if that will work, I haven't tested it, but the theory is that it will match all text between the end of the first <li> to the start of the </ul> closing tag, and then put that into the $table variable. The other stuff will effectively be removed. Hopefully it gives you an idea Denno
-
You don't close the opening <a> tag with the '>' symbol $banner_location = "http://".$_SERVER['SERVER_NAME']."/images/".$page_language.".png" <a href="http://".$_SERVER['SERVER_NAME']."/tilfredshedsgaranti-".$page_language.;</a> should be (also note that the image was moved inside the <a> tags, and into an <img> tag). $banner_location = "<a href=\"http://".$_SERVER['SERVER_NAME']."/tilfredshedsgaranti-".$page_language."><img src=\"http://".$_SERVER['SERVER_NAME']."/images/".$page_language.".png\"/></a>"; //Or with single quotes so you don't have to escape the double quotes: $banner_location = '<a href="http://'.$_SERVER['SERVER_NAME'].'/tilfredshedsgaranti-'.$page_language.'><img src="http://'.$_SERVER['SERVER_NAME'].'/images/'.$page_language.'.png"/></a>'; This is making an assumption as to what you want. Hope that helps Denno
-
Ok, so what is the significance of the 10? Why are you counting to 10? I really need to know the structure of your webinvt.txt file if I'm going to be able to run any tests myself.. Just putting 'stuff' in there won't work, as you're echoing out array indexes of strings, which means it's only going to grab a single letter, which would actually be a number from the real data I would assume. To be honest, this is really a terrible way to manage your inventory, it's exceptionally clunky and nearly impossible to maintain. I suggest you put your efforts into a writing a script that will parse your webinvt.txt file, and instead of writing it to a html file, save it to a database. You can then use phpmyadmin to manage the values in the database, or you could write your own, very basic, CMS (content management system). But as I said, without knowing what each field in your txt file is supposed to be (they're not going to all be strings), it's incredibly hard for me to give you definitive help, without just throwing guesses at you..
-
So you have 20 elements on a line? I assume comma separated? As for your <head> tag, the following if part of the HTML that you just pasted before <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>CSV Contents</title> <link rel="stylesheet" type="text/css" href="/css/demo_page.css" /> <link rel="stylesheet" type="text/css" href="/css/demo_table.css" /> <style type="text/css"> <!-- .style5 {font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-weight: bold; } .style9 {font-size: 12px} .logo h1 {position: absolute; top: 5px; right: 5px; font-size:14px; } .logo img-with-text {float: left; left 5px; font-size:14px; .img-with-text {text-align: justify; width: 40%; height: 20%;} .img-with-text img {display: block; margin: 0 auto;} .search {margin : 0px;} --> </style> <script src="/js/jquery.js"></script> <script src="/js/jquery.dataTables.nightly.js"></script> <script src="/js/makedatatablesworkfunction.js"></script> <div class="img-with-text"> <img src="/csv/image002.png" alt="sometext" /> <p>"WC" is West Coast warehouse- please add approximately 2-3 weeks for the arrival to East Coast.<br><br> </p> </div> <div class="logo"> <br>Last Updated on November 5, 2013, 6:15 pm </h1> </div> </head> <!-- ========================== Notice the ending head tag here ======================== --> <body id="dt_example"> <div id="container"> This is where it needs to be: <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>CSV Contents</title> <link rel="stylesheet" type="text/css" href="/css/demo_page.css" /> <link rel="stylesheet" type="text/css" href="/css/demo_table.css" /> <style type="text/css"> <!-- .style5 {font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-weight: bold; } .style9 {font-size: 12px} .logo h1 {position: absolute; top: 5px; right: 5px; font-size:14px; } .logo img-with-text {float: left; left 5px; font-size:14px; .img-with-text {text-align: justify; width: 40%; height: 20%;} .img-with-text img {display: block; margin: 0 auto;} .search {margin : 0px;} --> </style> <script src="/js/jquery.js"></script> <script src="/js/jquery.dataTables.nightly.js"></script> <script src="/js/makedatatablesworkfunction.js"></script> </head><!-- =========New </head> tag position=============== --> <div class="img-with-text"> <img src="/csv/image002.png" alt="sometext" /> <p>"WC" is West Coast warehouse- please add approximately 2-3 weeks for the arrival to East Coast.<br><br> </p> </div> <div class="logo"> <br>Last Updated on November 5, 2013, 6:15 pm </h1> </div> <!-- =========Old </head> tag position=============== --> <body id="dt_example"> <div id="container">
-
Ok so I just looked at your first bit of code, as I didn't know what you meant by using the semi-colon for escaping. What you're actually doing is using the semi-colon to end the line for the string input of the html_body variable. To be honest, it's quite hard to follow your code. And also, I hope that that isn't the current HTML output, because you still have divs in the <head> tags. Can you attach your webinvt.txt file so I can actually run the script and see the output myself. Have you considered using a database? It would make this much easier, and I would think much quicker too, as you don't have to handle external files.
-
Yep you're spot on there. Good Luck
-
You can put $(document).ready(function () { $('#example').dataTable(); }); anywhere you want. You can put it in script tags in your document header (in between the <head> tags), you can put it in your body in between <script> tags, but ideally you'd have it in an external JS file. If you don't already have an external JS file, I would suggest adding it to the end of your <body> E.g. <!-- Rest of your page --> <script> $(document).ready(function () { $('#example').dataTable(); }); </script> </body> </html> Obviously make sure you give the table a valid id, and use that in place of 'example', and also make sure the datatables script is being imported correctly. Denno
-
Few things with your code. You have output in the <head> tags. This isn't a header tag, this is for document information, so you should remove the code from the head tags, and place it in either a div with id/class of header, or inside <header> tags that are inside the body tags. You also have an ending </h1> tag, but no opening <h1> tag. There are multiple divs that either aren't opened, or aren't closed. So you're going to need to clean up your code/output a fair bit, and once you've done that, you'll get something like this: http://jsfiddle.net/Gd9QW/ That works with the datatables. It looks terrible, there is no CSS, but it works. Change some of the content in the table cells, and you'll see the sorting work when you click on the column headers. Denno
-
Mate that's the PHP file. If you copy the source of the webpage, there will be no PHP in it. I just want to look at the finished product, not the script that makes it. I'll look at that later.
-
Can you actually copy and paste the HTML over from a rendered page? Saves me having to set up the script and get it rendering myself. Just open the page, view the source, then copy and paste it all here.