Jump to content

ivalea

Members
  • Posts

    24
  • Joined

  • Last visited

    Never

Everything posted by ivalea

  1. Thanks businessman - after talking to the client, I decided instead of removing them from the table completely - which would make it more work to reinstate them - that I would just create another column in the table that either has a 1 or 0 value.  Then I just placed an update in the admin so that it updates this field through a dropdown.  This allows the admin then to turn the student off or on.  Students only gain access to their pages if this active column is set to 1. Works great! Thanks again for the speedy response though!  :)
  2. Hello! I have a database that includes a customers table and a students table.  In my admin I have the ability to update a customers information.  I'm looking to include a dropdown menu on this customers page that allows me to use a dropdown to select a yes or no under a heading of student access. Yes = delete record from students table No = add current customer to students table I'm not really sure on how to go about this - can someone point me in the right direction of how I could accomplish this?  Even direction of where I could find a tutorial for this specifically would greatly help!  Thanks!
  3. I'm working with oscommerce and created a table called students.  We have one product that is actually a course.  Once a customer purchases this course, it's supposed to add them to the students table.  On the checkout success page I first did a select statement that is supposed to look at the order just made and see if the product model matches the one of the course.  If, and ONLY if it does, then select the customers email address from the customers table and add them to the students table along with their customer id.  If the product model of the item just purchased doesn't match then do absolutely nothing.  I've tried this over and over again and I cannot seem to get it to act right.  Either all purchases are added to the students table or none at all whether they've purchased the correct product or not.  i'm ashamed to admit it, but I've been trying to get this small piece to work for a week now.... ??? Any help on this would be sooooo appreciated. Please note that where it says "INSERT CUSTOMERS ID HERE" in the insert statement - this is because I was unsure of where and how to get the customers email from the customers table. Here is my code: [code] <?php       $model_query = mysql_query("select products_model from orders_products where orders_id = '" . (int)$orders['orders_id'] . "' and products_model = 'CBT-0100'"); $result = mysql_query($mod_query); if($result){ $studentsquery = mysql_query("insert into students (students_id, customers_id, students_pmodel, students_email, students_mod1, students_mod2, students_mod3, students_manual, students_cert) values ('', '" . (int)$customer_id['customers_id'] . "', 'CBT-0100', 'INSERT - CUSTOMER ID HERE', '', '', '', '', '')"); }else{ echo ''; }   ?> [/code]
  4. Not sure - just that I need the "if" in there to make sure that the order contains that specific product model. So, I first need to pull the order information and then select the model number purchased.  Only if the model number purchased is equal to a specific string, then insert into the students table.  I'll look into doing an INSERT INTO .... SELECT though - thanks! :)
  5. Hi, I'm trying to grab the results of a select statement and only if the result is equal to a certain string use an insert to add to a different table.  I looks like my select is okay - but now I'm wondering how I can run the insert... here is my code: [code] $a = mysql_query("select * from orders_products as op, customers as c where op.orders_id = '000099' and op.products_id = '29' and c.customers_id = '14'"); while($row = mysql_fetch_assoc($a)){ $id = $row['products_model']; $email = $row['customers_email_address']; $custid = $row['customers_id']; } if ($id == 'CBT-0100'){ echo 'Now run the insert query using $email, $custid, and $id'; $z = mysql_query("insert into students (students_id, customers_id, students_pmodel, students_email, students_mod1, students_mod2, students_mod3, students_manual, students_cert) values ('', '$custid', '$id', '$email', '', '', '', '', ''"); }else{ echo 'something here'; } [/code] Desperately need help with this - project is due today and this is the last piece that I need to lauch!  Thanks! :)
  6. Thanks Jocka - i actually got the fpdf thing worked out - though now file size is huge! :) Also, I'm not altogether sure how use sessions for this purpose - would I have to add anything to the db for this to work?  Thanks! :)
  7. Hi - I'm trying to run a query that first checks to see if a customer has purchased a certain product and then if they have add them to a table in the db and print out a success message.  I swore I had this working a couple of days ago - thought I'd test it again today and now it's not only NOT adding the customer to the table but there's no message either.  Can you spot the error - maybe i've just been looking at it too long??? [code] $products = $cart->get_products(); $anycourse =0; for ($i=0, $n=sizeof($products); $i<$n; $i++)   { $val=mysql_fetch_array( mysql_query("select  pd.products_description, p.products_model from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . (int)$products[$i]['id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'")); if ($val = 'CBT-0100'){ $query = "select customers_email_address from customers where customers_id = '" . (int)$customer_id . "'"; $result = mysql_query ($query); $email=mysql_result($result,"customers_email_address"); if ($result){ $query = "INSERT INTO students (students_id, customers_id, students_pmodel, students_email, students_mod1, students_mod2, students_mod3) values ('', '$customer_id', '$model', '$email', '', '', '')"; $result = mysql_query ($query); if ($result) { $anycourse = 1; }else{ echo 'Could not add customer to db'; } } } }//end for if ($anycourse == 1)     echo '<p>Thank you for enrolling in our online course.  To login to your course please go to "My Account".</p>'; [/code] Thanks in advance for any help you can provide!  :)
  8. Hello - I've got a page that includes a link to download a dynamic pdf using the fpdf class and I've got a couple of questions - been searching for awhile now and I can't find the answer!  ??? First, is there a way for me to make the link available to users for only a certain number of attempts without having to set up something in mysql? Second, would anyone familiar with fpdf happen to know how I can get my images to come out looking better?  I'm not sure if it's the way they're are being set on the page or if it's just how the class generates the pdf.  I've tried using a 300dpi jpg and png but still my images are fuzzy. Thanks! 
  9. Hello, I'm trying to pull customers first name and last name from mysql.  What I want to do is say if there is no result returned then either echo an error message or redirect to another page.  But what I have now , lets the user into the page whether they are found in the table or not. All I'm trying to do is get the customers first and last name but only if their email address is found in the students table.  Here is what I have: [code] $result = mysql_query("SELECT customers.customers_firstname, customers.customers_lastname from customers, students where students.students_email = customers.customers_email_address") or die (mysql_error()); if(!result){ echo 'None'; }else{ while ($row = mysql_num_rows($result)) { $first .= $row[ 'customers_firstname' ]; $last .= $row[ 'customers_lastname' ]; } } [/code] This returns a server error when running the script...  Any thoughts on how I can achive this correctly?  Thanks! :)
  10. Thanks roopert!  Basically what I'm doing is building a menu based upon which product a member has purchased.  There should be up to ten model #'s that once purchased give the user access to the corresponding directory.  So on this success page, it should automatically enter the user in a separate members table - since there are other products other than these 10 - later, on their main account page, I use a switch to build the menu based upon the information included in the members table. Unfortunately, I tried the script you provided and it didn't work.  I totally get what you were trying to explain so I'll try something else.  Thanks again! :)
  11. Hi - I'm building a site with a shopping cart and on the checkout success page I would like to check and see what model number they purchased and then run a query based on which model number it was.  What I'm trying to find out is how would I assign my variable for this?  Right now I have this: [code] if ($partno = 'B-100'){ //then run query } [/code] Basically all part no's will begin with B-.  I tried the || w/o any success: [code] if ($partno = 'B-100' || 'B-200') { //then run query } [/code] Any easy ways to accomplish this?  Thanks in advance!  :)
  12. Thanks everyone for the help - I do have it working now.  Thanks printf - after reading your post I realized that all i really needed was the model #.  Now the only problem I have is that if there is more than one row with an email address matching the email address on file how can I get it to show both c1 and c2?  Here's what I have now - works perfect but only returns one row: [code] $query = "select members.members_pmodel from members, customers where members.members_email = customers.customers_email_address"; $result = @mysql_query ($query); $num=mysql_num_rows($result); $i=0; while ($i < $num){ $model=mysql_result($result,$i,"members_pmodel"); echo ""; $i++; } switch($model){ case 'c1': echo tep_image(DIR_WS_IMAGES . 'arrow_green.gif') . ' <a href="' . tep_href_link(FILENAME_C1, '', 'SSL') . '">' . MY_COURSES_C1 . '</a>'; break; case 'c2': echo tep_image(DIR_WS_IMAGES . 'arrow_green.gif') . ' <a href="' . tep_href_link(FILENAME_C2, '', 'SSL') . '">' . MY_COURSES_C2 . '</a>'; break; }[/code] I was getting errors trying to use mysql_fetch...() - this way it will at least return one row.  But if there are two or more rows containing the same email address I need it to return both rows.  Not sure what to change here...
  13. Hello - I'm trying to display a menu based upon information in two tables.  I've inserted a query that looks like this: [code]$query = "select * from members, customers"; $result = @mysql_query ($query); $num=mysql_numrows($result); $i=0; while ($i < $num){ $model=mysql_result($result,$i,"members_pmodel"); $first=mysql_result($result,$i,"members_fname"); $last=mysql_result($result,$i,"members_lname"); $company=mysql_result($result,$i,"members_company"); $address=mysql_result($result,$i,"members_address"); $city=mysql_result($result,$i,"members_city"); $state=mysql_result($result,$i,"members_state"); $zip=mysql_result($result,$i,"members_zip"); $email=mysql_result($result,$i,"members_email"); $phone=mysql_result($result,$i,"members_phone"); $email2=mysql_result(result,$i,"customers_email_address"); echo ""; $i++; }[/code] Then right after that I have this: [code]if ($email == $email2){ switch($model){ case 'c1': echo tep_image(DIR_WS_IMAGES . 'arrow_green.gif') . ' <a href="' . tep_href_link(FILENAME_C1, '', 'SSL') . '">' . MY_COURSES_C1 . '</a>'; break;             case 'c2':             echo tep_image(DIR_WS_IMAGES .'arrow_green.gif') . ' <a href="' . tep_href_link (FILENAME_C2, '', 'SSL') . '">' . MY_COURSES_C2 . '</a>'; } }else{ echo "You are not enrolled in any courses at this time."; }[/code] What I am trying to do is to display a different menu based upon the model number in the members table - but first I need to check if the email address in the customers table exists in the members table. I keep getting this error though: Warning: mysql_result(): supplied argument is not a valid MySQL result resource in /home/www/os.xephor.net/catalog/account.php on line 152 Warning: mysql_result(): supplied argument is not a valid MySQL result resource in /home/www/os.xephor.net/catalog/account.php on line 152 Warning: mysql_result(): supplied argument is not a valid MySQL result resource in /home/www/os.xephor.net/catalog/account.php on line 152 Warning: mysql_result(): supplied argument is not a valid MySQL result resource in /home/www/os.xephor.net/catalog/account.php on line 152 Any thoughts on how to fix this?  Perhaps my code is wrong?  Thanks! :)
  14. Thanks much Keith - that seemed to do the trick! - Irene :)
  15. on line 97 - right after this code which displays the checkbox to receive notifications on items just purchased: [code] $products_displayed = array();     for ($i=0, $n=sizeof($products_array); $i<$n; $i++) {       if (!in_array($products_array[$i]['id'], $products_displayed)) {         echo tep_draw_checkbox_field('notify[]', $products_array[$i]['id']) . ' ' . $products_array[$i]['text'] . '<br>';         $products_displayed[] = $products_array[$i]['id'];       }     }     echo '</p>';   } else {     echo TEXT_SEE_ORDERS . '<br><br>' . TEXT_CONTACT_STORE_OWNER;   }[/code]
  16. Hi all - I'm working with oscommerce and am trying to modify my checkout_success page to basically display a form if the customer purchased a certain model number. right now here is my select statement: [code]$products_array = array();     $products_query = tep_db_query("select products_id, products_name, products_model from " . TABLE_ORDERS_PRODUCTS . " where orders_id = '" . (int)$orders['orders_id'] . "' order by products_name");     while ($products = tep_db_fetch_array($products_query)) {       $products_array[] = array('id' => $products['products_id'],                                 'text' => $products['products_name'], 'model' => $products['products_model']);     }   }[/code] And this is what I have to display the form: [code] if ($products_array['model'] == 'm1'){   include(form.php); }else{ echo ''; }[/code] The problem is that even when the correct model is purchased that part of the page is still blank - not even so much as an error code.  Any thoughts on how I can get this working? Thanks!  :)
  17. Thanks nogray - I'll give that a try. So is there any other way to accomplish this using PHP?
  18. Hello, A while ago I thought that I read somewhere that HTTP_REFERER could be used to make sure that visitors are coming from a certain page. For example, I want visitors to not gain acces to 2.php unless they've clicked on a link to it from 1.php. I thought that I could use something like: [code] <?php if ($_SERVER['HTTP_REFERER'] != "http://domain.com/1.php") {          header("Location: http://www.domain.com/2.php"); } ?>[/code] But that is not working. Even when clicking on the link placed in 1.php, 2.php never loads. Any insight on how to accomplish this would be so appreciated. Thanks!
  19. I've got a page where user can upload images and I'm wondering how to restrict file size by pixels and echo error if too large. My code is this: [code] if(isset($_POST[s1])) {     if(!empty($_FILES[images][name][0]))     {         while(list($key,$value) = each($_FILES[images][name]))         {             if(!empty($value))             {                 $NewImageName = $t."_offer_".$value;                 copy($_FILES[images][tmp_name][$key], "re_images/".$NewImageName);                 $MyImages[] = $NewImageName;             }         }         if(!empty($MyImages))         {             $ImageStr = implode("|", $MyImages);         }              } [/code] Other possibility - any way to check file size through javascript? Thanks!
  20. Hi! I am trying to build a search form (am still pretty new to PHP and MySQL so please bear with me) that searches by min and max price by dropdown - like on a real estate site. Right now it's written so that if there are any listings in the database then it takes those prices and puts them in the dropdown. Otherwise if there are no listings then the dropdown shows no options. My code is this: $MinPrice = "<select name=min>\n\t<option value=\"\">Minimum</option>\n\t"; $q1 = "select distinct Price from re2_listings order by Price asc"; $r1 = mysql_query($q1) or die(mysql_error()); if(mysql_num_rows($r1) > '0') { while($a1 = mysql_fetch_array($r1)) { $prices .= "<option value=\"$a1[Price]\">$ $a1[Price]</option>\n\t"; } } $MinPrice .= $prices."</select>\n"; //set the max price menu $MaxPrice = "<select name=max>\n\t<option value=\"\">Maximum</option>\n\t"; $MaxPrice .= $prices."</select>\n"; Then all I do is reference <?=$MinPrice?> and <?=$MaxPrice?> in the html form where the select should be. I need the dropdown to display price values in increments of $50,000 starting at $150,000 and ending at $1,000,000+. I tried inserting a select field in the form the way it normally would be and then setting id's to MinPrice and MaxPrice but that didn't work. Sorry to be soooo long winded but I've been at this for what seems forever and I so need help! :) Any thoughts at all as to how I can accomplish this would be sooo greatly appreciated! Thanks! - Irene
  21. Hi - I'm having a problem with my forms and I'm hoping someone can help.... I've been at it the better part of the day and am at my wits end. I have an index page that includes login.php and search.php. For some reason when I click on "Search" it tries to validate the login form. Login is validated with Javascript and works fine. The name of each form is different as well as the action - each action points to different pages entirely the only common reference I notice in each is the submit button names - both are sl - however when I change this it still happens. Any insight as to why this would happen would be awesome! Thanks - Irene :)
  22. Thanks soccer for your reply... unfortunately this was what I thought to be the logical solution and tried it first but it didn't work. I finally did get it to work though by adding a separate if to the page directly. So the main access page just checks to see if they are logged in and then passes them onto the page and then checks to see what type of account they have. Maybe not the best solution, but it works! :) Thanks!
  23. Hi - I'm sortof a newb when it comes to PHP and I'm trying to build a site that offers two account types. I also have pages that I want to restrict access to depending if they have an account type of 1 or 2. I am having some trouble with the if statement that would not only check to see if the user is logged in, but logged in with a certain account type. This is what I have: if(empty($_SESSION[user1])) { include_once("lerr.php"); } My question is how to I get it to say if user is logged in AND account type = 1 then direct them to the page otherwise show the lerr.php page. I hope I've explained this correctly. Any help would be greatly appreciated - I've spent way too much time on this one. :) Thanks! ivalea
×
×
  • 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.