Jump to content

[SOLVED] from help in php


nezbo

Recommended Posts

Hi all

 

I have a from that i want to repeat over an over again. i have setup a page where it sets up a table, with a link for the id number what you click on to activate it, and a drop for the diffrent options.

 

the way i have got it to work is to refresh the fpage and keep the drop down. but then it all the items become a same.

 

Hope this makes sense.

 

here is the code

 

<?php
	$details = mysql_query("SELECT * FROM users WHERE validateUser = 0 ORDER BY surname") or mysql_error();
	while ($getUserDetails = mysql_fetch_array($details))
	{

		$userGroupe = mysql_query("SELECT * FROM usergroups " . NEW_WHERE . "") or die(mysql_error());
		$area = mysql_query("SELECT * FROM area WHERE valid = 0 and areaID = '$getUserDetails[area]'") or mysql_error();
		while ($getArea = mysql_fetch_array($area))
		{
			$theArea = $getArea['areaName'];
		}
		echo "<tr class=bTable>";
		echo "<td><span class=small><a href=" . $_SERVER['PHP_SELF'] ."?g=" . $_POST['userGroups'] . "&selectedNewUser=" . $getUserDetails['userID'] . "&o=1>Yes</a></span></td><td><span class=small><a href=" . $_SERVER['PHP_SELF'] ."?selectedNewUser=" . $getUserDetails['userID'] . "&o=2>No</a></span></td><td><span class=\"small\"> $getUserDetails[userName]</span></td><td><span class=\"small\">$getUserDetails[forename] $getUserDetails[surname]</span></td><td><span class=\"small\">$theArea</span></td><td><span class=\"small\">$getUserDetails[resion]</span></td>";
		echo "<td><select name='userGroups' onchange=form1.submit()><option value=''>" . F_SELECT_ONE . "</option>";
		while($noticia = mysql_fetch_array($userGroupe)) {
			echo "<form action=" . $_SERVER['PHP_SELF'] . " name=\"form1\"  method=\"post\">";
			if ($_POST['userGroups'] == $noticia['groupID'])
			{	

				echo "<option selected=\"selected\" value='$noticia[groupID]'>$noticia[groupName]</option>";

			}
			else
			{
				echo "<option value='$noticia[groupID]'>$noticia[groupName]</option>";
			}
			echo "</form>";
		}
		echo "</td>";
		echo "</tr>";

	}
?>	

 

is there any other way of doing this?

 

Neil

Link to comment
Share on other sites

i guess the main thing i want to do is update a link

 

i have the link :

 

$_SERVER['php_self'] . "g= *****

 

 

the ***** is the point i want to get a dropdown to input the number of the group (the group is in the drop down)

Link to comment
Share on other sites

i have no idea how to use Ajax, unless any one has any idea how to do this?

 

and i am also not to sure how to do this with the for refresh either. i have updated my code so it refreshes, but it doesnt work.

 

<?php
	$form = array();
	$details = mysql_query("SELECT * FROM users WHERE validateUser = 0 ORDER BY surname") or mysql_error();
	echo "<form action=" . $_SERVER['PHP_SELF'] . " name=\"form1\"  method=\"post\">";
	while ($getUserDetails = mysql_fetch_array($details))
	{

		$userGroupe = mysql_query("SELECT * FROM usergroups " . NEW_WHERE . "") or die(mysql_error());
		$area = mysql_query("SELECT * FROM area WHERE valid = 0 and areaID = '$getUserDetails[area]'") or mysql_error();
		while ($getArea = mysql_fetch_array($area))
		{
			$theArea = $getArea['areaName'];
		}
		echo "<tr class=bTable>";
		echo "<td><span class=small><a href=" . $_SERVER['PHP_SELF'] ."?g=" . $_POST['userGroups'] . "&selectedNewUser=" . $getUserDetails['userID'] . "&o=1>Yes</a></span></td><td><span class=small><a href=" . $_SERVER['PHP_SELF'] ."?selectedNewUser=" . $getUserDetails['userID'] . "&o=2>No</a></span></td><td><span class=\"small\"> $getUserDetails[userName]</span></td><td><span class=\"small\">$getUserDetails[forename] $getUserDetails[surname]</span></td><td><span class=\"small\">$theArea</span></td><td><span class=\"small\">$getUserDetails[resion]</span></td>";
		echo "<td><select name='userGroups' onchange=form1.submit()><option value=''>" . F_SELECT_ONE . "</option>";
		while($noticia = mysql_fetch_array($userGroupe)) {

			if ($_POST['userGroups'] == $noticia['groupID'])
			{	

				echo "<option selected=\"selected\" value='$noticia[groupID]'>$noticia[groupName]</option>";

			}
			else
			{
				echo "<option value='$noticia[groupID]'>$noticia[groupName]</option>";
			}

		}
		echo "</td>";
		echo "</tr>";

	}
	echo "</form>";
?>

Link to comment
Share on other sites

here you go hope its helpfull.. change quite a lot of things


<?php
	$form = array();
	$details = mysql_query("SELECT * FROM users WHERE validateUser = 0 ORDER BY surname") or mysql_error();
	while ($getUserDetails = mysql_fetch_array($details))
	{

		$userGroupe = mysql_query("SELECT * FROM usergroups " . NEW_WHERE . "") or die(mysql_error());
		$area = mysql_query("SELECT * FROM area WHERE valid = 0 and areaID = '$getUserDetails[area]'") or mysql_error();
		while ($getArea = mysql_fetch_array($area))
		{
			$theArea = $getArea['areaName'];
		}
		echo "<form action=" . $_SERVER['PHP_SELF'] . " method=\"post\">";
		echo "<tr class=bTable>";
		echo "<td><span class=small><a href=" . $_SERVER['PHP_SELF'] ."?g=" . $_POST['userGroups'] . "&selectedNewUser=" . $getUserDetails['userID'] . "&o=1>Yes</a></span></td><td><span class=small><a href=" . $_SERVER['PHP_SELF'] ."?selectedNewUser=" . $getUserDetails['userID'] . "&o=2>No</a></span></td><td><span class=\"small\"> $getUserDetails[userName]</span></td><td><span class=\"small\">$getUserDetails[forename] $getUserDetails[surname]</span></td><td><span class=\"small\">$theArea</span></td><td><span class=\"small\">$getUserDetails[resion]</span></td>";
		echo "<td><select name='userGroups' onchange=\"this.form.submit()\"><option value=''>" . F_SELECT_ONE . "</option>";
		while($noticia = mysql_fetch_array($userGroupe)) {

			if ($_POST['userGroups'] == $noticia['groupID'])
			{	

				echo "<option selected=\"selected\" value='$noticia[groupID]'>$noticia[groupName]</option>";

			}
			else
			{
				echo "<option value='$noticia[groupID]'>$noticia[groupName]</option>";
			}

		}
		echo "</select>";
		echo "</td>";
		echo "</tr>";		
		echo "</form>";
	}
?>

Link to comment
Share on other sites

Cheers, this dose help, i think this is more or less what i have, but the problem is that it then updates all the forms with the same dropdown.

 

if i select the 'mediator', 'user' or the 'administrator' it also sets the rest of the dropdowns to the same one?

 

any ideas ?

 

Cheers for you help so far.

 

here you go hope its helpfull.. change quite a lot of things


<?php
	$form = array();
	$details = mysql_query("SELECT * FROM users WHERE validateUser = 0 ORDER BY surname") or mysql_error();
	while ($getUserDetails = mysql_fetch_array($details))
	{

		$userGroupe = mysql_query("SELECT * FROM usergroups " . NEW_WHERE . "") or die(mysql_error());
		$area = mysql_query("SELECT * FROM area WHERE valid = 0 and areaID = '$getUserDetails[area]'") or mysql_error();
		while ($getArea = mysql_fetch_array($area))
		{
			$theArea = $getArea['areaName'];
		}
		echo "<form action=" . $_SERVER['PHP_SELF'] . " method=\"post\">";
		echo "<tr class=bTable>";
		echo "<td><span class=small><a href=" . $_SERVER['PHP_SELF'] ."?g=" . $_POST['userGroups'] . "&selectedNewUser=" . $getUserDetails['userID'] . "&o=1>Yes</a></span></td><td><span class=small><a href=" . $_SERVER['PHP_SELF'] ."?selectedNewUser=" . $getUserDetails['userID'] . "&o=2>No</a></span></td><td><span class=\"small\"> $getUserDetails[userName]</span></td><td><span class=\"small\">$getUserDetails[forename] $getUserDetails[surname]</span></td><td><span class=\"small\">$theArea</span></td><td><span class=\"small\">$getUserDetails[resion]</span></td>";
		echo "<td><select name='userGroups' onchange=\"this.form.submit()\"><option value=''>" . F_SELECT_ONE . "</option>";
		while($noticia = mysql_fetch_array($userGroupe)) {

			if ($_POST['userGroups'] == $noticia['groupID'])
			{	

				echo "<option selected=\"selected\" value='$noticia[groupID]'>$noticia[groupName]</option>";

			}
			else
			{
				echo "<option value='$noticia[groupID]'>$noticia[groupName]</option>";
			}

		}
		echo "</select>";
		echo "</td>";
		echo "</tr>";		
		echo "</form>";
	}
?>

Link to comment
Share on other sites

sorry. The info is stored in the user table, but i am geting the info for the drop down from the groups table.

 

 

 

no I meant your selection should come from the table your storing the details of which group the user belongs too... which table is that ?

Link to comment
Share on other sites

Cheers for all you help.

 

i think i might have found a way round it, i have added :

 

$userID = $getUserDetails['userID'];
$tec = "userGroups" . $userID . "";

 

here is the full code. :)

 

<?php
	$details = mysql_query("SELECT * FROM users WHERE validateUser = 0 ORDER BY surname") or mysql_error();
	while ($getUserDetails = mysql_fetch_array($details))
	{
		$userID = $getUserDetails['userID'];
		$tec = "userGroups" . $userID . "";
		$userGroupe = mysql_query("SELECT * FROM usergroups " . NEW_WHERE . "") or die(mysql_error());
		$area = mysql_query("SELECT * FROM area WHERE valid = 0 and areaID = '$getUserDetails[area]'") or mysql_error();
		while ($getArea = mysql_fetch_array($area))
		{
			$theArea = $getArea['areaName'];
		}
		echo "<form action=" . $_SERVER['PHP_SELF'] . " method=\"post\">";
		echo "<tr class=bTable>";
		echo "<td><span class=small><a href=" . $_SERVER['PHP_SELF'] ."?g=" . $_POST[$tec] . "&selectedNewUser=" . $getUserDetails['userID'] . "&o=1>Yes</a></span></td><td><span class=small><a href=" . $_SERVER['PHP_SELF'] ."?selectedNewUser=" . $getUserDetails['userID'] . "&o=2>No</a></span></td><td><span class=\"small\"> $getUserDetails[userName]</span></td><td><span class=\"small\">$getUserDetails[forename] $getUserDetails[surname]</span></td><td><span class=\"small\">$theArea</span></td><td><span class=\"small\">$getUserDetails[resion]</span></td>";
		echo "<td><select name='userGroups" . $userID . "' onchange=\"this.form.submit()\"><option value=''>" . F_SELECT_ONE . "</option>";
		while($noticia = mysql_fetch_array($userGroupe)) {
			if ($_POST[$tec] == $noticia['groupID'])
			{	
				echo "<option selected=\"selected\" value='$noticia[groupID]'>$noticia[groupName]</option>";
			}
			else
			{
				echo "<option value='$noticia[groupID]'>$noticia[groupName]</option>";
			}
		}
		echo "</select>";
		echo "</td>";
		echo "</tr>";		
		echo "</form>";
	}
?>	

 

hope it makes sence to what i was trying to do.

 

cheers rajivgonsalves for all your help.

 

Neil

 

 

well in which table do you plan to store it ?

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.