Jump to content

Failure to Select Option


X51

Recommended Posts

OK so I'm having a pull my hair out moment. I have spent all day trying to figure this out. I have a select box for a list of customers where one customer is unique and I want that account to appear twice in the list. That part was easy and when selected the appropriate info populates the page.

 

The problem I am having is that no matter which one of those two options I click it only selects the second option . So in other words if these are the two options in the list:

 

Some Business Week 1

Some Business Week 2

 

when I click either, Some Business Week 2 is always the one selected even though the page populates correctly. Any thoughts on what I need to change?

 

  <?php do {
		mysql_select_db($database_customers, $customers);
		$query_multiple = "SELECT accnt, week, alt FROM schedule WHERE accnt = " . $customer['accnt'];
		$multiple_sel = mysql_query($query_multiple, $customers) or die(mysql_error());
		$multiple = mysql_fetch_assoc($multiple_sel);
		$multiple_run = $multiple['alt'];

		if($multiple_run > 1) {

			for ($i = 1; $i <= $multiple_run; $i++) {

		mysql_select_db($database_customers, $customers);
		$query_get_week = "SELECT week, alt FROM schedule WHERE accnt = " . $customer['accnt'] . " AND alt = " . $i;
		$get_week_sel = mysql_query($query_get_week, $customers) or die(mysql_error());
		$get_week = mysql_fetch_assoc($get_week_sel);

$version1 = $inv_title . " Week " . $get_week['week'];
$version2 = $customer['name'] . " Week " . $get_week['week']; ?>

         <option value="report.php?accnt=<?php echo $customer['accnt']; ?>&alt=<?php echo $get_week['alt'];?>"<?php if (!(strcmp($version1, $version2))) {echo "selected=\"selected\"";} ?>><?php echo $version2; ?></option>

<?php 				}
		 } else {
$version1 = $inv_title;
$version2 = $customer['name']; ?>

         <option value="report.php?accnt=<?php echo $customer['accnt']; ?>&alt=<?php echo $multiple['alt'];?>"<?php if (!(strcmp($version1, $version2))) {echo "selected=\"selected\"";} ?>><?php echo $version2; ?></option>
<?php } ?>
       <?php } while ($customer = mysql_fetch_assoc($customer_sel)); ?>


Link to comment
Share on other sites

Finally figured out how to get around this, only took a week :)

 

Had to abandon this method completely and add another column to the scheduling table with a unique business name based on the schedule (rather than try to concatenate the business name with the week of service). Then use a left join to combine the tables with select distinct so only businesses with more than one variation of the schedule would show up twice in the drop down menu.

 

So the string comparison no longer uses the account number (which would always be the same number if two variations exist) it now compares the unique business names so I can have the selected one be the one that was picked.

 

The only real drawback I can see is that if I change a business name in one table I will have to remember to change this unique name also, but I don't see that as too big a problem.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.