Storing Values taken from a DB...
Posted on
16th Feb 2014 07:03 pm by
admin
Using this code it will generate a short list from my database
<?php
mysql_connect('localhost','root','');
mysql_select_db("clients");
$fname = $_POST['firstname'];
$SQL = "SELECT * FROM members WHERE firstname = '$fname'";
$result = mysql_query($SQL);
while ($db_field = mysql_fetch_assoc($result)) {
print $db_field['firstname'] . "<BR>";
print $db_field['lastname'] . "<BR>";
print $db_field['email'] . "<BR>";
print $db_field['date'] . "<BR>";
echo $db_field['firstname'];
}
?>
but I need to be able to use the values its pulled out later down in the page.
if I try to use echo $db_field['firstname']; somewhere else on my page it just leaves a blank spot...
I tried doing this:
<?php
mysql_connect('localhost','root','');
mysql_select_db("clients");
$fname = $_POST['firstname'];
$SQL = "SELECT * FROM members WHERE firstname = '$fname'";
$result = mysql_query($SQL);
while ($db_field = mysql_fetch_assoc($result)) {
$name = print $db_field['firstname'] . "<BR>";
$lname = print $db_field['lastname'] . "<BR>";
$mail = print $db_field['email'] . "<BR>";
$day = print $db_field['date'] . "<BR>";
echo $db_field['firstname'];
}
?>
and then using echo $thevariable i wanted but that didnt work either...
thanks
No comments posted yet
Your Answer:
Login to answer
165
39
Other forums
how to populate a drop down box
Hi buddies!
PROCEDURE DOWNLOAD_REPORT_FORM (report_name varchar)
is
begin
DOWNLO
Header redirect
Hello ive got a problem ive got form with its action set to itself.
Code: <form id="f
Do not allow posting of whitespace
Currently the script below works if the user does not type a name/message, but if i create a whitesp
Check Date/Time in PHP
What I need the code to check is that $reQuest is 24 hours in the past then return a time based on h
upload form file types....
Hey all, I am learning PHP and I am writing a script from the W3C Schools tutorials for uploading fi
PHP4 to PHP5 Conversion
Hi Everyone,
I am working on a site that is built up on PHP4 and each page is being started f
PHP error on MySQL insert
I'm sure it's the simplest of issues, but I can't recall why this isn't working.
Code: [Selec
value not going in data base
hello friends....
i am having a working javascript....when i am selecting any
MVC - Code review
I'm in the process of trying to wrap my head around MVC, and as part of that, I'm attempting to impl
Show message after entering data
Hello Colleagues
I would like to display messages after entering the data example: "
dat