Php And Mysql Help, (Reading Data From A Table)?

chrisopher

New member
hello,


I am having a question, that i keep stumbling on,
i cant quite comprehend the manuals that i have looked at...
I Am a newb at this, and any help is extremely appreciated .

i Am trying to read data from a table.
This Is the current script i am using.

<?php
include ("sql.php");
$con = mysql_connect("$host","$user","$password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

mysql_select_db("unit1", $con);

$result = mysql_query("SELECT * FROM data1");

while($row = mysql_fetch_array($result))
{
$lookup1 = $row['varch'];
}

mysql_close($con);
?>

my problem is:

every time i need to retreive another variable for my script from my database, i have to put it in a new table, ( Because i cant seem to get the following script to work )

<?php
include ("sql.php");
$con = mysql_connect("$host","$user","$password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

mysql_select_db("unit1", $con);

$result = mysql_query("SELECT * FROM 'data1' WHERE id = '1'");

while($row = mysql_fetch_array($result))
{
$lookup1 = $row['varch'];
}

mysql_close($con);
?>

Once Again, Thanks For All Of your help in advance,

If There is anything i need to change in my script, please say so...



THANKS,
 
Back
Top