Jump to content

manhattanpaul

New Members
  • Posts

    4
  • Joined

  • Last visited

    Never

Posts posted by manhattanpaul

  1. Hi all

     

    I have this page which collects some information on our clients.

     

    As part of this assessment, it collects their height and weight.  I want to get this to automatically calculate their BMI (which is calculated by Weight / Height Squared.

     

    Here is my coding - you will see the Height and Weight Variables.  What should I do to get the BMI to calcualte automatically or with the press of a button ??

     

    Thanks Paul

     

     

    <?php
    $type=$_GET['type'];
    if ($type=='') {
    ?>
    <a href='index.php?page=interventions&type=add'>Add new intervention</a><br>
    <br>
    
    <table border=1><tr><th width='140'>Client Name</th><th>Intervention Date</th><th width='140'>Options</th></tr><?
    $result=mysql_query("SELECT * FROM interventions ORDER BY year DESC, month DESC, day DESC");
    while ($row=mysql_fetch_array($result)) {
    echo "<tr><td>";
    $clientid=$row['clientid'];
    $clientarray=mysql_fetch_array(mysql_query("SELECT * FROM clients WHERE id='$clientid'"));
    echo $clientarray['name'];
    echo "</td><td>";
    $day=$row['day'];
    
    if ($day==01) { echo "1st"; }
    elseif ($day==02) { echo "2nd"; }
    elseif ($day==03) { echo "3rd"; }
    elseif ($day==04) { echo "4th"; }
    elseif ($day==05) { echo "5th"; }
    elseif ($day==06) { echo "6th"; }
    elseif ($day==07) { echo "7th"; }
    elseif ($day==08) { echo "8th"; }
    elseif ($day==09) { echo "9th"; }
    elseif ($day==21) { echo "21st"; }
    elseif ($day==22) { echo "22nd"; }
    elseif ($day==23) { echo "23rd"; }
    elseif ($day==31) { echo "31st"; }
    else { echo $day; echo "th"; }
    echo " ";
    $monthid=$row['month'];
    $montharray=mysql_fetch_array(mysql_query("SELECT * FROM months WHERE id='$monthid'"));
    echo $montharray['month'];
    echo " ";
    echo $row['year'];
    echo "</td><td><a href='index.php?page=interventions&type=add&interid=".$row['id']."'>Update Intervention</a><br>
    <a href='index.php?page=delete&type=interventions&id=".$row['id']."'>Delete Intervention</a></tr>";
    
    
    }
    
    echo "</table>";
    } 
    
    elseif ($type=='add') {
    $interid=$_GET['interid'];
    
    echo "Please fill in the following form to add a new intervention.<br><br><table border=1>
    <form name='form1' action='index.php?page=interventions&type=add2' method='post'>";
    if ($interid=='') {
    echo "<input type='hidden' name='interid' value='NEW'>";
    } else {
    
    echo "<input type='hidden' name='interid' value='$interid'>";
    $client=mysql_fetch_array(mysql_query("SELECT * FROM interventions WHERE id='$interid'"));
    }
    
    
    
    echo "<tr><td> Client Name</td><td>";
    echo " <select name='clientid'><option></option>";
    $res1=mysql_query("SELECT * FROM clients ORDER BY name ASC, dobyear DESC, dobmonth DESC, dobday DESC");
    while ($r=mysql_fetch_array($res1)) {
    
    echo "<option value='".$r['id']."' ";
    if ($client['clientid']==$r['id']) { echo "selected"; }
    echo ">".$r['name']." (".$r['dobday']."/".$r['dobmonth']."/".$r['dobyear'].")</option>";
    }
    echo "</select>";
    echo "</td></tr>";
    
    echo "<tr><td>Intervention Date</td><td><select name='day'><option></option>";
    $times=32;
    $x=1;
    while ($x<$times) {
    echo "<option ";
    if ($client['day']==$x) { echo "selected"; }
    echo ">";
    if ($x<10) { echo "0"; }
    echo $x;
    echo "</option>";
    $x++;
    }
    echo "</select>";
    echo " <select name='month'><option></option>";
    $res1=mysql_query("SELECT * FROM months");
    while ($r=mysql_fetch_array($res1)) {
    
    echo "<option value='".$r['id']."' ";
    if ($client['month']==$r['id']) { echo "selected"; }
    echo ">".$r['month']."</option>";
    }
    echo "</select>";
    echo "<select name='year'>";
    $times=2020;
    $x=2008;
    while ($x<$times) {
    
    echo "<option ";
    if ($client['year']==$x) { echo "selected"; }
    echo ">".$x."</option>";
    $x++;
    }
    echo "</select>";
    echo "</td></tr>";
    echo "<tr><td>Venue</td><td>";
    echo " <select name='venueid'><option></option>";
    $res1=mysql_query("SELECT * FROM venues WHERE 1");
    while ($r=mysql_fetch_array($res1)) {
    
    echo "<option value='".$r['id']."' ";
    if ($client['venueid']==$r['id']) { echo "selected"; }
    echo ">".$r['name']."</option>";
    }
    echo "</select>";
    echo "</td></tr>";
    echo "<tr><td>Staff Member Involved</td><td>";
    $staffhold=$client['staffid'];
    echo " <select name='staffid'><option></option>";
    $res1=mysql_query("SELECT * FROM staff WHERE 1");
    while ($r=mysql_fetch_array($res1)) {
    
    echo "<option value='".$r['id']."' ";
    if ($staffhold==$r['id']) { echo "selected"; }
    echo ">".$r['name']."</option>";
    }
    echo "</select>";
    echo "</td></tr>";
    
    echo "<tr><td>Improvements since last visit</td><td><textarea name='improvements' rows='6' cols='50'>".$client['improvements']."</textarea></td></tr>";
    echo "<tr><td>Risk Assessment Used</td><td>";
    echo " <select name='assessment'><option></option>";
    $res1=mysql_query("SELECT * FROM assessment");
    while ($r=mysql_fetch_array($res1)) {
    
    echo "<option value='".$r['id']."' ";
    if ($client['assessment']==$r['id']) { echo "selected"; }
    echo ">".$r['assessment']."</option>";
    }
    echo "</select>";
    echo "</td></tr>";
    echo "<tr><td>Review Of Risk Score</td><td>";
    echo " <select name='review'><option></option>";
    $res1=mysql_query("SELECT * FROM review");
    while ($r=mysql_fetch_array($res1)) {
    
    echo "<option class='".$r['id']."' value='".$r['id']."' ";
    if ($client['review']==$r['id']) { echo "selected"; }
    echo ">".$r['name']."</option>";
    }
    echo "</select>";
    echo "(before any improvements made)</td></tr>";
    echo "<tr><td>Advice Offered and Improvements Suggested</td><td><textarea name='actions' rows='6' cols='50'>".$client['actions']."</textarea></td></tr>";
    
    echo "<tr><td>BP Reading (Systolic)</td><td><input type='text' name='BPSystolic' size='5' value='".$client['BPSystolic']."'></td></tr>";
    echo "<tr><td>BP Reading (Diastolic)</td><td><input type='text' name='BPDiastolic' size='5' value='".$client['BPDiastolic']."'></td></tr>";
    echo "<tr><td>Height</td><td><input type='text' name='Height' size='15' value='".$client['Height']."'> Enter This as XX.x m</td></tr>";
    echo "<tr><td>Weight</td><td><input type='text' name='Weight' size='15' value='".$client['Weight']."'> Enter this as XX.x Kg</td></tr>";
    echo "<tr><td>BMI</td><td><input type='text' name='BMI' size='15' value='".$client['BMI']."'> This is calculated by Weight (in Kg) / Height Squared (in m) </td></tr>";
    
    
    
    echo "<tr><td>Referral agencies suggested</td><td><table spacing='0' padding='0'><tr><th width='280'></th><th>Yes</th><th width='5'></th><th>No</th></tr>";
    $times=18;
    $x=1;
    $background=1;
    while ($x<$times) { 
    $array=mysql_fetch_array(mysql_query("SELECT * FROM referral WHERE id='$x'"));
    echo "<tr><td class='";
    echo $background;
    echo "'>";
    echo $array['name'];
    echo "</td><td class='";
    echo $background;
    echo "'><input type='radio' name='$x' value='Yes' ";
    if ($client["{$x}"]=='Yes') { echo "checked"; }
    echo ">
    </td><td class='";
    echo $background;
    echo "'></td><td class='";
    echo $background;
    echo "'>
      
      <input type='radio' name='$x' value='No' ";
      if ($client["{$x}"]=='No' || $client["{$x}"]=='') { echo "checked"; }
      echo ">
      </td></tr>";
    $background++;
    if ($background==3) { $background=1; }
    $x++; }
    echo "</table><br><br>Other (please specify)<input type='text' name='referral' size='40' value='".$client['referral']."'></td></tr>";
    
    
    
    
    echo "<tr><td>Letter Sent To GP</td><td><input name='gpletter' type='checkbox' value='Yes' ";
    if ($client['gpletter']=='Yes') { echo "checked"; }
    echo ">";
    echo "</table>";
    echo "<br><br><input type='submit' name='submit' value='";
    if ($interid=='') { echo "Add New Intervention"; } 
    else { echo "Update Intervention"; }
    echo "'>";
    echo "</form>";
    } elseif ($type=='add2') {
    $interid=$_POST['interid'];
    $clientid=$_POST['clientid'];
    $venueid=$_POST['venueid'];
    $staffid=$_POST['staffid'];
    
    $BPSystolic=$_POST['BPSystolic'];
    $BPDiastolic=$_POST['BPDiastolic'];
    $Weight=$_POST['Weight'];
    $Hieght=$_POST['Height'];
    $BMI=$_POST['BMI'];
    
    
    $improvements=$_POST['improvements'];
    $assessment=$_POST['assessment'];
    $review=$_POST['review'];
    $actions=$_POST['actions'];
    $referral=$_POST['referral'];
    $gpletter=$_POST['gpletter'];
    $day=$_POST['day'];
    $month=$_POST['month'];
    $year=$_POST['year'];
    $i1=$_POST['1'];
    $i2=$_POST['2'];
    $i3=$_POST['3'];
    $i4=$_POST['4'];
    $i5=$_POST['5'];
    $i6=$_POST['6'];
    $i7=$_POST['7'];
    $i8=$_POST['8'];
    $i9=$_POST['9'];
    $i10=$_POST['10'];
    $i11=$_POST['11'];
    $i12=$_POST['12'];
    $i13=$_POST['13'];
    $i14=$_POST['14'];
    $i15=$_POST['15'];
    $i16=$_POST['16'];
    $i17=$_POST['17'];
    
    
    if ($interid=='NEW') {
    
    mysql_query("INSERT INTO interventions (clientid, venueid, staffid, improvements, assessment, BPDiastolic, BPSystolic, Height, Weight, BMI, review, actions, referral, gpletter, day, month, year,`1`,`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`,`10`,`11`,`12`,`13`,`14`,`15`,`16`,`17`) VALUES 
    ('$clientid', '$venueid', '$staffid', '$improvements', '$assessment', '$BPDiastolic', '$BPSystolic', '$Height', '$Weight', '$Weight', '$review', '$actions', '$referral', '$gpletter', '$day', '$month', '$year','$i1','$i2','$i3','$i4','$i5','$i6','$i7','$i8','$i9','$i10','$i11','$i12','$i13','$i14','$i15','$i16','$i17')");
    echo "New intervention succesfully added. Click <a href='index.php'>HERE</a> to continue";
    } else {
    
    mysql_query("UPDATE interventions SET clientid='$clientid', venueid='$venueid', staffid='$staffid', improvements='$improvements', BPDiastolic='$BPDiastolic', BPSystolic='$BPSystolic', Height='$Height', Weight='$Weight', BMI='$BMI', assessment='$assessment', review='$review',
    actions='$actions', referral='$referral', gpletter='$gpletter', day='$day', month='$month', year='$year',`1`='$i1',`2`='$i2',`3`='$i3',`4`='$i4',`5`='$i5',`6`='$i6',`7`='$i7',`8`='$i8',`9`='$i9',`10`='$i10',
    `11`='$i11',`12`='$i12',`13`='$i13',`14`='$i14',`15`='$i15',`16`='$i16',`17`='$i17' WHERE id='$interid'");
    echo "Existing intervention successfully updated. Click <a href='index.php'>HERE</a> to continue";
    
    }
    
    
    }
    ?>

     

     

     

    mod edit: Use code tags

    <?php
         // your code
    ?>
    

     

     

    and just post the relevant code if you expect people to read it

  2. Hi All

     

    Anyone got any ideas how I can get the following code to offset by 5 hours.  The field that displays the date / time is 'data' and the format is 2007-02-28 11:38:43  , ideally i would like it 11:38:43  28-02-2007.

     

    Any thoughts......here is the code

     

    Paul

     

     

     

     

    <?

    include ("../config.php");

    include ("../functii_mail.php");

    include ("../".$lang);

     

    function accept($id)

    {

    $sql="update users set approvved=1 where id=$id";

    $result=mysql_query($sql);

      if (!$result)

        {

        echo "Error";

        echo mysql_error();

        }

     

     

    }

    function upgrade($id)

    {

    $sql="update users set upgraded=1 where id=$id";

    $result=mysql_query($sql);

      if (!$result)

        {

        echo "Error";

        echo mysql_error();

        }

    }

    function downgrade($id)

    {

    $sql="update users set upgraded=0 where id=$id";

    $result=mysql_query($sql);

      if (!$result)

        {

        echo "Error";

        echo mysql_error();

        }

    }

     

     

    function delete_u ($id)

    {

    $sql="delete from users where id=$id";

    $result=mysql_query($sql);

      if (!$result)

        {

        echo "Error";

        echo mysql_error();

        }

     

     

    }

    function suspend($id)

    {

    $sql="update users set approvved=0 where id=$id";

    $result=mysql_query($sql);

      if (!$result)

        {

        echo "Error";

        echo mysql_error();

        }

     

     

    }

     

    function get_picture($user_id)

    {

    //mod daca apare sau nu butonul radio

        $sql="select nume,id from pictures where user_id=$user_id";

        $result=mysql_query($sql);

        $num=mysql_numrows($result);

        if ($num<>0)

        {

     

          $i=0;

        while ($i<$num)

          {

          $nume=mysql_result($result,$i,"nume");

          $id=mysql_result($result,$i,"id");

          ?> <img src="../user_pic/ <?=$nume?>">

          <?

          $i++;

          }

        }

        else

        {

        echo "This user have no pictures uploaded!";

        }

     

    }

    function get_sound($user_id)

    {

        $sql="select nume,id from sounds where user_id=$user_id";

        $result=mysql_query($sql);

        $num=mysql_numrows($result);

        if ($num<>0)

        {

     

          $i=0;

        while ($i<$num)

          {

          $nume=mysql_result($result,$i,"nume");

          $id=mysql_result($result,$i,"id");

          $nume="user_sounds/ $nume";

          ?> <a href="../play_sound.php?fisier=<?=$nume?>" target="blank"><?echo $nume?></a>

          <input name="sound" type="hidden" value="1">

          <input type="radio" name="id" value="<?=$id?>"><br>

          <?

          $i++;

          }

        }

        else

        {

        echo "This user have no sounds uploaded!";

        }

     

    }

     

    db_connect($dbserver,$dbuser,$dbpass,$dbname);

    if (isset($accept_))

    {

    accept($id);

    }

    if (isset($delete_))

    {

    echo $delete;

    delete_u($id);

    }

    if (isset($suspend_))

    {

    suspend($id);

    }

    if (isset($upgrade_))

    {

    upgrade($id);

    }

    if (isset($downgrade_))

    {

    downgrade($id);

    }

     

    ?>

    <html>

    <head>

    <title>Dating site</title>

    <meta http-equiv="Content-Type" content="text/html;">

    <meta name="description" content="FW4 DW4 HTML">

    <!-- Fireworks 4.0  Dreamweaver 4.0 target.  Created Fri Nov 01 22:53:30 GMT+0200 (E. Europe Standard Time) 2002-->

    <link href="stil.css" rel="stylesheet" type="text/css">

    <?

                              if (isset($id))

                              {

                              //id id-ul userului

                              get_picture($id);

                              echo "<br>";

                          //  get_sound($id);

                              echo "<br>";

                              }

                              ?>

    <?

    if (isset($id))

    {

    $sql="SELECT * FROM users where id=$id order by data desc ";

    $result=mysql_query($sql);

    $num=mysql_numrows($result);

    if ($num<>0)

    {

        $nick=mysql_result($result,0,"nick");

        $data=mysql_result($result,0,"data");

        $last_access=mysql_result($result,0,"last_access");

        $email=mysql_result($result,0,"email");

        $password=mysql_result($result,0,"password");

        $sex=mysql_result($result,0,"sex");

        $sexuality=mysql_result($result,0,"sexuality");

        $personal_ad=mysql_result($result,0,"personal_ad");

        $location=mysql_result($result,0,"location");

        $country=mysql_result($result,0,"country");

        $age=mysql_result($result,0,"age");

        $birth_date=mysql_result($result,0,"birth_date");

        $zodia=mysql_result($result,0,"zodia");

        $marital_status=mysql_result($result,0,"marital_status");

        $icq=mysql_result($result,0,"icq");

        $msn=mysql_result($result,0,"msn");

        $web=mysql_result($result,0,"web");

        $eyes_colour=mysql_result($result,0,"eyes_colour");

        $hair_colour=mysql_result($result,0,"hair_colour");

        $weight=mysql_result($result,0,"weight");

        $music=mysql_result($result,0,"music");

        $partner=mysql_result($result,0,"partner");

        $question=mysql_result($result,0,"question");

        $newsletter=mysql_result($result,0,"newsletter");

        $approvved=mysql_result($result,0,"approvved");

    echo $nume_users."<font color=\"#FF0000\">".$nick;

    echo "</font><br>".$data_intrarii."<font color=\"#FF0000\">".$data;

    echo "<br></font>".$last_access_text."<font color=\"#FF0000\">".$last_access;

    echo "<br></font>".$email_text."<font color=\"#FF0000\">".$email;

    echo "<br></font>".$password_text."<font color=\"#FF0000\">".  $password;

    echo "<br></font>".$sex_text."<font color=\"#FF0000\"> ".  $sex;

    echo "<br></font>".$sexuality_text."<font color=\"#FF0000\"> ".  $sexuality;

     

    echo "<br></font>".$personal_ad_text."<font color=\"#FF0000\"> ".  $personal_ad;

    echo "<br></font>".$location_text." <font color=\"#FF0000\">".  $location;

    echo "<br></font>".$country_text."<font color=\"#FF0000\">".  $country;

    echo "<br></font>".$age_text."<font color=\"#FF0000\"> ".  $age;

    echo "<br></font>".$birth_date_text."<font color=\"#FF0000\">".  $birth_date;

    echo "<br> </font>".$zodia_text."<font color=\"#FF0000\">".  $zodia;

    echo "<br></font>".$marital_status_text."<font color=\"#FF0000\">".  $marital_status;

    echo "<br></font>".$icq_text."<font color=\"#FF0000\">".  $icq;

    echo "<br></font>".$msn_text."<font color=\"#FF0000\">".  $msn;

    echo "<br></font>".$web_text."<font color=\"#FF0000\">".  $web;

    echo "<br></font> ".$eyes_colour_text."<font color=\"#FF0000\">".  $eyes_colour;

    echo "<br></font>".$hair_colour_text."<font color=\"#FF0000\">".  $hair_colour;

    echo "<br></font>".$weight_text."<font color=\"#FF0000\">".  $weight;

    echo "<br></font>".$music_text."<font color=\"#FF0000\">".  $music;

    echo "<br></font>".$partner_text."<font color=\"#FF0000\">".  $partner;

    echo "<br></font>".$question_text."<font color=\"#FF0000\">".  $question;

    if ($newsletter==1)

    {

      echo $accept_newsletters;

    }

      else

    {

      echo $not_accept_newsletters;

    }

    if ($approvved==1)

    {

      echo $profile_accepted;

    }

      else

    {

      echo $profile_not_accepted;

    }

     

    }

    }

    ?>

    <br>

  3. Hi there

    I am currently trying to create a new display on the following page - mysite4singles.com/manager/users3.php

    I want to be able to see at a glance which members have upgraded.

    The only problem is, that the members who have upgraded are then repeated under 'Waiting to be registered' and 'Aleady registered' again !

    Any thoughts (code below)

    Cheers

    Paul


    [quote]The pages consists of the following code:
    [color=purple]<?
    include ("../config.php");
    include ("../functii_mail.php");
    db_connect($dbserver,$dbuser,$dbpass,$dbname);
    function get_picture($user_id,$mod=0)
    {
    //mod daca apare sau nu butonul radio
        $sql="select nume,id from pictures where user_id=$user_id";
        $result=mysql_query($sql);
        $num=mysql_numrows($result);
        if ($num<>0)
        {

          $i=0;
        while ($i<$num)
          {
          $nume=mysql_result($result,$i,"nume");
          $id=mysql_result($result,$i,"id");
          ?>
    <p><img src="../user_pic/ <?=$nume?>">
          <?
          if ($mod==1)
          {
          }
          else
          {
          ?>
          <input type="radio" name="id" value="<?=$id?>">
          <br>
      <?}
          $i++;
          }
        }
        else
        {
        echo "This user have no pictures uploaded !";
        }

    }

    function last_user($aproved=0)
    {
      $sql="SELECT count(*) FROM users where approvved=$aproved ";
      $result=mysql_query($sql);
    if($result)
    { $count=mysql_result($result,0,"count(*)");
    echo '('.$count.')';
    }

      $sql="SELECT id,nick FROM users where approvved=$aproved order by data desc ";
      $result=mysql_query($sql);
      $num=mysql_numrows($result);
      if ($num<>0)
      {
        $i=0;
      while ($i<$num)
      {
        $nick=mysql_result($result,$i,"nick");
        $id=mysql_result($result,$i,"id");
        if ($i==$num-1)
        {
        ?>
          <a href="profile.php?id=<?=$id?>" target="mainFrame">
          <?=$nick?>
          </a>
      <?is_online($id);
        }
        else
        {
        ?>
          <a href="profile.php?id=<?=$id?>" target="mainFrame">
          <?=$nick?>
          </a>,
      <?is_online($id);
        }
      $i++;
      }
      }
     
     
     
      $sql="SELECT id,nick FROM users where upgraded='1' order by data desc ";
      $result=mysql_query($sql);
      $num=mysql_numrows($result);
      if ($num<>0)
      {
        $i=0;
      while ($i<$num)
      {
        $nick=mysql_result($result,$i,"nick");
        $id=mysql_result($result,$i,"id");
        if ($i==$num-1)
        {
        ?>
          <a href="profile.php?id=<?=$id?>" target="mainFrame">
          <?=$nick?>
          </a>,
      <?is_online($id);
        }
        else
        {
        ?>
          <a href="profile.php?id=<?=$id?>" target="mainFrame">
          <?=$nick?>
    </a>, </p>
    <?is_online($id);
        }
      $i++;
      }
      }
     
     
    }
    echo "Waiting to be registered:";
    last_user();
    echo "<br>Already registered:";
    last_user(1);
    echo "<br>Upgraded:";
    last_user(2);[/quote]



    ?>[/color]
×
×
  • 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.