Displaying Data From Mysql Tables

Started on the old forum in July 2008 · view the original in the archive · old links redirect here

6 replies · 618 views · started 18 years ago · 1 min read

2 participants
Guest #1

this is the first time iam ever working with mysql and ive tried many tutorilas online but,they r too complicated for me to nderstand since its my first time ive a table named "mytable" with "id" "name" "dob"

i just want to echo all of them in an order for ex: name=xyz dob=x/y/z

name=abc dob=a/b/s....................

..........n

i ve already made a file foe coonecting that is" sqlconect.php'

Anshul Senior · 296 posts #2

maybe it will be like this

$get_data_query = @mysql_query("SELECT `id`, `name`,`dob` FROM `mytable` ORDER BY id ASC limit 20;");
while ($get_data_query_result=mysql_fetch_array($get_data_query)){
++$i; print "[b]$i.[/b]Name: $get_data_query_result[1]
 DOB: $get_data_query_result[2]}
Guest #3

iam getting this error

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/evnixcom/public_html/wap/q23w/4rtt/q23w/data/trial.php on line 6

Guest #4

ok i got it right !! some small error on my side thnks!!

Guest #5

u need to connect to your database

$dbhost="";
$dbuser="";
$dbpass="";
$dbname="";
mysql_connect("$dbhost","$dbuser","$dbpass") or die(mysql_error()); 
mysql_select_db("$dbname") or die(mysql_error());

may be this code will help

SpiderWap Lead · 622 posts #6

To get a single thing out database:

$query=mysql_query("SELECT * FROM table");
$resault=mysql_fetch_array($query);
echo "Name: ".$resault[name]."
\n";
echo "Surname: ".$resault[surname]."
\n";
echo "Number: ".$resault[number]."
\n";
echo "Info: ".$resault[info]."
\n";

You saw at the top i said SELECT * FROM table what the * means, select everything from table, then just to make it easier i said [name] [number] and [info] (the name of the collems) or you could use LIMIT 0,2 and use $rasault[0] $resault[1] $resault[2]...

Hope this was usefull.

Guest #7

yes indeed it was helpfull,thnks spidey!!!

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close