Jump to content

Reno04

New Members
  • Posts

    2
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Reno04's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Sorry my mistake the query was typed wrong it it should've been Select name, Year(current_date())-birth_yr As age from prime_minister the real problem i have is with php displaying the "as age" column as its derived and i don't know how to refer to it in my while loop see below while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { echo "<br /> Name : {$row['name']} <br>". echo "<br /> Age : {$row['??????']} <br>"; // This part i dont understand what to write } mysql_close();
  2. Hi I'm new to using Mysql and php together and was wondering if someone could explain how i would display a derived column result. As in year - death_age. see below $query = "select name from prime_minister where YEAR(CURRENT_DATE()) - birth_yr "; $result = mysql_query($query); if (mysql_affected_rows() >=1) { echo '<h3>'.'The results of'.'<p>'.'<code>'. $query . '</code>' .'</p><p>are as follows:'.'</p>'.'</h3>'; } else { echo 'Check your SQL statement as there has been no data retrieved!'; } while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { echo "<br /> Name : {$row['name']} <br>". echo "<br /> Current Age : {$row['??????']} <br>"; This part i dont understand what to write } mysql_close(); //
×
×
  • 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.