Jump to content

wildteen88

Staff Alumni
  • Posts

    10,480
  • Joined

  • Last visited

    Never

Everything posted by wildteen88

  1. By table I am assuming you mean a MySQL table. $sql = 'SELECT id_cidade, n_anuncio FROM your_table ORDER BY id_cidade'; $result = mysql_query($sql); $prevID = 0; while($row = mysql_fetch_assoc($result)) { if($prevID != $row['id_cidade']) echo '<h1>' . $row['id_cidade'] . '</h1>'; echo $row['n_anuncio'] . '<br />'; $prevID = $row['id_cidade']; }
  2. You could use regex to see if $bet only contains numbers, if ( $bet < 0 || preg_match('/[^0-9]+/', $bet) ){ $error = "One or more of your bet(s) was invalid."; error($error); }
  3. $customerID = 30038; $randNumber = sprintf("%d%04d", $customerID, rand(0, 9999)); echo $randNumber;
  4. You need to wrap field values within quotes $sql="SELECT domain FROM domains WHERE user='".$_SESSION['user']."'";
  5. The filename needs be wrapped with in quotes.
  6. You can use, fopen and fwrite to create/write the file.
  7. In session sessionlesson.php and session03.php, replace this line require('sessionlesson01.php'); With just session_start(); Otherwise you're just overwriting your session variables with blank values. This is because the _POST variables will not be available on these pages, as the form is only submitted to sessionlesson02.php
  8. You can use array_sum, or with a foreach loop $total = 0; foreach($myArray as $value) { $total += $value; } echo $value;
  9. The only way to include files is via the use of include or require. Why on earth do Yahoo! not allow the use of include?
  10. This is because web browsers ignore white space characters, such as new lines. In order for a new line to appear in a web browser you need use the <br /> tag. nl2br() converts new lines into <br /> tags.
  11. You can format your dates by first using the strtotime function to convert your date into a unix timestamp. You then pass the timestamp as the second parameter to the date function. This will allow you to change the appearance of your date.
  12. It looks like the constant CATEGORIES_PER_ROW is controlling how many columns are being displayed. You need to find where this constant is being defined, which is probably in some configuration file. Currently CATEGORIES_PER_ROW is set to 3. You need to change it to 4 in order for the 4gth column to display.
  13. PHP does not understand HTML, therefore you can't place raw HTML within the php tags. You need to use echo (or print) to send the html to the browser, as I showed you in my previous post:
  14. You cant place HTML code within PHP tags. You need to use echo or print. <?php echo '<label>Tel:</label> <div>' . $row['tel'] . '</div> <label>Address:</label> <div>'. $row['address'] . '</div> <div>'. $row['county'] . $row['state'] . '</div> <div>'. ['zip'] . '</div>'; ?>
  15. No adam is using HEREDOC syntax, the <<< is perfectly fine. The problem is the semi-colon ( ; ) at the end of line. Delete the semi-colon and it should fix the error
  16. Yes correct. For more information regarding functions please read this
  17. If you want call a PHP function when the form is submitted. Then you'll need to do something like this <?php function some_function() { echo 'form submittted'; } if(isset($_POST['submit'])) { // call function here some_function(); } ?> <fom action="" method="post"> SOME FIELD HERE <input type="submit" name="submit" value="Submit" /> </form>
  18. Leave what in? Rather than post single lines of code. Post all the code for your form.
  19. No, leave it as it is. The form tag should have an action and method defined.
  20. The problem is your code is outdated. In order for your code to work a setting called register_globals needs to be enabled. It sounds like your webhosts has now disabled this setting (which it should be) and your code no longer works. You need to update your code so it no longer relies on this setting. Please read the manual on register_globals here.
  21. This <option value="<?=$this_page.'&$year'?>" <? if($_GET{'year'}){echo 'selected';}?>><?=$year?></option> Should be <option value="<?=$year?>" <? if($_GET{'year'}){echo 'selected';}?>><?=$year?></option>
  22. You're getting that error because your overwriting the $guide variable while ($guide = mysql_fetch_array($guide)) That line should be while ($row = mysql_fetch_array($guide)) In your while loop use $row['guidetext'] instead of $guide['guidetext']
  23. This line $customer_id = $_SESSION['valid_user']; Needs to be within the saveOrder() function. The problem is functions have their own variable scope, meaning they do not share variables defined outside of them. To understand this have read about variable scope
  24. If you want each row to have a unique identifier then you should look into using auto_increment. With an auto_increment field MySQL will assign a unique identifier for each row inserted into the table.
  25. Variables are not parsed within single quotes.
×
×
  • 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.