PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I'm new to php,and i met some problem when displaying item from database. When user log in, i can retrieve and display username from database in page, but it failed to display when I try to retrieve and display relevant item related to the user at the same page...anyone can help???
/*1st: CAN NOT display item when assigned lecID=$id, which retrieve from input(log in)*/
<?php
include 'Connections/myconnection.php';
mysql_select_db($database_myconnection, $myconnection)
or die("Unable to connect to MySQL");
$query = "SELECT subCode FROM lecturer WHERE lecID=$id LIMIT 1";
$result = mysql_query($query);
/*2nd: CAN display when assigned lecID=1133, which specified the user ID*/
<?php
include 'Connections/myconnection.php';
mysql_select_db($database_myconnection, $myconnection)
or die("Unable to connect to MySQL");
$query = "SELECT subCode FROM lecturer WHERE lecID=1133 LIMIT 1";
$result = mysql_query($query);
while($row = mysql_fetch_assoc($result)) {
echo "{$row['subCode']}<br>" ;
}
?>
$id = $_POST['userid']; but it was at another php file,as shown below. I tried to include the file inside,and it comes out with error...anyone can help???
<?php
session_start();
include 'Connections/myconnection.php';
mysql_select_db($database_myconnection, $myconnection)
or die("Unable to connect to MySQL");
$result = mysql_query("SELECT Name FROM lecturer WHERE lecID='$id' and password='$password'")
or die(mysql_error());
if($data = mysql_fetch_object($result)){