Jump to content

Show Next Result in dropdown box


Caffeinenyx

Recommended Posts


for ($i = 1; $i<$rows+1; $i++)
{
	$Choicequery ="SELECT PersonA, PersonB FROM modules WHERE GroupID = '$UpdateNumber'";
	$Choiceresult = mysql_query($Choicequery);
	$ChoiceRows = mysql_fetch_array($Choiceresult);

	$PersonQuery = "SELECT FirstName, LastName FROM Persons p, modules m, users e, group t WHERE m.modID = $ChoiceRows[0] AND e.UserID = m.PersonA AND p.PersonID = e.PersonID";
	$PersonResult = mysql_query($PersonQuery);
	$PersonRows = mysql_fetch_array($PersonResult);

	$Person2Query = "SELECT FirstName, LastName FROM Persons p, modules m, users e, group t WHERE m.modID = $ChoiceRows[0] AND e.UserID = m.PersonB AND p.PersonID = e.PersonID";
	$Person2Result = mysql_query($Person2Query);
	$Person2Rows = mysql_fetch_array($Person2Result);

	echo "<Option value = \"$i\">$PersonRows[0] $PersonRows[1] and $Person2Rows[0] $Person2Rows[1] </Option>";
}

 

How do I get it to show the next result when $i increases? All the options are the first people A and B $i number of times. Not sure how to use a loop here to go though the results. Whats the best way?

 

ie $PersonRows[0] $PersonRows[1] are the same for every option

Link to comment
https://forums.phpfreaks.com/topic/235445-show-next-result-in-dropdown-box/
Share on other sites

I dont think the above is explained very well, also If I could add ORDER BY to topic...

 

echo "<Option value = \"$i\">$PersonRows[0] $PersonRows[1] and $Person2Rows[0] $Person2Rows[1] </Option>";

 

I need to iterate though the results of $PersonRows[0] $PersonRows[1] and $Person2Rows[0] $Person2Rows[1]  for each $i

 

At the moment I get

Andy Smith
Andy Smith
Andy Smith

 

 

But I need

 

Andy Smith
Tim Carbrook
Tom Steptoe

 

etc,

 

Also I have

 

$Choicequery ="SELECT PersonA, PersonB FROM modules WHERE GroupID = '$UpdateNumber'"; or
$Choicequery ="SELECT PersonA, PersonB,StartDate FROM modules WHERE GroupID = '$UpdateNumber'";

 

But if I add ORDER BY StartDate, it returns nothing? I really need them ordered....

 

 

 

Any ideas?, thanks

Archived

This topic is now archived and is closed to further replies.

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