yurad Posted March 21, 2011 Share Posted March 21, 2011 Well... trying to teach myself php/mysql programming and it's not going so well :/ I'm attempting to add a statement on the address_book.php page to query address_book table and check for contents in entry_telephone field. If field is empty >> display message. If field is populated >> skip message. Something like this: <?php $phone_check = tep_db_query("select address_book_id, entry_firstname, entry_lastname, entry_telephone from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . (int)$customer_id . "' order by entry_firstname, entry_lastname"); $phone_check_array = tep_db_fetch_array($phone_check); if ($phone_check_array['entry_telephone'] ==NULL) { ?> <tr> <td><?php echo $messageStack->output('addressbook'); ?></td> </tr> <?php } ?> REST OF CODE HERE... if continue... Any help with what I'm doing wrong would be much appreciated! Thanks! Link to comment Share on other sites More sharing options...
Guest Posted March 21, 2011 Share Posted March 21, 2011 Yura, The code is redundant as the telephone field is mandatory in osCommerce. So the file will always be populated. Chris Link to comment Share on other sites More sharing options...
yurad Posted March 21, 2011 Author Share Posted March 21, 2011 Yura, The code is redundant as the telephone field is mandatory in osCommerce. So the file will always be populated. Chris Yes... in default osc install, you are correct :) But this site has been highly modified and typical registration has been shortened to only ask for name, email address and password :) Link to comment Share on other sites More sharing options...
npn2531 Posted March 21, 2011 Share Posted March 21, 2011 The telephone number is normally stored in the customers table, not the address_book table. Normally you would do this: $account_query = tep_db_query("select customers_gender, customers_firstname, customers_lastname, customers_dob, customers_email_address, customers_telephone, customers_fax from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$customer_id . "'"); $account = tep_db_fetch_array($account_query); echo $account['customers_telephone']; Assuming you have a custom field in address_book table called entry_telephone your code should work. However, you probably don't have enough code to generate an error msg, and <?php echo $messageStack->output('addressbook'); ?> just comes up blank no matter what. Try this as a test: <?php $phone_check = tep_db_query("select address_book_id, entry_firstname, entry_lastname, entry_telephone from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . (int)$customer_id . "' order by entry_firstname, entry_lastname"); $phone_check_array = tep_db_fetch_array($phone_check); if ($phone_check_array['entry_telephone'] ==NULL) { ?> <tr> <td><?php echo 'there is no phone number'; ?></td> </tr> <?php }else{ ?> <tr> <td><?php echo $phone_check_array['entry_telephone']; ?></td> </tr> <?php } ?> That way if you get your hardcoded msg ('there is no phone number') or a phone number you know your code is good, but you need to figure out to access the msgs. ps - and there is nothing wrong with using the hardcoded msg like above, esp if you have only one msg to display such as 'type in a phone#' . Oscommerce site: OSC to CSS, http://addons.oscommerce.com/info/7263 -Mail Manager, http://addons.oscommerce.com/info/8120 Link to comment Share on other sites More sharing options...
yurad Posted March 21, 2011 Author Share Posted March 21, 2011 The telephone number is normally stored in the customers table, not the address_book table. Normally you would do this: $account_query = tep_db_query("select customers_gender, customers_firstname, customers_lastname, customers_dob, customers_email_address, customers_telephone, customers_fax from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$customer_id . "'"); $account = tep_db_fetch_array($account_query); echo $account['customers_telephone']; Assuming you have a custom field in address_book table called entry_telephone your code should work. However, you probably don't have enough code to generate an error msg, and <?php echo $messageStack->output('addressbook'); ?> just comes up blank no matter what. Try this as a test: <?php $phone_check = tep_db_query("select address_book_id, entry_firstname, entry_lastname, entry_telephone from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . (int)$customer_id . "' order by entry_firstname, entry_lastname"); $phone_check_array = tep_db_fetch_array($phone_check); if ($phone_check_array['entry_telephone'] ==NULL) { ?> <tr> <td><?php echo 'there is no phone number'; ?></td> </tr> <?php }else{ ?> <tr> <td><?php echo $phone_check_array['entry_telephone']; ?></td> </tr> <?php } ?> That way if you get your hardcoded msg ('there is no phone number') or a phone number you know your code is good, but you need to figure out to access the msgs. ps - and there is nothing wrong with using the hardcoded msg like above, esp if you have only one msg to display such as 'type in a phone#' . THANKS! Got it all working :) Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.