Jump to content

Wolphie

Members
  • Posts

    682
  • Joined

  • Last visited

    Never

Posts posted by Wolphie

  1. From what I can understand, I would suggest something like the following..

     

    <?php
    $query = "SELECT COUNT(*) as Num FROM `table` WHERE `billing_id` = '$billing_id'";
    $result = mysql_query($query) or trigger_error(mysql_error());
    
    for($a = 0; $a < $result['Num']; $a++)
      print $billing_id . '-' . $a;
    
    ?>
    

     

     

  2. Everything would be fine, because when you click the submit button, the data will be submitted regardless of whether you use an event handler or not. It doesn't matter, if you remove the onclick event handler, your form will still be submitted.

     

    This works *perfectly* fine for me:

    <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
      <input type="text" name="name" />
      <input type="image" src="http://localhost/MAMP/images/welogo.gif" name="submit" />
    </form>
    <?php
    if(isset($_POST['submit'])) { 
      print $_POST['name'];
    }
    ?>
    

  3. The solution given by dannyb785 doesn't work!!!

     

    What *exactly* doesn't work? Is there anything indicating where the problem is? What's wrong? Please be more clearer.

    If you're using Firefox, download the Firebug add-on, it will help you debug and determine the problem.

     

    Why are you adding a submit method to a submit button/image anyway? And I very much doubt that your first one worked, seeing as the form would submit regardless.

  4. Why not just select the username in the same query? :S

     

    And also, it's mysql_query() not Mysql_query()

     

     

    P.S. could you mark your other topic as solved before creating another related question.

  5. SELECT `userid`, MAX(`vote_count`) FROM `user_users`
    

     

    I think you need to display the structure of the database. All votes should be placed at a different table, then check the number of occurences there from the list of users from the users table.

     

    This would makes things inefficient for a simple polling system. A seperate table would only be required if you wanted to record information about the user that voted, e.g. userid, date/time they voted, what they voted for etc.. or if you wanted to display 'pretty' percentage bar images etc.. for BOTH answers.

  6. I personally prefer the O'Reilly books, they tend to be very in-depth and detailed with their examples, explanations and definitions. However, php.net is by far the best learning resource in my honest opinion.

  7. If I were you, I'd create an additional column on the user_users table, and name it vote_count.

    Everytime the user gets a vote, you will update the value in the database and increment it by 1.

     

    Then to check the user with the most votes

     

    <?php
    // db connection info
    
    $query = "SELECT MAX(`vote_count`) FROM `user_users`";
    $result = mysql_query($query) or trigger_error(mysql_error());
    
    ?>
    

     

     

     

  8. It should be:

     

    $query = sprintf("SELECT `address` FROM `address_photos` WHERE `mc_name` = '%s' AND `batch_code` = '%s' AND `time` = '%s'",
      mysql_real_escape_string($mc_name),
      mysql_real_escape_string($batch_code),
      mysql_real_escape_string($time)
    );
    
    $result = mysql_query($query) or trigger_error(mysql_error());
    

     

     

     

  9. The problem is the line

    echo "<a href='index.php?id=", $id, "'>", $firstname, "</a>";
    

     

    The formatting is wrong and the quotes are causing the echo statement to end early. Format it like I said and it will work.

     

    As gigas10 pointed out, your formatting is wrong.

     

    Try:

    echo '<a href="index.php?id=' . $id . '">' . $firstname . '</a>';
    

     

    Your quotes were ok by the looks of it, but to concatenate strings, you use a period (full-stop) rather than a comma.

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