Jump to content

joel24

Members
  • Posts

    760
  • Joined

  • Last visited

Posts posted by joel24

  1. If we all add something, he'll be done in a matter of weeks!

     

    <?php
    //rest of code here
    echo '<h1>Car Dealership Site</h1>';
    
    echo '<table width="650"> <tr> <td width="600">Vehicle Name</td> <td width="50">Price</td> </tr><tr> <td width="600">VEHICLE NAME HERE</td> <td width="50">PRICE HERE</td> </tr> </table>';
    

    you forgot the ;

  2. And yes, you can set it manually. $_POST is an array afterall. Nothing really special about that. But people really need to learn to use better practices. When coding use error_reporting(E_ALL);. There is a PHP notice for using undefined constants as keys.

     

    interesting!

    just had a play around you can even set $_SERVER['PHP_SELF'] etc etc..

    always assumed they'd be locked...

  3. I can not set it manually because I get it from previous page where names of inputs are set automatically.

    ... so you have a form on the previous page and its being posted to the page with the script you posted?

     

    what are you trying to achieve by your foreach loops??

     

    if you just want to look at the contents of the $_POST array you can use print_r($_POST);

     

    have you tried this code? it *should* work

    if (isset($_POST)) {
      foreach($_POST as $key){
    if (is_array($_POST[$key])) {
        foreach ($key as $key2 => $value){
        echo "<br />Key=".$key2."value=".$value;
        }
    }
      }

  4. i don't think you can set an $_POST value manually??

    i.e.

    $_POST[firstkey][secondkey]=12; won't work?

     

    what if $_POST array isn't multidimensional?

     

    i'd do

    if (isset($_POST)) {
      foreach($_POST as $key){
    if (is_array($_POST[$key])) {
        foreach ($key as $key2 => $value){
        echo "<br />Key=".$key2."value=".$value;
        }
    }
      }

     

    oh, and what code is on line 5?

    is it isset($_POST)?

     

    and the second foreach should be

    foreach $key as $key2 etc etc

     

    i think you're problem was you were trying to use an array as an index.. i.e. $_POST[$key] when $key was an array.

    use that

    foreach $key as $key2 and you should be fine

  5. your form doesn't have an action...?

    i.e. it should be something like (if the data should be posted to itself)

    <form method="post" enctype="multipart/form-data" action="<?php echo basename($_SERVER['PHP_SELF']); ?>">

     

    otherwise set action="rarqara.php" to whatever page the data should b posted to.

     

    and theres no submit button?!

  6. as far as I know you're meant to define the selected option in the option tag...

    i.e.

    <select name="clnt_state" id="clnt_state" tabindex="8" class="form-inputitem">
                                   <option value="" selected></option>
                                    <option value="AL">AL</option>
    </select>

     

    how is each individual state <option> getting written?

    manually or from an array...?

     

    i'd suggest putting the states into an array,

    then doing a foreach loop to list them all i.e.

     

    foreach ($states as $s) {

     

    if ($row_rstocdetail['clnt_state'] == $s) {

    $isSelected = "selected";

    } else {

    $isSelected = "";

    }

     

    echo '<option '.$isSelected.' value="'.$s.'">'.$s.'</option>

    }

  7. you can use javascript to call a PHP page which checks if theres any new shouts every say 10minutes? or just wait and have it done on every page refresh...

     

    i'd probably just have the script check if there were any messages in the tbl_message / whatever this converts to table which were had the users ID as the toid and had not been viewed yet (viewed = 0)

     

    if there were, i'd display the messages and at the same time set a "viewed" column in the tbl_message table to "1"

  8. most common way is to send the page number in the url... with $_GET...

    then have your sql which gets the comments and also looks for the page number...

     

    then based off that page number and the amount of posts you want to display, you'd have the SQL changed depending on this..

    i.e. if page was 3 and you displayed 20 posts per page,

    $page = ($_GET['pageNumber'] - 1) * 20;

    minus one because you want to find the start of the posts needed..?

     

    then your sql would be like

    "SELECT * FROM comments ORDER BY whatever LIMIT $page, 20"

    with limit x, y.. the x variable sets the starting number (remember the first entry in the results list is zero, so 20 is the 21st result...... so if you have limit 5, 10.. you'd get the 6th - 10th results.

     

    then you'd need a sql command which also counted how many comments there were for the page numbers..

    then i'd divide it by 20 or however many posts per page to work out how many pages you need.

     

    $amountOfComments = $amountOfComments / 20;

     

    for ( $counter = 1; $counter <= $amountOfComments; $counter += 1) {

    echo '<a href="'.basename($_SERVER['PHP_SELF']).'?pageNumber='.$counter.'">'.$counter.'</a>';

    }

     

    and then the y value tells sql how many results to pull.

     

    anyway thats just the basics, theres heaps of tutorials on it that will explain it better than I can, google is your friend

×
×
  • 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.