Need help with PHP

Status
Not open for further replies.

chrisgill369

In Runtime
Messages
435
I want to create a dynamic image gallery so i dont have to keep editing the page to add new images. I want to be able to add a file name to a database and 6 images will be shown per page.

any help on how to do this, or links ?

thanks
 
*sigh* I've never done this on open forums:

all.php
PHP:
<?php

$dbhost = "localhost";
$dbname = "name";
$dbpass = "pass";
$dbuser = "user";

mysql_connect("$dbhost", "$dbuser", "$dbpass");
mysql_select_db("$dbname");

?>

index.php
PHP:
<?php

include("all.php");

$lralg = "SELECT * FROM images";
$res = mysql_query($lralg);
$hu = mysql_numrows($res);
$i=0;
while ($i < $hu) {
$hysa = mysql_result($res,$i,"location");
?>
<TABLE>
<TR>
<TD>
[img]<?php echo $locaton; ?>[/img]
</TD>
</TR>
</TABLE>


<?
$i++;
}

?>

/admin/index.php
PHP:
<?php

include("../all.php");

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

$location = $_POST['location'];

$add = "INSERT INTO images VALUES ('', '$location')";
if(mysql_query($add))
{
echo "Image added";
} else {
echo "Could not add image";
}

} else {
?>
<form method="POST" action="index.php">
Image location: <input type="text" name="location" value="/">


<input type="submit" name="submit" value="Add Image">
</form>
<?
}
?>

This is _VERY_ basic. You'll have to mod the HTML yourself. And /admin/ should be protected. And, you need to actually upload the image - the script doesn't do it for you.
 
Status
Not open for further replies.
Back
Top Bottom