Jump to content

cannot use mysql_fetch_assoc twice :S


stijn0713

Recommended Posts

hello,

 

It seems that i can't use the mysql_fetch_assoc twice. I found that it i use the mysql_fetch assoc on the result twice the second time it will be empty. I guess because the internal pointer has moved. How i can avoid this or put the internal point back with 1?

Link to comment
Share on other sites

I need it in the following code:

 

f($pad == 1){
$query = "SELECT * FROM groepen WHERE groep_id = $groep_ID";
$rs = mysql_query($query);
$row_groep = mysql_fetch_array($rs);
mysql_free_result($rs);
}

if($pad == 2) {
$query = "SELECT * FROM groepen WHERE onderzoek_id = $onderzoek_ID";
$rs = mysql_query($query);
$aantal_groepen = mysql_num_rows($rs); 
}

 

 

if ($pad == 2){
/// bepaal extra kenmerken van de groep:
foreach ($_SESSION as $key => $value){

if(is_array($value)) { foreach($value as $k => $v){

	if($_SESSION['gekozen_groep'] == $k) {

		$groep_locatie = $_SESSION['groep_locatie'][$k];
		$groep_onderwerp = $_SESSION['groep_onderwerp'][$k];
		$groep_afloop = $_SESSION['groep_afloop'][$k];

		}}}}}

if ($pad == 1){

$groep_locatie = $row_groep['groep_locatie_id'];
$groep_onderwerp = $row_groep['groep_name'];
$groep_afloop = $row_groep['groep_tijdstip'];
} 

 

 

 

<select name="selecteerGroep" id="selecteerGroep" size ="<?php ($pad == 2) ? $aantal_groepen : '1' ?>" />
	 <?php while ($row = mysql_fetch_assoc($rs)) { 

	 echo '<option value="'.$row['groep_id'].'">'.$row['groep_name'].'</option>';

	 }  ?>     
        </select>

.

 

 

So what am i trying to do:

 

-one can create an examination

-one can create several groups that belong to an examination

- one can add respondants to an examination

 

Either the admin create and add respondants in an sequencial way :: 1) create examination 2) create group(s) 3) add respondants..  --> parameters are passed via $_SESSION.

 

OR the admin selects an examination from the list and adds people --> parameters are passed via querystring.

 

The above code with the selector echoes either the groups created with the sequencial way or it echoes the group (only one) passed via the querystring. 

 

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.