im using a my SQL database to power my portfolio section in my site,
i use this php script to do so,
Code: Select all
<?php
/*
X - Navigation Links 2.25
DESIGNED BY X-SCRIPTS
*/
include ("config.php");
//$table = '3dsmax'; // The name of your table in the database
$limit = '5'; // How many results should be shown at a time
$scroll = '10'; // How many elements to the navigation bar are shown at a time
// Get the total number of rows in a database
$query1 = mysql_query ("SELECT * FROM $table");
$numrows = mysql_num_rows ($query1);
//
if (!isset ($_GET[show])) {
$display = 1; // Change to $NUMROWS if DESCENDING order is required
} else {
$display = $_GET[show];
}
// Return results from START to LIMIT
$start = (($display * $limit) - $limit);
$query2 = mysql_query ("SELECT * FROM $table LIMIT $start,$limit");
while ($myrow = mysql_fetch_array ($query2)) {
// echo "<p>".$myrow[mainTitle]."</p>"; // EDIT TO REFLECT YOUR RESULTS
echo "<table width="529" border="0" cellspacing="0" cellpadding="0"> ";
echo "<tr>";
echo "<td colspan="3" class=TDTITLE><img src="db\box.gif" width="18" height="16"> ".$myrow[mainTitle]."</td>";
echo "</tr>";
echo "<tr>";
echo "<td width="360" class=TDCONTENT>".$myrow[shortName]."</td>";
echo "<td CLASS=TDIMG><a href="$movie$myrow[picLink]"><img CLASS=IMGBRD src="db\view.php?file={$myrow[id]}"></a></td>";
echo "<td width="46" CLASS=TDAFTERIMG></td>";
echo "</tr>";
echo "<tr>";
//echo "$File_Size()";
echo "<td colspan="3" CLASS=TDDOWNLOAD>File_Size($movie$myrow[picLink])<a href="$movie$myrow[picLink]">[play]</a></td>";
echo "</tr>";
echo "</table>";
/////////// table ////////
}
//
$paging = ceil ($numrows / $limit);
// Display the navigation
if ($limit != $numrows) {
echo "<table border="0" cellspacing="0" cellpadding="2" width="529" class="NEXTRECBRD"><tr>";
echo "<td colspan="6" class="NEXTRECBRD"><img src="spacer.gif" width="1" height="50"></td></tr>";
echo "<tr>";
if ($display > 1) {
$previous = $display - 1;
echo "<td height="26" align="right" class="NEXTREC"><a href="$_SERVER[PHP_SELF]?show=$previous#nav">Previous</a></td>";
} else {
echo "<td height="26" align="right" valign="top" class="NEXTREC"></td>";
}
if ($numrows != $limit) {
if ($paging > $scroll) {
$first = $_GET[show];
$last = ($scroll - 1) + $_GET[show];
} else {
$first = 1;
$last = $paging;
}
if ($last > $paging ) {
$first = $paging - ($scroll - 1);
$last = $paging;
}
for ($i = $first;$i <= $last;$i++){
if ($display == $i) {
echo "<td width="16" height="26" align="center" class="NEXTREC">$i</td>";
} else {
echo "<td width="16" height="26" align="center" class="NEXTREC"><a href="$_SERVER[PHP_SELF]?show=$i#nav">$i</a></td>";
}
}
}
if ($display < $paging) {
$next = $display + 1;
echo "<td width="100" height="26" class="NEXTREC"><a href="$_SERVER[PHP_SELF]?show=$next#nav">Next</a></td>";
} else {
echo "<td width="100" height="26" valign="top" class="NEXTREC"></td>";
}
echo "</tr></table>";
}
//
?>Code: Select all
<?php
include 'db.inc';
if (empty($maintitle) || empty($picLink) || empty($short) || empty($userfile))
{
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Upload an Image File</title>
<style type="text/css">
<!--
.textarea {
height: 100px;
}
body {
background-color: #999999;
}
-->
</style>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head>
<body>
<form method="post" action="insert.php" enctype="multipart/form-data">
<h1>Upload an Image File</h1>
<table>
<col span="1" align="right">
<tr>
<td>portfolio section </td>
<td><select name="list">list</select></td>
</tr>
<tr>
<td>Title</td>
<td><input type="text" name="maintitle" size=50></td>
</tr>
<tr>
<td><font color="red">Short description:</font></td>
<td><textarea name="short" cols="50" class="textarea"></textarea></td>
</tr>
<tr>
<td><font color="red">Thumbupload:</font></td>
<td><input name="userfile" type="file"></td>
</tr>
<tr>
<td>filelink:</td>
<td><input name="picLink" type="text">
</td>
</tr>
<tr>
<td><input type="submit" value="Submit"></td>
</tr>
</table>
<input type="hidden" name="MAX_FILE_SIZE" value="30000">
</form>
<h3>Click <a href="port.php">here</a> to browse the images instead.</h3>
</body>
</html>
<?php
}
else
{
$maintitle = clean($maintitle, 50);
$short = clean($short, 400);
$picLink = clean($picLink, 50);
$userfile = clean($userfile, 50);
if (!($connection = @ mysql_pconnect($hostName,
$username,
$password)))
showerror();
if (!mysql_select_db("kingabz_port", $connection))
showerror();
// Was a file uploaded?
if (is_uploaded_file($userfile))
{
switch ($userfile_type)
{
case "image/gif";
$mimeName = "GIF Image";
break;
case "image/jpeg";
$mimeName = "JPEG Image";
break;
case "image/jpg";
$mimeName = "JPEG Image";
break;
case "image/png";
$mimeName = "PNG Image";
break;
case "image/x-MS-bmp";
$mimeName = "Windows Bitmap";
break;
default:
$mimeName = "Unknown image type";
}
// Open the uploaded file
$file = fopen($userfile, "r");
// Read in the uploaded file
$fileContents = fread($file, filesize($userfile));
// Escape special characters in the file
$fileContents = AddSlashes($fileContents);
}
else
$fileContents = NULL;
$insertQuery = "INSERT INTO $table VALUES (NULL, "{$maintitle}", "{$short}", "{$picLink}",
"{$userfile_type}", "{$mimeName}", "{$fileContents}")";
if ((@ mysql_query ($insertQuery, $connection))
&& @ mysql_affected_rows() == 1)
header("Location: receipt.php?status=T&file="
. mysql_insert_id($connection));
else
header("Location: receipt.php?status=F&file="
. mysql_insert_id($connection));
} // if else empty()
?>so let say i have,
:3dsmax
:Maya
:solidworks
tables and waont them to be displayed in the submit form that i use to add entries, i want this cos it will make life simple, very simple.
and i include this script into the page i wont the results to be displayed, at the momet if i wont to show the results for a differant table i will have to create a few versions of the same script to display the results, is there a simpler way to call deffrent tables from the same script.
thanks alot, sorry for over doing it in content terms, ill try provideing a download link next time