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
Just cannot get 'area' to submit to db using same php code as already used
Basically all i have done is just modified some code and added an area section.
The form is allre
Generate multilayered array from string.
ok so i have a string that looks like this:
Code: [Select]blog:edit_all,delete_all|users:edit_all
for loop without same $i digits?
Hi,
Can some guru please advise how can I accomplish this with a simple for loop ?
I
The page should be expire when cilck back button
hi,
i'm new to php world.
i create user registration page.
when i submit it,data goes to my
Check before inserting in DB ???
This is my code
---------------
if ( $_POST ['Submit'])
{{
$username = $_POST ['usernm
Automatic Webpage ??
I have a page www.mysite.com/test.php with a
<form>
<textarea name=&q
newbie error
what is wrong with this code ?
<html>
<body>
<?
Concatenate two strings ???
I have string one $string1 and another $string2.
How to concatenate (add) both of them $str
question about n
I was looking at some of the things you could do with php and one of the things I have tried is n.<
This must be easy , pulling the last record of the day, every day, from a txt
I have a txt file logging weather data every minutes (so 1 record per minute). I want to extract the