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 Like 39 Dislike
Previous forums Next forums
Other forums

having a small php error tha deals with the 'foreach'
Last night i was working on a script for a cart and it seemed to working good, until this morning. F

PHP Display Telephone Number On Referrer
I have used the php below to show a different telephone number in the header of the site depending u

Redistributing dependent dlls
Hai all ,

I have created an application in VC++ using VS2008 in a development machine which r

remove trailing slash from array
I have the following array which contains trailing slashes I need to remove. What is the best way to

Header is not working in IE
Hi ! header function is not working in IE but it works in FF, Safari, Chrome. any help please. :

Best way to read this text file.
Hi.I am planning to make a small application in C# to convert the players from Football manager 2010

need help with this contact form
I made this form and I need it to read the data and write the data to a table and its not working ca

disable all input buttons
Hello Friends,

suppose i do have a file ( file.php ) has a submit button

Code: [Sele

Checking if multidimensional array is empty?
I have a for with multiple test input fields. Specifically the user submits multiple names and ages

How to get variable value on next page
Hello friends
i am working on payentry page ..there i have this code.........

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash