Jump to content

Ch0cu3r

Staff Alumni
  • Posts

    3,404
  • Joined

  • Last visited

  • Days Won

    55

Everything posted by Ch0cu3r

  1. On line 9 you have an incomplete php tag, it should be <?php Also on line 14 you need to use the comparison operator == not the assignment operator = } while ($red == "exciting"); // ^ // needs to be the comparison operator If used the assignment operator you will end up with an infinite loop.
  2. What are you trying to do? Increment pad_count by a certain amount? There is no need for the select query to get the current pad_count. You can reference the pad_count column in your update query and do simple arithmetic $pad_id = 1; $add_pad_count = 2; // add 2 to the current pad_count column $sql = "UPDATE user SET pad_count = (pad_count + $add_pad_count) WHERE pad_id = $pad_id";
  3. Its hard to know what the problem is without the seeing the outputted HTML from the code you post. We do not have your database/values to reproduce the same output you are getting. If at all possible could you provide a link? If not post your outputted HTML and CSS code.
  4. Where did you add that line? It must be within the do {} statement not after the while condition. $red = "exciting"; do { echo "<p>It's $red to be red.</p>"; $red = false; // set $red to false to stop the loop } while ($red == "exciting");
  5. Cant really help you without seeing the code for include/fg_membersite.php. You need to post the code which is handling the ajax request. Ajax cannot call PHP functions. You can send a HTTP request to a PHP file yes, but its down to the logic in your php code for how PHP functions are called.
  6. Why have a prompt if you are providing a text field? I feel that is unnecessary. How about apply the required html5 attribute to the remarks and filename text fields. That way when the user attempts to submit the form the browser will highlight those text fields informing the user they must enter a value if they have left them blank.
  7. Change $classParent = ''; if ($level == 0) { $classParent = "class='parent'"; } foreach ($cats[$parent] as $id=>$nm) { to be foreach ($cats[$parent] as $id=>$nm) { $classParent = ($level == 0 && isset($cats[$id])) ? "class='parent'" : '';
  8. Yes it picks two random values. But you cant "get the sum of the two cards", You need to set your array as Barand suggested provided each cards value is unique for every color. Example code for picking two random values using array_rand and getting the sum of the chosen cards $cards = array ( 1 => 'Red', 2 => 'Yellow', 3 => 'Green', 4 => 'Red', 5 => 'Yellow', 6 => 'Blue', 7 => 'Yellow', 8 => 'Red', 9 => 'Yellow', 10 => 'Blue', 11 => 'Yellow', 12 => 'Green', 13 => 'Blue', 14 => 'Red', 15 => 'Blue', 16 => 'Green' ); $values = array_rand($cards, 2); echo "The two card picked are:<br />"; echo $cards[$values[0]] . " value is $values[0]<br />"; echo $cards[$values[1]] . " value is $values[1]<br />"; $sum = $values[0] + $values[1]; echo "The sum of the two cards picked is: $sum";
  9. Because the closing <li> tag needs to be echo'd after the if echo "<li $classParent><a href='#'><span>$nm</span></a>\n"; if (isset($cats[$id])) { displayMenuMobile($cats, $id, $level+1); //increment level } echo "</li>\n"; // closing </li> tags needs to be echo'd here } echo "</ul>\n"; // not here I pretty sure Jacques1 explained that last time
  10. Did you not learn anything from the last two topics you posted? Also when posting code please wrap it in tags or click the <> in the editor.
  11. If you want to diaplay the time on your page use the date function
  12. I'm not going to give you the code but I will split the question into easy to follow step to achieve the set task. Create a form with an input field for the name. Set the forms action attribute to submit.php (or to the name of your .php file) and set the forms method attribute to post then name the input field name. In the .php file your form submits to use the $_POST['name'] superglobal variable to get the name and assign it to variable, eg $name = $_POST['name']; Assign the suggest date code to a variable, name the variable hour, eg $hour = date('H'); To display the appropriate greeting depending on time of day ( $hour ). You need to use a if/elseif/else statement using the less then or greater than comparison operator(s) for comparing $hour. Example pseudo code if $hour < 12 { echo "Good morning $name" } elseif $hour >= 12 && $hour < 16 { echo "Good afternoon $name" } else { echo "Good Evening $name" }
  13. i see you have a javascript function defined (on line 80 to 83) called resizeIframe. But you don't appear to be calling it.
  14. Topic locked. Due to attracting a lot of spammers. @M84 if you want to reply PM me or click the Report link and a moderator/admin will unlock for you.
  15. Make sure you are referencing the timer javascript file (and jquery) before the foreach loop? <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script> <script type="text/javascript" src="timer.js"></script>
  16. You'll need to wrap the username, title and image in a containing element and then apply css styling as necessary // output the users name, title and picture echo ' <div class="user"> <img src="'.$row['user_picture'].'" /> <h4>' . $row['username'] . '<span class="title">' . $row['title'] . '</span></h4>' </div>'; Then apply a little css to style it. .user { display: inline-block; text-align: center; border: 1px solid #CCC; padding: 5px; margin: 5px; } .user img { display: block; } .user h4 { margin: 0; padding: 0; font-weight: normal; } .user .title { display: block; font-weight: bold; }
  17. You will have to create a new timers inside the foreach loop. Example foreach($rows as $k => $row) { $target_date = $row['target_date']; $timeLeft = (strtotime($target_date) - time()) * 1000; // append the array key to make a unique name for each counter $counterName = "counter_$k"; ?> <input type="hidden" class="target-date" value="<?php echo $timeLeft; ?>" /> <div class="counter <?php echo $counterName ?>"> <span class="hour">00</span> <span class="min">00</span> <span class="sec">00</span> </div> <script> // initiate new timer new Timer($('.<?php echo $counterName; ?>'), <?php echo $timeLeft; ?>); </script> <?php }
  18. You are not going to get very far using Dreamweaver's built in code wizards, (which to to be honest are complete garbage. By the looks of thing Adobe has not updated it since the Macromedia days). You are far better of coding PHP by hand. If the data is coming from the same table then you only need to use 1 query. You will have the query return all records in the users table, but have the results ordered by region name first and then secondly order by the users id( or name). Example query (Substitute user user_picure_column and Username_column to be your columns names) SELECT Secteurs, user_picure_column FROM Users WHERE ASS = 'Y' ORDER BY Secteurs ASC, Username_column ASC For displaying the results you'd do something like this $prevRegion = ''; // loop over results of query while($row = mysql_fetch_assoc($result)) { // if the region has changed from previous row if($prevRegion != $row['Secteurs']) { // then output a new region heading echo '<h1>' . $row['Secteurs'] . '</h1>'; $prevRegion = $row['Secteurs']; } // output the users picture echo '<img src="'.$row['user_picture'].'" />'; } The result should be each user picture is displayed under the correct region heading.
  19. So the target date is coming from the database. In that case use PHP to calculate the difference between the two dates. Then have PHP set the value for the timeLeft javascript variable // subtract the two dates and then multiply by 1000 to get milliseconds $timeLeft = (strtotime($target_date) - time()) * 1000; <script> $(document).ready(function(){ // echo $timeLeft value to set timeLeft javascript variable var timeLeft = <?php echo $timeLeft ; ?>; var timer = new Timer($('#counter'), timeLeft); }); </script>
  20. That is because you are applying htmlspecialchars to $stringData $stringData = htmlspecialchars($stringData); Its the foreach loop at the top of your code that is applying htmlspecialchars to your POST data only
  21. You don't need to use cookie at all. All you need to do is to dynamically calculate the timeLeft value by subtracting todays date/time from your target date/time. For example if you want your timer to countdown until 8pm today (16th October 2015). Then do // get todays date today = new Date(); // the target date, this will get the date/time for 8PM 16th October 16th 2015 targetDate = new Date(2015, 9, 16, 20); // subtract the two dates to get the difference in millisecons var timeLeft = targetDate - today;
  22. So your question is how to get the improvement, remarks and filename values in your foreach loop? I would loop over the $_POST['improvment'] values, using the array key (which will contain the grade id) to reference the corresponding remarks and filename field values inside the loop. Example // loop over each submitted improvement value // the array key comtains the grade_id // the grade_id is use for referencing the corresponding remarks and filename values foreach ($_POST['improvment'] as $grade_id => $status) { $remarks = $_POST['remarks'][$grade_id]; $filename = $_POST['filename'][$grade_id]; // insert values into db }
  23. You cant mix PHP and Javascript code together. PHP and Javascript are two completely different languages, they both run a different times. PHP runs on the server. JavaScript runs in the browser. The only way to send the value returned by the prompt box to PHP would be to to redirect the user to your php script and have value pass a querystring value. Example // get value form javascript prompt var person = prompt('Enter your name', 'John Smith'); // submit the value to php by redirecting the user to submit.php // and passing the name as a querystring value document.location = 'submit.php?name=' + person; Your PHP code for inserting the name into the database goes in submit.php. The variable $_GET['name'] will contain the value from the prompt box. If you dont want the user to be redirected/page to be refreshed then you can use ajax. (Example code using Jquery's ajax api) <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script> <script> var person = prompt('Enter your name', 'John Smith'); $.ajax({ url: "submit.php", data: { person: person } }) .done(function( msg ) { alert( "Name has been submitted"); }); </script>
  24. No . I'm stumped to be honest. That is the same code I have used in the past. I'm not sure what else to suggest.
×
×
  • 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.