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

insert PHP code into function
Hi,
I'm having problems when trying following:

I have:
Code: [Select]createBar("Do

Phase Error I can't seem to find :(`
Hey guys, I can seem to find my phase error on this. I am getting this error

[error]
Pars

how to remove in php string display
My code is $message="We're looking at developing our website."; $body= "My mess

I think i'm using the syntax incorrectly
Hi Everyone!

I'm new to this forum and a newbie with PHP - I'm glad I found this site - I hop

Calling strings from other php class
I have test1.php{
$string1;
$string2;
....
... //10 strings in this class <

records between 2 dates
Hello all,

I have a date tracked table which contains effective_start_date and effective

Passing Arguments to execlp()
I'm writing a program that mimics a unix shell. It's supposed to take commands with arguments and ex

C - Reading a file into a byte array
Hi,

I'm trying to read a file into a byte array in C. I have to use C as this is for a loadru

question about stripslashes and real_escape_string
im cleaning up an old app that I wrote fixing some of the vulernabilities from attacks.

I hav

building a function with multiple outputs
I want to build a function that has multiple outputs.

I know but am not to sure how I should

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