mysql-select-db

Can you reuse a mysql result set in PHP?

浪尽此生 提交于 2019-12-18 16:26:31
问题 I have a result set I pull from a large database: $result = mysql_query($sql); I loop through this recordset once to pull specific bits of data and get averages using while($row = mysql_fetch_array($result)) . Later in the page, I want to loop through this same recordset again and output everything - but because I used the recordset earlier, my second loop returns nothing. I finally hacked around this by looping through a second identical recordset ( $result2 = mysql_query($sql); ), but I

how pass dynamic parameter in mysql view

好久不见. 提交于 2019-12-07 01:52:19
问题 I have created this in mysql CREATE VIEW MYVIEW AS ( SELECT A.FNAME , A.LNAME , B.EMAIL FROM EMPLOYEE A, EMPEMAIL B WHERE A.EID = :empId AND A.EID = B.EID AND B.EMAILTYP = :emailType) now i want make " empId " and " emailType " dynamic.I mean pass the value at select time. what need to change in code?? thanx in advance 回答1: Just create the view without the parameters (i.e., to take care of the join only): CREATE VIEW MYVIEW AS ( SELECT A.FNAME , A.LNAME , B.EMAIL , A.EID AS EID -- added to be

how pass dynamic parameter in mysql view

霸气de小男生 提交于 2019-12-05 06:49:59
I have created this in mysql CREATE VIEW MYVIEW AS ( SELECT A.FNAME , A.LNAME , B.EMAIL FROM EMPLOYEE A, EMPEMAIL B WHERE A.EID = :empId AND A.EID = B.EID AND B.EMAILTYP = :emailType) now i want make " empId " and " emailType " dynamic.I mean pass the value at select time. what need to change in code?? thanx in advance Just create the view without the parameters (i.e., to take care of the join only): CREATE VIEW MYVIEW AS ( SELECT A.FNAME , A.LNAME , B.EMAIL , A.EID AS EID -- added to be used in the WHERE , B.EMAILTYP AS EMAILTYP -- added to be used in the WHERE FROM EMPLOYEE A, EMPEMAIL B

How to insert data in two different tables of two different database in php

▼魔方 西西 提交于 2019-12-04 04:28:19
问题 I have to insert data in two different database's table. I have created database1 and table1 for database1, also i have created database2 and table2 for database2. For inserting data i have written code, $connect = mysql_connect("localhost","root",""); //database connection mysql_select_db("database1",$connect); // select database1 mysql_select_db("database2",$connect); // select database2 $sql = mysql_query("INSERT INTO database1.table1 (contact_first, contact_last, contact_email) VALUES(

Can you reuse a mysql result set in PHP?

不想你离开。 提交于 2019-11-30 14:06:27
I have a result set I pull from a large database: $result = mysql_query($sql); I loop through this recordset once to pull specific bits of data and get averages using while($row = mysql_fetch_array($result)) . Later in the page, I want to loop through this same recordset again and output everything - but because I used the recordset earlier, my second loop returns nothing. I finally hacked around this by looping through a second identical recordset ( $result2 = mysql_query($sql); ), but I hate to make the same SQL call twice. Any way I can loop through the same dataset multiple times? Use: