MySQL Forums
Forum List  »  PHP

Insert returned values in another table.
Posted by: Onkar Shinde
Date: March 19, 2015 08:18AM

Hi,

I am selecting 5 rows at random from a table.

$query = "SELECT stdid, name FROM students order by rand(UNIX_TIMESTAMP()) limit 5"

$myquery =   mysqli_query($db_connect, $query);
	while($students = mysqli_fetch_assoc($myquery)){
		$stdid =$students['stdid']; $name = $students['name']; $dept = $students['dept'];
		echo "<br><br>".$stdid."<br>".$name."<br>".$dept;

//NOT SURE IF I ADD INSERT HERE		
	}

I want to INSERT the displayed 'stdid' into another table.

Do i need to add the INSERT in the WHILE loop ? Is there another way to go about this ?

Many thanks.

Options: ReplyQuote


Subject
Written By
Posted
Insert returned values in another table.
March 19, 2015 08:18AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.