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

Saving PHP output as a file
I wondered if anyone knows how to save the rendered output of a PHP script as a file?

I have

Load Animated Image while cache is serve
I have a page that loads up using cache and took about 1 to 2 minutes before it loads to the page. <

what are '%S%', '%E%'
for example when i see Code: [Select]printf("Hello %srn", $name);
what does %s means

DBCA Templates
Hi all,

I'm working on creating a template for DBCA, but can't find any documentation on the

How to sum these output values
Hi

I need sum the month totals
SELECT region_name, area_name ,SUM (CASE WHEN S

PHP hyperlinks generator
Hi

I need some help to get this done using php:


1 - I have few hyperlinks say 500

How do I replace any number of character occurences with one occurrence?
How do I replace any number of character occurences with one occurrence?

Let's say I have:

Linking with Foreign Keys
I have been getting an erro when I try and link:

create table Faculty_Specialty (I_Name v

Files in current folder. Should be an easy fix.
Never mind. I've asked about this before and just found my answer. Anyway to delete this?

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

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