MySQL & PHP problem

Status
Not open for further replies.

rileypool

paper clique fiend
Mar 8, 2007
1,345
43
0
41
Tulsa, OK
rileypool.com
Hey guys, I'm still fairly new to php/MySQL, but I'm learning. I'm trying to return two variables from the same database record. This is currently the code I'm using and I know its wrong because the query selects the event only. How can I also return the date it happened from that same record?

Code:
    <?php    
    $query = 'SELECT tih_event FROM todayinhistory WHERE right(tih_date,5) = "' . $currDay . '"';
    $result = mysql_query($query) or die(mysql_error());
    
    while($row = mysql_fetch_array($result)){
        echo 'Year: ' . $row['tih_date'] . ' - ' . $row['tih_event'] . '<br />';
        }
    ?>
 


You can also get more than one value with a Select Statement.

example:
Code:
$query = 'SELECT tih_event, tih_date FROM todayinhistory WHERE right(tih_date,5) = "' . $currDay . '"';

SELECT * can and will kill your performance, as you are getting every value in the table, not just the ones you need.

::emp::
 
Status
Not open for further replies.