localhost Posted June 17, 2006 Share Posted June 17, 2006 contact form into admin panel, it does insert it into the database i checked in phpmyadmin, just cant get it to select, it echos $id instead of the actual id, and $name instead of the actual name, some help?[code]<?php/* ******** INCLUDE DB CONNECTION AND SET VARIABLES ******** */include('../includes/connect.php');$date = date('m/d/Y');/* ******** SELECT DATA TO DISPLAY MESSAGES FROM TODAY ******** */$query = "SELECT * FROM `contact` WHERE `sentdate` = '$date' ORDER BY id DESC";$result = mysql_query($query) or die('Could not select messages from today');while ($rows = mysql_fetch_array($result, MYSQL_ASSOC)) {/* ******** SELECT ROWS AND SET THEM AS VARIABLES FOR LATER USE ******** */$id = $rows['id'];$name = $rows['name'];$email = $rows['email'];$subject = $rows['subject'];$message = $rows['messages'];$ipaddress = $rows['ipaddress'];}/* ******** DISPLAY THE DATA SELECTED IN A PROPER MANNER ******** */echo 'Messages sent to you today, $date<br>Message ID number $id<Br>Claimed to be from: $name<BR>Acclaimed eMail: $email<BR>Subject: $subject<Br>Message:<Br>$message<Br>Users Logged IP: <a href=http://$ipaddress>$ipaddress</a><Br>______________________________________________<Br><Br>';/* ******** SELECT DATA TO DISPLAY MESSAGES RECEIVED IN TOTAL ******** */$query2 = "SELECT * FROM `contact` ORDER BY id DESC";$result2 = mysql_query($query2) or die('Could not select total messages from database');/* ******** DISPLAY THE DATA SELECTED IN A PROPER MANNER ******** */echo 'Total Messages Sent<br>Message ID number $id<Br>Claimed to be from: $name<Br>Acclaimed eMail: $email<Br>Subject: $subject<Br>Message:<br>$message<Br>Users Logged IP: <A href=http://$ipaddress>$ipaddress</a><br>______________________________________________<br><Br>';?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/12224-not-displaying-info-from-database/ Share on other sites More sharing options...
joquius Posted June 17, 2006 Share Posted June 17, 2006 because on each while() loop you're replacing the data, why is the echo outside the loop?"/* ******** SELECT ROWS AND SET THEM AS VARIABLES FOR LATER USE ******** */"You\re just overwriting the variables Quote Link to comment https://forums.phpfreaks.com/topic/12224-not-displaying-info-from-database/#findComment-46603 Share on other sites More sharing options...
localhost Posted June 17, 2006 Author Share Posted June 17, 2006 so i took out the comment...but what else should be in the loop? Quote Link to comment https://forums.phpfreaks.com/topic/12224-not-displaying-info-from-database/#findComment-46650 Share on other sites More sharing options...
localhost Posted June 17, 2006 Author Share Posted June 17, 2006 so i took out the comment...but what else should be in the loop?current updatec code:[code]<?php/*======================================================================*\|| #################################################################### |||| # .Omega Community System 2006 version 0.6 # |||| # ---------------------------------------------------------------- # |||| # Copyright ©2006 dotOmega # |||| # This file may not be redistributed in whole or significant part. # |||| # ---------------- DOTOMEGA IS NOT FREE SOFTWARE ----------------- # |||| # http://dotomega.com | http://licence.dotomega.com # |||| #################################################################### ||\*======================================================================*//* ******** INCLUDE DB CONNECTION AND SET VARIABLES ******** */include('../includes/connect.php');$date = date('m/d/Y');/* ******** SELECT DATA TO DISPLAY MESSAGES FROM TODAY ******** */$query = "SELECT * FROM `contact` WHERE `sentdate` = '$date' ORDER BY id DESC";$result = mysql_query($query) or die('Could not select messages from today');while ($rows = mysql_fetch_array($result, MYSQL_ASSOC)) {$id = $rows['id'];$name = $rows['name'];$email = $rows['email'];$subject = $rows['subject'];$message = $rows['messages'];$ipaddress = $rows['ipaddress'];print "Messages sent to you today, $date<br>";/* ******** IN THE CASE THAT NO MESSAGES WERE SENT TODAY ******** */$numrows = mysql_num_rows($result);if($numrows<1) {echo ' No Messages received today ';} else {/* ******** DISPLAY THE DATA SELECTED IN A PROPER MANNER ******** */echo 'Message ID number $id<Br>Claimed to be from: $name<BR>Acclaimed eMail: $email<BR>Subject: $subject<Br>Message:<Br>$message<Br>Users Logged IP: <a href=http://$ipaddress>$ipaddress</a><Br><Br><Br>';print "_________________________________________________________________<Br>Total Messages Sent<br>";/* ******** SELECT DATA TO DISPLAY MESSAGES RECEIVED IN TOTAL ******** */$query2 = "SELECT * FROM `contact` ORDER BY id DESC";$result2 = mysql_query($query2) or die('Could not select total messages from database');/* ******** DISPLAY THE DATA SELECTED IN A PROPER MANNER ******** */echo 'Message ID number $id<Br>Claimed to be from: $name<Br>Acclaimed eMail: $email<Br>Subject: $subject<Br>Message:<br>$message<Br>Users Logged IP: <A href=http://$ipaddress>$ipaddress</a><br>______________________________________________<br><Br>';/* ******** END ALL IF STATEMENTS AND FINISH THE SCRIPT ******** */}}?>[/code]so i took out the comment...but what else should be in the loop? Quote Link to comment https://forums.phpfreaks.com/topic/12224-not-displaying-info-from-database/#findComment-46654 Share on other sites More sharing options...
aebstract Posted June 17, 2006 Share Posted June 17, 2006 when you echo variables, remember theres two ways to echo.. as far as I knowecho '';andecho "";the difference in the quotation marks.Single quotes will enter a whatever is in them exactly how it is seen, leaving your variable as $id and whatnot. If you use double quotes, it puts it in as the actual id and not $id.Edit: to clarify sorry,Single Quotes: Treated LiterallyDouble Quotes: Extrapolated - a variable's name is replaced with its value. Quote Link to comment https://forums.phpfreaks.com/topic/12224-not-displaying-info-from-database/#findComment-46660 Share on other sites More sharing options...
localhost Posted June 17, 2006 Author Share Posted June 17, 2006 so i took out the comment...but what else should be in the loop?so i took out the comment...but what else should be in the loop? Quote Link to comment https://forums.phpfreaks.com/topic/12224-not-displaying-info-from-database/#findComment-46662 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.