我怎么知道用户是否已登录以响应本机并将数据传递给listview + php
我无法将数据从登录的用户传递到react native。
return fetch('https://entregas24.000webhostapp.com/viewData.php')
.then((response) => response.json())
.then((responseJson) => {
let ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2})
this.setState({
isLoading: false,
dataSource: ds.cloneWithRows(responseJson),
}, function() {
});
})
.catch((error) => {
console.error(error);
});
}
viewUsers=(email, firstName, lastName)=>{
this.props.navigation.navigate('Third', {
email : email,
firstName : firstName,
lastName : lastName,
});
}
return (
<ListView
dataSource={this.state.dataSource}
renderSeparator= {this.ListViewItemSeparator}
renderRow={ (rowData) => <Text style={styles.rowViewContainer}
onPress={this.viewUsers.bind(
this,
rowData.email,
rowData.firstName,
rowData.lastName,
)} >
{rowData.email}
</Text> }
/>
</View>
);
}
目前,我什至只是尝试显示数据并进行编辑。 因此,如果有人可以帮助我,我会非常感激。
public function viewUser($email, $firstName, $lastName){
$userData = array();
$result = $this->connect()->prepare( "SELECT email, firstName, lastName FROM `users` ");
$result->execute();
$number_of_rows = $result->fetchColumn();
if($number_of_rows > 0) {
while($row = $result->fetch(PDO::FETCH_OBJ)){
echo $row['email'];
}
}
}