The forums have permanently moved to forum.kirupa.com. This forum will be kept around in read-only mode for archival purposes. To learn how to continue using your existing account on the new forums, check out this thread.


Results 1 to 10 of 10

Thread: selecting * from a certain column from a certain table???

  1. #1

    Fla Script selecting * from a certain column from a certain table???

    hey all,

    i currently have my query as follows:
    Code:
    SELECT *
    FROM my_table
    WHERE //not coded yet// (i want to select everything from `email` column)
    i basically want to display everything from my `email` column but don't how to go about my query...any help would be great! thanks all.

    any ideas?

  2. #2

  3. #3
    so simple!
    Thanks bwh2 i think i over think things

    Cheers

  4. #4
    no problem. * means "all". so...
    Code:
    /* selects all columns from my_table */
    SELECT * FROM my_table
    
    /* selects the email column from my_table */
    SELECT email FROM my_table
    
    /* selects email and username columns from my_table */
    SELECT email, username FROM my_table
    
    /* selects only the unique emails from my_table */
    SELECT DISTINCT email FROM my_table

  5. #5

    sorry one more quick question when i echo my $result variable which is the following:

    Code:
    $query = "SELECT `email` FROM `table_name`";
    $result = mysql_query( $query ) or die (mysql_error());
    
    $sendTo = "$result";
    $subject = "Test";
    $message .= "hello world";
    
    mail($sendTo, $subject, $message);
    echo $query
    Cheers in advance

  6. #6

    i fixed that problem with the echo but to send off to my list of email addresses i need to put the $result into a 'string' - correct i am having trouble with getting the result into a string...

    know any tutorials or any ways to do it??

    Cheers bwh2/ everyone
    Last edited by - |Flash Man| -; February 7th, 2007 at 12:32 AM. Reason: thanks bwh2 for the explanations ;)

  7. #7
    $result is a mysql resource. to access the resource, you need to put it into an array. then access the array. you could do something like this:
    PHP Code:
    while( $row mysql_fetch_array$result ) ) {
      
    mail($row['email'$subject$message);

    Last edited by bwh2; February 7th, 2007 at 01:35 AM.

  8. #8

    sorry...it seems right but when i add it in i get a parse error:
    Code:
    Parse error: parse error, unexpected T_VARIABLE in e:\inetpub\svc027\images\site\mail.php on line 12
    PHP Parse error: parse error, unexpected T_VARIABLE in e:\inetpub\svc027\images\site\mail.php on line 12
    do i need to specify in the query that $row[`email`]??


    Cheers here is my whole code so you can see [minus my connection details]

    Code:
    <?php
    
    $list = $_POST['list'];
    //$template = $_POST['template'];
    
    $query = "SELECT DISTINCT `email` FROM `sub_mail_list`";
    $result = mysql_query( $query ) or die (mysql_error());
    while( $row = mysql_fetch_array( $result )) {
      mail($row['email'] $subject, $message);
    }
    // Printing results in HTML
    //echo "<table>\n";
    //while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
      // echo "\t<tr>\n";
      // foreach ($line as $col_value) {
       //    echo "\t\t<td>$col_value</td>\n";
       //}
       //echo "\t</tr>\n";
    //}
    //echo "</table>\n";
    
    
    $subject = "Website Subscription Newsletter Test";
    $message .= "hello world this is a test from me...don't freak out [list]";
    
    //mail($sendTo, $subject, $message);
    //echo $col_value
    
    
    ?>

  9. #9
    SORRY i left a comma out lol

    it all works fine now
    thanks heaps bwh2! much appreciated

  10. #10

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012