Jump to content

Cant View Mysql Data into php


eyeore

Recommended Posts

Hello im new to php and i cant seems to view my database in my php 

	<?php
										include('../connect.php');
										$sds=$_SESSION['SESS_FIRST_NAME'];
										$result = mysql_query("SELECT * FROM paymentdetails WHERE idnumber='$sds'");
										while($row = mysql_fetch_array($result))
											{
												echo '<tr class="record">';
												echo '<td style="border-left: 1px solid #C1DAD7"><div align="left">'.$row['date'].'</div></td>';
												echo '<td><div align="left">'.$row['amount'].'</div></td>';
												echo '</tr>';
											}
										?> 
									</tbody>
								</table>

Here my database  im really confuse on what to do

 

CREATE TABLE IF NOT EXISTS `paymentdetails` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `idnumber` varchar(30) NOT NULL,
  `date` varchar(30) NOT NULL,
  `amount` varchar(30) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;

--
-- Dumping data for table `paymentdetails`
--

INSERT INTO `paymentdetails` (`id`, `idnumber`, `date`, `amount`) VALUES
(1, 'SID-YWU49JU', '2014-08-07', '50000');
Link to comment
https://forums.phpfreaks.com/topic/290329-cant-view-mysql-data-into-php/
Share on other sites

 

 

m really confuse on what to do

You need to debug your script.

 

Have you checked to make sure the $_SESSION['SESS_FIRST_NAME']; variable contains the expected value to be used in your query? Checked that your query has not returned any errors? Have you enabled PHP error reporting?

Try,

<?php
ini_set('display_startup_errors', 1);

ini_set('display_errors', 1);

error_reporting(-1);

include('../connect.php');
$id = $_SESSION['SESS_MEMBER_ID'];
$result = mysql_query("SELECT * FROM student WHERE id='$id'") or die(mysql_error());
while ($row = mysql_fetch_array($result)) {
    echo '<tr class="record">';
    echo '<td style="border-left: 1px solid #C1DAD7"><div align="left">' . $row['date'] . '</div></td>';
    echo '<td><div align="left">' . $row['amount'] . '</div></td>';
    echo '</tr>';
}
?>

Why the columns idnumber, date and amount are varchar's type? Where do you start a session in your application?

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.