Hi,

I don't know if you're really new or not, but I am.  I have successfully
created 2 basic forms: 1 is to add data to the database and the other is to
retrieve. Look at my code and see if any of the functions or code give you a
hint of what you need.

grant

HOW TO ADD DATA TO DATABASE.
<?php
@mysql_pconnect
("mysql35.secureserver.net", "username","password" )
or die("My very first custom error message!");
mysql_select_db("sellerlistings" ); ?></p>

<form action="entryform.php" method="post">
<p>

HousesID:
<input type="text" name="housesID" size="20" maxlength="40" value="" />
</p>

<p>
Bedrooms:<input type="text" name="bedrooms" size= "20" maxlength="40" value=
"" />
</p>

<p>
Floors: <input type="text" name="floors" size= "20" maxlength="40" value=""/>
</p>

<p>
Baths:
<input type="text" name="baths" size= "20" maxlength="40" value="" />
</p>

<p>
Fireplaces: <input type="text" name="fireplaces" size= "20" maxlength="40"value=
"" />
</p>

<p>
Squarefeet: <input type="text" name="squarefeet" size= "20" maxlength="40"value=
"" />
</p>

<p>
Price:
<input type="text" name="price" size= "20" maxlength="40" value="" />
</p>

<p>
Yearbuilt:
<input type="text" name="yearbuilt" size= "20" maxlength="40" value="" />
</p>

<p>
picture:
<input type="text" name="picture" size= "20" maxlength="40" value="" />

</p>
<input type="submit" name="submit" value="Go!"

$housesID=$_POST['housesID'];
$bedrooms=$_POST['bedrooms'];
$floors=$_POST['floors'];
$baths=$_POST['baths'];
$fireplaces=$_POST['fireplaces'];
$squarefeet=$_POST['squarefeet'];
$price=$_POST['price'];
$yearbuilt=$_POST['yearbuilt'];
$picture=$_POST['picture'];
/>

<?php

if (isset($_POST['submit']))

{

echo "<br />";

echo "House ID: ".$_POST['housesID']."<br />" ;
echo "Bedrooms ".$_POST['bedrooms']." <BR />" ;
echo "Floors " .$_POST['floors']." <BR />" ;
echo "Baths ".$_POST['baths'] ." <BR />";
echo "Fireplaces ".$_POST['fireplaces' ]." <BR />";
echo "Squarefeet ".$_POST['squarefeet' ]." <BR />";
echo "Price ".$_POST ['price']." <BR />";
echo "Year Built " .$_POST['yearbuilt']." <BR />";

$query= "INSERT INTO tblhouses set HousesID='$housesID'
,Bedrooms='$bedrooms',
Floors='$Floors', Baths='$baths' , fireplaces='$fireplaces' ,
SquareFeet='$squarefeet' , Price='$price' , YearBuilt='$yearbuilt',
Picture='$picture'" ;

$result = mysql_query($query);
echo "Hey, dude...you're stuff has been added!". " <BR />" ;

}

?>

<!................END OF PHP.........><!>

 </form>
HOW TO RETRIEVE DATA FROM DATABASE

$link1= @mysql_pconnect("mysql40.secureserver.net", "username","password");
mysql_select_db("sellerlistings");

$query= SELECT housesID, bedrooms, floors, baths, fireplaces, ,squarefeet,
price, yearbuilt, picture FROM tblhouses";

$result = mysql_query($query);

for ($count=0; $count < mysql_numrows($result); $count++)
{
$housesID = mysql_result($result, $count, "housesID");
$bedrooms = mysql_result($result, $count, "bedrooms");
$floors = mysql_result($result, $count, "floors");
$baths = mysql_result($result, $count, "baths");
$fireplaces = mysql_result($result, $count, "fireplaces");
$squarefeet = mysql_result($result, $count, "squarefeet");
$price = mysql_result($result, $count, "price");
$yearbuilt = mysql_result($result, $count, "yearbuilt");
$picture = mysql_result($result, $count, "picture");
$fullpicture = "http://www.ricotierrarealty.com/images/"; . $picture;

echo "HouseID ($housesID) ";
echo "Bedrooms: $bedrooms ";
echo "Floors: $floors ";
echo "Baths: $baths ";
echo "Fireplaces: $fireplaces ";
echo "Squarefeet: $squarefeet ";
echo "Price: $price ";
echo "Yearbuilt: $yearbuilt ";
echo "Picture: $fullpicture ";
echo "<br />";
echo "<br />";
echo "<p> </p>";

}
 ?>


[Non-text portions of this message have been removed]



The php_mysql group is dedicated to learn more about the PHP/MySQL web database 
possibilities through group learning.  
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/php_mysql/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to