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

for some reason mysql query not working, not inserting, please check it out
This code is not inserting anything into my db, don't know why, the $_SESSION variable does contain

problem with script manager
Hi iam using Net.2005.I have created ajax enabledwebsite.i have master page in which i have script m

PHP Thumbnail Creation
Ok so i use this function to create thumbnails:

Code: [Select]function createthumb($name,$fil

reating a background image
I am building a site in drupal and have a php form in it, due to certain annoyances with module buil

Best way to check for end of a record and send it back to the first record
I'm hoping someone can help me out and explain the best way to accomplish this.

What I'm doin

SQl num_rows problem
when i try to count rows from an SQL select i get an warning

Code: [Select]$countviews = mysq

FROM_UNIXTIME($phpdate);
Hello,

I tried to use this :

$date = FROM_UNIXTIME($phpdate);

ANd I was t

Need help in Generating Combinations
Need help generating all possible combination of names in an array

Lets say i have the follow

Google Map
I have done Google Map Integration for one my project. But for that we need the "latitude and l

Help building / using array
First - this is a cross-posting, if this is wrong I apologise! What started out as a MySQL query que

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