Jump to content

aaron118

Members
  • Posts

    30
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

aaron118's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi guys, I'm currently creating my first Yii app, and I'm really enjoying it so far. The app will be used to allow users to log their weightlifting workouts and to monitor their strength over time. Part of the app is to allow users to create their own workout routines, so for example a final workout routine might consist of: Legs Routine A Squat Set 1 Target reps: 12 Set 2 Target reps: 10 Set 3 Target reps: 8 Deadlift Set 1 Target reps: 10 Set 2 Target reps: 8 Set 3 Target reps: 6 Seated Calf Raises Set 1 Target reps: 15 Set 2 Target reps: 12 I know how to display and use these workout routines, but I can't seem to figure out how I can go about building the feature to create them. Ideally I'd like a 'create' page where both the exercises and their sets become repeatable fields, so you can define a certain amount of each. I have attached my database schema (the routine tables are the main ones concerned) and a wireframe design for my desired create routine page to help give you guys an idea on what I'm trying to do. I would really appreciate it if someone could point me in the right direction with this. Many thanks, Aaron
  2. I'm wondering how I can make a drop down select box to display all the week commencing dates (starting on a Monday) for the chosen year (drop down box to select year), because I'm trying to make a script to show all the events for the chosen week. Any help would be appreciated, Aaron
  3. Ok the problem is $chosen_products_ids = array($chosen_products); Because it is putting the result of $chosen_products (1,3) into one element row of the array, I can tell this becasue print_r($chosen_products_ids); outputs Array ( [0] => 1,3 ) whereas it should be Array ( [0] => 1 [1] => 3 ). Any ideas?
  4. print_r($chosen_products_names); just prints: Product 1. Which is the name of the first chosen_products ID.
  5. It won't be a bug in my DB class, becasue I use many methods like this with my DB class just not like this. The problem is something to do with the arrays, becasue the foreach is only looping once, thats why the first product is only displayed.
  6. In my MYSQL database I have a field called chosen_products which has the IDs of each chosen product, e.g. 1,3. What I am trying to do is to get the contents of chosen_products (e.g. 1,3) and then find the chosen products names by querying the database against those IDs. Heres my code: $match = $DB->SelectRow("SELECT chosen_products FROM orders WHERE uid='$uid' AND oid='$oid'"); $chosen_products = $match["chosen_products"]; $chosen_products_ids = array($chosen_products); $chosen_products_names = array(); foreach($chosen_products_ids as $val) { $result = $DB->SelectRow("SELECT pname FROM products WHERE pid='$val'"); $pname = array($result['pname']); $chosen_products_names = array_merge($chosen_products_names, $pname); } $chosen_products_names = join(',', $chosen_products_names); So I eventually want $chosen_products_names returned as a string of names seperated by a commar. But the final string only shows the name of the first product from $chosen_products. Any ideas on where I've gone wrong? Thanks
  7. Im not sure on what the array($num, $result); does? Also I have different mysql functions I like to use like mysql_num_rows and mysql_result, Im still not sure how I use these separatly with a class, I want to be able to return the class with both; how many rows (mysql_num_rows) and the result (mysql_result). Perhaps looking at my code above gain, it might give you an idea of what I mean, sorry if i'm not explaining very clear. Thanks again
  8. Say I want to do something like count the amount of rows selected from the query, how would I do this with your way? Also can someone please show me the point of creating a class becasue : $result = DBAccess::dbQuery('select * from yourtable'); could just be: $result = mysql_query('select * from yourtable'); and there would be no need to create a class, am I right? I just don't understand the point of creating a class for this, can someone please make it a little clearer. Thanks
  9. I want it so I only have to create one instance of the class, but still be able to run multiple querys and use the query data. How is this achieved? Thanks
  10. You should notice that I have to create two instances of the CPDatabase class; DB and CDB. I want the program to work with only one instance of the class, thats what I need help on.
  11. I'm wanting to learn more about good coding technique, so I have started trying to use OOP as well. Please take a look at this example, it is an order form I made, you'll notice I have to create two instances of the CPDatabase class, even though they both do the same job, but I have to create two otherwise it won't work: <?php require_once("./config.php"); // Select all available product categories $CDB = new CPDatabase; $CDB->QueryRow("SELECT cid, cname FROM product_cats"); // Start the session varibles session_start(); $uid = $_SESSION['uid']; $username = $_SESSION['username']; $userpass = $_SESSION['userpass']; $firstname = $_SESSION['firstname']; $lastname = $_SESSION['lastname']; $smarty->assign('username',$username); $smarty->assign('firstname',$firstname); $smarty->assign('lastname',$lastname); $smarty->assign('page_title','Order Form'); $smarty->display('header.tpl'); // Check to see if the session varibles are empty if(empty($uid) & empty($username) & empty($userpass) & empty($firstname) & empty($lastname)) $smarty->display('order_content1.tpl'); else $smarty->display('order_content2.tpl'); // Display each product category $ci = 0; while ($ci < $CDB->query_num_rows) { $cid = mysql_result($CDB->query_result,$ci,"cid"); $cname = mysql_result($CDB->query_result,$ci,"cname"); $smarty->assign('cname',$cname); $smarty->display('order_cat_top.tpl'); // Select all available products from this category $PDB = new CPDatabase; $PDB->QueryRow("SELECT pid, pname, pprice FROM products WHERE cid = '$cid'"); if($PDB->query_num_rows == 0) $smarty->display('order_no_products.tpl'); // Display each product $pi = 0; while ($pi < $PDB->query_num_rows) { $pid = mysql_result($PDB->query_result,$pi,"pid"); $pname = mysql_result($PDB->query_result,$pi,"pname"); $pprice = mysql_result($PDB->query_result,$pi,"pprice"); $smarty->assign('pid',$pid); $smarty->assign('pname',$pname); $smarty->assign('pprice',$pprice); $smarty->display('order_product_row.tpl'); $pi++; } $ci++; } $CDB->Disconnect(); $smarty->display('order_bottom.tpl'); $smarty->display('footer.tpl'); ?> Here is the class code: <?php class CPDatabase { function CPDatabase() { global $config; require("".$config['includes']."db.php"); } function QueryRow($query) { $this->query_result = mysql_query($query); $this->query_num_rows = mysql_num_rows($this->query_result); $this->query_data = mysql_fetch_array($this->query_result); } function InsertRow($query) { $this->query_result = mysql_query($query); } function UpdateRow($query) { $this->query_result = mysql_query($query); } // Disconnect from the MYSQL database function Disconnect() { mysql_close() or die("MYSQL ERROR: ".mysql_error()); } } ?> Any tips? Thanks
  12. Here is what is should look [a href=\"http://img357.imageshack.us/img357/6646/good5iu.gif\" target=\"_blank\"]like[/a] (in IE and Opera) but this is what it [a href=\"http://img165.imageshack.us/img165/5157/bad0vb.gif\" target=\"_blank\"]looks like[/a] in firefox. As you can see the "Member Info" bar is 1px shorter than it should be. Here is my code: [!--html--][div class=\'htmltop\']HTML[/div][div class=\'htmlmain\'][!--html1--]<[color=blue]center[/color]><[color=blue]img alt[/color]='[color=orange]' src='/images/customer-area.gif[/color]' /> <[color=blue]form action[/color]='[color=orange]./password_proccess.php[/color]' method='[color=orange]post[/color]'> <[color=blue]div class[/color]='[color=orange]member-wrap[/color]'> <[color=blue]div class[/color]='[color=orange]member-left[/color]'> <[color=blue]div class[/color]='[color=orange]table-top-wrap[/color]'><[color=blue]div class[/color]='[color=orange]table-top[/color]'><[color=blue]h2[/color]>Members Info<[color=blue]/h2[/color]><[color=blue]/div[/color]><[color=blue]/div[/color]> <[color=blue]table class[/color]='[color=orange]main-table-members[/color]' cellpadding='[color=orange]0[/color]' cellspacing='[color=orange]1[/color]'> <[color=blue]tr[/color]> <[color=blue]td class[/color]='[color=orange]column1[/color]' width='[color=orange]100%[/color]'><[color=blue]b[/color]>Welcome John Smith<[color=blue]/b[/color]><[color=blue]br /[/color]><[color=blue]br /[/color]> • <[color=blue]a href[/color]='[color=orange]/customers/help.php[/color]'>Help Page<[color=blue]/a[/color]><[color=blue]br /[/color]> • <[color=blue]a href[/color]='[color=orange]/customers/support.php[/color]'>Contact Support<[color=blue]/a[/color]><[color=blue]br /[/color]> • <[color=blue]a href[/color]='[color=orange]/customers/order.php[/color]'>Products<[color=blue]/a[/color]><[color=blue]br /[/color]> • <[color=blue]a href[/color]='[color=orange]/customers/email_edit.php[/color]'>Change my email<[color=blue]/a[/color]><[color=blue]br /[/color]> • <[color=blue]a href[/color]='[color=orange]/customers/password_edit.php[/color]'>Change my password<[color=blue]/a[/color]><[color=blue]br /[/color]> • <[color=blue]a href[/color]='[color=orange]/customers/logout.php[/color]'>Logout<[color=blue]/a[/color]><[color=blue]/td[/color]> <[color=blue]/tr[/color]> <[color=blue]/table[/color]> <[color=blue]/div[/color]> <[color=blue]div class[/color]='[color=orange]member-right[/color]'> <[color=blue]div class[/color]='[color=orange]table-top-wrap[/color]'><[color=blue]div class[/color]='[color=orange]table-top[/color]'><[color=blue]h2[/color]>Change Your Password<[color=blue]/h2[/color]><[color=blue]/div[/color]><[color=blue]/div[/color]> <[color=blue]table class[/color]='[color=orange]main-table-members[/color]' cellpadding='[color=orange]0[/color]' cellspacing='[color=orange]1[/color]'> <[color=blue]tr[/color]> <[color=blue]td class[/color]='[color=orange]column1[/color]' width='[color=orange]50%[/color]' valign='[color=orange]top[/color]'><[color=blue]b[/color]>Your new password:<[color=blue]/b[/color]><[color=blue]/td[/color]> <[color=blue]td class[/color]='[color=orange]column2[/color]' width='[color=orange]50%[/color]' valign='[color=orange]top[/color]'><[color=blue]input type[/color]='[color=orange]password[/color]' name='[color=orange]password_edit[/color]' /><[color=blue]/td[/color]> <[color=blue]/tr[/color]> <[color=blue]tr[/color]> <[color=blue]td class[/color]='[color=orange]column1[/color]' width='[color=orange]50%[/color]' valign='[color=orange]top[/color]'><[color=blue]b[/color]>Confirm your current password:<[color=blue]/b[/color]><[color=blue]/td[/color]> <[color=blue]td class[/color]='[color=orange]column2[/color]' width='[color=orange]50%[/color]' valign='[color=orange]top[/color]'><[color=blue]input type[/color]='[color=orange]password[/color]' name='[color=orange]password_edit2[/color]' /><[color=blue]/td[/color]> <[color=blue]/tr[/color]> <[color=blue]tr[/color]> <[color=blue]td class[/color]='[color=orange]column1[/color]' width='[color=orange]50%[/color]' valign='[color=orange]top[/color]'><[color=blue]b[/color]>Confirm your current password:<[color=blue]/b[/color]><[color=blue]/td[/color]> <[color=blue]td class[/color]='[color=orange]column2[/color]' width='[color=orange]50%[/color]' valign='[color=orange]top[/color]'><[color=blue]input type[/color]='[color=orange]password[/color]' name='[color=orange]password_confirm[/color]' /><[color=blue]/td[/color]> <[color=blue]/tr[/color]> <[color=blue]/table[/color]> <[color=blue]/div[/color]> <[color=blue]/div[/color]> <[color=blue]div class[/color]="[color=orange]clear-div[/color]"><[color=blue]br /[/color]><[color=blue]br /[/color]><[color=blue]br /[/color]><[color=blue]/div[/color]> <[color=blue]input type[/color]="[color=orange]submit[/color]" value="[color=orange]Save Changes[/color]" /> <[color=blue]/form[/color]> <[color=blue]/center[/color]>[!--html2--][/div][!--html3--] CSS used: [code].member-wrap {     width: 98%;     text-align: center; } .member-left {     float: left;     width: 28%;     /*height: 100%;*/     text-align: center; } .member-right {     float: right;     border: 0;     width: 71%;     text-align: left; } .main-table-members {     margin: 0;     padding: 0;     width: 100%;     height: 200px;     background-color: #FFFFFF;     border: 1px solid #000000;     border-top: 0; } .table-top-wrap {     margin: 0;     padding: 0;     border: 1px solid #000000;     border-bottom: 0; } .table-top {     margin: 0;     padding: 0;     height: 25px;     background: #175299 url("/images/top_bg.gif");     color: #FFFFFF;     font-size: 1em;     text-align: center;     border: 1px solid #FFFFFF;     border-bottom: 0; } .table-top h2 {     padding-top: 4px;     color: #FFFFFF;     font-size: 1em; } .clear-div {     font-size:1px;     overflow:hidden;     clear:both; }[/code] I know the problem is caused by the widths in member-right and member-left. Thanks
  13. What button style, I do not have one? Thanks
  14. Thanks alot mate, that has fixed the button issue. I have learnt from that so I will know in the future. Any idea on how to fix my height issue in IE? Thanks again
×
×
  • 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.