Forum Moderators: coopster
______________________________________________________
<?php
$conn = mysql_connect("localhost","","");
mysql_select_db("models",$conn);
$person = $_POST['sex'];
$myage = $_POST['dob'];
$myheight = $_POST['size'];
$resultID = mysql_query("SELECT * FROM $person WHERE age in ($myage) and height in ($myheight) ",$conn);
print "<table border = .25><tr><th>id</th>";
print "<th>name_first</th><th>name_last</th>";
print "<th>age</th><th>height</th><th>weight</th>";
while ($row = mysql_fetch_row($resultID))
{
print "<tr>";
foreach ($row as $field)
{
print "<td>$field</td>";
}
print "</tr>";
}
print "</table>";
mysql_close($conn);
?>
Then;
$path = "yoursite.com/images/";
echo "<img src=\"{$path}{$img}\">";
See where i'm going? Now to output it you'd have to do this:
$result = mysql_query("SELECT * FROM table");
While ( $r = MySQL_fetch_array($result) ) {
$img = $r['table_img'];
echo "<img src=\"{$path}{$img}\">";
}
mysql_fetch_array(): supplied argument is not a valid MySQL result resource in
THIS IS MY SCRIPT
<?php
$conn=mysql_connect("localhost","","");
mysql_select_db("models",$conn);
# Variable path to images
$path = "Inetpub\wwwroot";
// The Query
$result = mysql_query("SELECT * FROM pick");
While ( $r = MySQL_fetch_array($result) ) {
$img = $r['table_img'];
echo "<img src=\"{$path}{$img}\">";
}
?>
$result = mysql_query("SELECT * FROM pick");
isn't working. It is more than likely returning an error. Try to get the error like so
$result = mysql_query("SELECT * FROM pick") or die (mysql_error());
if your query errors out that will return the actual error from mysql and display it to the screen and kill the script. It helps when trying to debug queries.
Undefined index: table_img in c:\inetpub\wwwroot\picture_output.php on line 17
THE SCRIPT I AM USING IS BELOW
By the way how should the column for the picture be setup as **********VARCHAR TEXT BLOB **********
Does it matter?
<?php
$conn=mysql_connect("localhost","","");
mysql_select_db("mytest",$conn);
# Variable path to images
$path = "Inetpub\wwwroot";
// The Query
$result = mysql_query("SELECT * FROM my_kids")or die(mysql_error());
While ( $r = MySQL_fetch_array($result) ) {
$img = $r['table_img'];
echo "<img src=\"{$path}{$img}\">";
}
?>
$result = mysql_query("SELECT * FROM my_kids")or die(mysql_error());
if (mysql_num_rows [php.net]($result) == 0) {
print "the table is empty!";
} else {
While ( $r = MySQL_fetch_array($result) ) {
...
Store your images in sperate folders and store folder_name and file_name in your DB.