homepage Welcome to WebmasterWorld Guest from 54.145.183.169
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / Databases
Forum Library, Charter, Moderator: open

Databases Forum

    
Mysql Query, Displaying Stored Data
dico

5+ Year Member



 
Msg#: 4411957 posted 10:23 pm on Jan 28, 2012 (gmt 0)

hi guys, i need help in making this scrip work.. i want individual registered user on the portal to be able to view their information anytime they want. am having issue fetching the data from the data base.
The script is like this;

<?php
session_start();
if(!isset($_SESSION['user'])){
header("Location: index.php");
exit;
}
if(!file_exists("confunc.inc.php")){
die("No such include file. Check filename properly");
}

include("confunc.inc.php");

$message = array();
// check if message array is empty then open database
@$conn = db_connect(HOST, USER, PWD, DB);
if(!$conn){
die("<h2><font color='red'>can't connect to server. try again or ask administrator</font></h2>");
}
else{
// connection successful
$sql = "select * from ef_tb where ";
$sql .= "email='" . $_SESSION['e'] . "' and phone='" .$_SESSION['p'] . "'";
@$result = mysql_query($sql, $conn);

if(!$result){
die("<h2><font color='red'>can't perform database operation. try again or ask administrator</font></h2>");
}
else{
$status = 1;
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dth">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="css/style.css" media="screen" type="text/css" />
<style type="text/css">
<!--
.style1 {
color: #006600
}
.wid{
position: 50%;
size: 50%;
}
body {
margin: 0;
padding: 0;
}
.style2 {font-size: 36px}
-->
</style>
<title>View Information</title>
<script type="text/javascript">
function sname(musc){
if(musc=="all")
{
location.href="view_page.php";
}else{
location.href="view_page.php?name="+musc;
}
}
</script>
</head>

<body>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#00FF33">
<tr>
<td bgcolor="#FFFFFF"><div align="center"><img alt="" class="form-image" border="0" src="http://www.jotform.com/uploads/Duncanjo/form_files/Students_bursary_butt.jpg" height="81.9" width="630"></div>
</div></td>
</tr>
</table>
<span>
<center>
<a href="logout.php">Logout</a> | <a href="form.php">Register Member</a>
</center>
</span>
<table width="70%" border="0" align="center" cellpadding="0" cellspacing="4" bgcolor="#FFFFFF">
<caption>
<strong>Member Information</strong>
</caption>
<tr>
<th colspan="2"><table width="100%" border="0" align="center">
<tr>
<td width="488" bgcolor="#FFFFCC"><div align="center"> <div align="center">Overall Info.
</div></td>
<td width="122" height="90" bgcolor="#FFFFFF">
<?php
if(isset($stat)){
$count = 1;
while($row = mysql_fetch_array($result)){
?>
<?php
$directory = '../upload/thumbs/';
$imagePix = $row["images"];
$sepPix = explode(".", $imagePix);
$imagePix = $sepPix[0] . "_thb" . "." . $sepPix[1];
$imageP = $directory . $imagePix;
?>
<p>
<?php
if(isset($imageP)) {
echo "<img src='" . $imageP. "' /> </br>";
}
?>
</p></td>
</tr>
</table>
</tr>
<tr><?php echo $count; ?>
<td bgcolor="#FFFFFF"><strong>Name</strong></td>
<td bgcolor="#FFFFFF"><?php echo htmlspecialchars(ucfirst($row["name"])); ?></td>
</tr>
<tr>
<td bgcolor="#FFFFCC"><strong>Contact Address</strong></td>
<td bgcolor="#FFFFCC"><?php echo htmlspecialchars(ucfirst($row["caddress"])); ?></td>
</tr>
<tr>
<td bgcolor="#FFFFFF"><strong>City Address</strong></td>
<td bgcolor="#FFFFFF"><?php echo htmlspecialchars(ucfirst($row["cityaddress"])); ?></td>
</tr>
<tr>
<td bgcolor="#FFFFCC"><strong>Village of Origin</strong></td>
<td bgcolor="#FFFFCC"><?php echo htmlspecialchars(ucfirst($row["viladdress"])); ?></td>
</tr>
<tr>
<td bgcolor="#FFFFFF"><strong>Ward</strong></td>
<td bgcolor="#FFFFFF"><?php echo htmlspecialchars(ucfirst($row["wdaddress"])); ?></td>
</tr>
<tr>
<td bgcolor="#FFFFCC"><strong>LGA</strong></td>
<td bgcolor="#FFFFCC"><?php echo htmlspecialchars(ucfirst($row["lga"])); ?></td>
</tr>
<tr>
<td bgcolor="#FFFFFF"><strong>GSM Number</strong></td>
<td bgcolor="#FFFFFF"><?php echo htmlspecialchars(strtoupper($row["phone"])); ?></td>
</tr>
<tr>
<td bgcolor="#FFFFCC"><strong>Email</strong></td>
<td bgcolor="#FFFFCC"><?php echo htmlspecialchars(strtolower($row["email"])); ?></td>
</tr>
<tr>
<tr>
<td bgcolor="#FFFFFF"><strong>Name of Institution</strong></td>
<td bgcolor="#FFFFFF"><?php echo htmlspecialchars(strtoupper($row["n_school"])); ?></td>
</tr>
<tr>
<td bgcolor="#FFFFCC"><strong>Telophone Number</strong></td>
<td bgcolor="#FFFFCC"><?php echo htmlspecialchars(strtoupper($row["tphone"])); ?></td>
</tr>
<tr>
<td bgcolor="#FFFFFF"><strong>Gender</strong></td>
<td bgcolor="#FFFFFF"><?php echo htmlspecialchars(strtolower($row["sex"])); ?> </td>
</tr>
<tr>
<td bgcolor="#FFFFCC"><strong>Marital Status</strong></td>
<td bgcolor="#FFFFCC"><?php echo htmlspecialchars(strtolower($row["marital"])); ?></td>
</tr>
<tr>
<td bgcolor="#FFFFFF"><strong>Father/Guardian Name</strong></td>
<td bgcolor="#FFFFFF"><?php echo htmlspecialchars(strtoupper($row["father"])); ?></td>
</tr>
<tr>
<td bgcolor="#FFFFCC"><strong>Date of Birth</strong></td>
<td bgcolor="#FFFFCC">month:<?php echo htmlspecialchars(strtolower($row["month"])); ?> | Day:
<?php echo htmlspecialchars(strtolower($row["day"])); ?> | Year:
<?php echo htmlspecialchars(strtolower($row["year"])); ?> </td>
</tr>
<tr>
<td bgcolor="#FFFFFF"><strong>Parent/Guardian Occupation</strong></td>
<td bgcolor="#FFFFFF"><?php echo htmlspecialchars(strtoupper($row["parent"])); ?></td>
</tr>
<tr>
<td bgcolor="#FFFFCC"><strong>Department</strong></td>
<td bgcolor="#FFFFCC"><?php echo htmlspecialchars(strtoupper($row["dept"])); ?></td>
</tr>
<tr>
<td bgcolor="#FFFFFF"><strong>Level</strong></td>
<td bgcolor="#FFFFFF"><?php echo htmlspecialchars(strtoupper($row["level"])); ?></td>
</tr>
<tr>
<td bgcolor="#FFFFCC"><strong>Registration Number</strong></td>
<td bordercolor="#FFFFCC" bgcolor="#FFFFFF"><?php echo htmlspecialchars(strtoupper($row["r_num"])); ?></td>
</tr>
<tr>
<td bgcolor="#FFFFFF"><strong>Bank Name</strong></td>
<td bgcolor="#FFFFFF"><?php echo htmlspecialchars(strtoupper($row["bank_name"])); ?></td>
</tr>
<tr>
<td bgcolor="#FFFFCC"><strong>Account Number</strong></td>
<td bgcolor="#FFFFCC"><?php echo htmlspecialchars(strtoupper($row["bank_acc"])); ?></td>
</tr>
<tr bgcolor="#FFFFCC">
<td colspan="2" align="center" bgcolor="#FFCC99"> <input type='button' value='Print' onclick='window.print();return false;' /></td>
</tr>
<?php
$count++;
}
}
?>
<tr bgcolor="#FFFFCC">
<td colspan="25" align="center"> <input type='button' value='Print' onclick='window.print();return false;' /></td>
</tr>
</table>
</tr>
</table>
<table width="180%" border="0" align="left" cellpadding="0" cellspacing="0" bgcolor="#00FF33">
<tr><td colspan="2" align="center" bgcolor="#FFFFFF"><?php include("includes/footer.php"); ?></td>
</tr>
</table>
</body>
</html>


thanks

 

rocknbil

WebmasterWorld Senior Member rocknbil us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 4411957 posted 4:37 pm on Jan 31, 2012 (gmt 0)

am having issue fetching the data from the data base.


This should really be in the PHP forum, but first,

@$result = mysql_query($sql, $conn);

Remove the @. In PHP, this suppresses any errors returned by the function mysql_query (I think, it's usually done here: @mysql_query)

next, temporarily add this:
$sql = "select * from ef_tb where ";
$sql .= "email='" . $_SESSION['e'] . "' and phone='" .$_SESSION['p'] . "'";
echo $sql;
exit;


Then copy and paste it into mysql command line or phpMyAdmin and see if it runs and returns results.

Once that's working, you'll have to read in the values like you're doing but put them into a form:

<p><label for="yourname">Name</label> <input type="text" name="yourname" id="yourname" value="<?php echo htmlspecialchars(ucfirst($row["name"])); ?>"></p>

Then that form should submit to a script in which you use update to update the record by ID.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Databases
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved