- Readme First! - Read and follow the rules, otherwise your posts will be closed
There are currently, 144 guest(s) and 0 member(s) that are online. You are Anonymous user. You can register for free by clicking here
Nuke Cops :: View topic - Block that displays latest 10 items added to a database [ ]
Author
Message
RedGerry
Captain
Joined: Jul 28, 2003
Posts: 304
Location: Alloa, Scotland
Posted:
Sun Jan 04, 2004 2:57 pm
Sorry Dude.. got waylaid with the Christmas fetivities.
Had a look at this for you and ran into a problem with the table names. If anyone out there can give me the syntax to address the table then the rest is a doddle. i.e Divx Title only returns DivX when the field name is returned.. spaces.. ?
_________________ RedGerry.com - Home of RG_Sports
Tjendol
Sergeant
Joined: Dec 15, 2003
Posts: 77
Posted:
Mon Jan 05, 2004 1:46 pm
I'm not sure what you mean but the name of this table in my database is Divx_Title. So there's an underscore in it there.
The name of the column is Divx Title, without the underscore. I'm no expert but I'm guessing you need to the Divx Title (Column) out of the Divx_Title (Table)....right?
Tjendol
Sergeant
Joined: Dec 15, 2003
Posts: 77
Posted:
Mon Jan 05, 2004 1:57 pm
Yay, somebody answered
I'm not sure what you mean but maybe this screenshot of one of the tables in my MySQL front will clear things up for you.
So the database is called divx, the table is called divx and the column name of the title is Divx_Title ( with an underscore)
The following is the divx page code with names that also refer to parts of the table..as I explainend I don't know much about php so I don't know which names you need, but here's the code:
Code:
<?php session_start(); ?>
<?php /* no security */ ?>
<?php
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified
header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache"); // HTTP/1.0
?>
<?php include ("db.php") ?>
<?php include ("function.php") ?>
<?php
$displayRecs = 27;
$recRange = 10;
// Get table name
$tablename = "`divx`";
$dbwhere = "";
$a_search = "";
$b_search = "";
?>
<?php
// Get search criteria for basic search
$pSearch = @$HTTP_GET_VARS["psearch"];
if ($pSearch != "")
{
$pSearch = (!get_magic_quotes_gpc()) ? addslashes($pSearch) : $pSearch;
$b_search .= "`Divx_Title` LIKE '%".$pSearch."%' OR ";
$b_search .= "`Download_Location` LIKE '%".$pSearch."%' OR ";
$b_search .= "`Language` LIKE '%".$pSearch."%' OR ";
$b_search .= "`Name_Author` LIKE '%".$pSearch."%' OR ";
$b_search .= "`E-Mail` LIKE '%".$pSearch."%' OR ";
}
if (strlen($b_search) > 4)
{
$b_search = substr($b_search, 0, strlen($b_search)-4);
$b_search = "(".$b_search.")";
}
?>
<?php
//Build search criteria
if ($a_search != "")
{
$dbwhere .= $a_search; //advance search
} elseif ($b_search!="") {
$dbwhere .= $b_search; //basic search
}
//Save search criteria
if ($dbwhere != "")
{
$HTTP_SESSION_VARS["tablename"] = $tablename;
$HTTP_SESSION_VARS["dbwhere"] = $dbwhere;
//reset start record counter
$startRec = 1;
$HTTP_SESSION_VARS["divx_REC"] = $startRec;
} else {
if ($tablename == @$HTTP_SESSION_VARS["tablename"])
{
$dbwhere = $HTTP_SESSION_VARS["dbwhere"];
} else {
//reset search criteria
$dbwhere = "";
$HTTP_SESSION_VARS["dbwhere"] = $dbwhere;
}
}
//Get clear search cmd
$cmd = @$HTTP_GET_VARS["cmd"];
if (strtoupper($cmd)=="RESET")
{
//reset search criteria
$dbwhere = "";
$HTTP_SESSION_VARS["dbwhere"] = $dbwhere;
}
?>
<?php
// Load Default Order
$DefaultOrder = "";
$DefaultOrderType = "";
// Check for an Order parameter
$OrderBy = @$HTTP_GET_VARS["order"];
if ($OrderBy != "")
{
// Check if an ASC/DESC toggle is required
if ($HTTP_SESSION_VARS["divx_OB"] == $OrderBy)
{
if ($HTTP_SESSION_VARS["divx_OT"] == "ASC")
{
$HTTP_SESSION_VARS["divx_OT"] = "DESC";
} else {
$HTTP_SESSION_VARS["divx_OT"] = "ASC";
}
} else {
$HTTP_SESSION_VARS["divx_OT"] = "ASC";
}
$HTTP_SESSION_VARS["divx_OB"] = $OrderBy;
$HTTP_SESSION_VARS["divx_REC"] = 1;
} else {
$OrderBy = @$HTTP_SESSION_VARS["divx_OB"];
if ($OrderBy == "")
{
$OrderBy = $DefaultOrder;
$HTTP_SESSION_VARS["divx_OB"] = $OrderBy;
$HTTP_SESSION_VARS["divx_OT"] = $DefaultOrderType;
}
}
// Check for a START parameter
$startRec = @$HTTP_GET_VARS["start"];
if ($startRec != "")
{
$HTTP_SESSION_VARS["divx_REC"] = $startRec;
} else {
$startRec = @$HTTP_SESSION_VARS["divx_REC"];
if ($startRec == "")
{
//reset start record counter
$startRec = 1;
$HTTP_SESSION_VARS["divx_REC"] = $startRec;
}
}
//Set the last record to display
$stopRec = $startRec + $displayRecs - 1;
// Open Connection to the database
$conn = mysql_connect(HOST, USER, PASS);
mysql_select_db(DB);
// Build Query
$strsql = "SELECT * FROM `divx`";
if ($dbwhere != "")
{
$strsql .= " WHERE ".$dbwhere;
}
if ($OrderBy != "")
{
$strsql .= " ORDER BY `".$OrderBy."` ".@$HTTP_SESSION_VARS["divx_OT"];
}
$rs = mysql_query($strsql, $conn) or die(mysql_error());
$totalRecs = mysql_num_rows($rs);
?>
<?php include ("header.php") ?>
<form action="divxlist.php">
<table border="0" cellspacing="1" cellpadding="4">
<tr>
<td><font size="-1"><b>Quick Search (*)</b></font></td>
<td>
<input type="Text" name="psearch" size=40>
<input type="Submit" name="Submit" value="GO!">
</td>
<td><a href="divxlist.php?cmd=reset"><font size="-1">Show All</font></a></td>
</tr>
</table>
</form>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="0" align="left"><a href="divxadd.php"><font size="-1">ADD A DIVX MOVIE</font></a> <a href="../pc games/pc_gamesadd.php"><font size="-1">ADD A PC GAME</font></a> <a href="../svcd/svcdadd.php"><font size="-1">ADD A SVCD MOVIE</font></a> <a href="../xvid/xvidadd.php"><font size="-1">ADD A XVID MOVIE</font></a></td>
</tr>
</table>
<p>
<body vlink="#000000">
<form>
<table width="100%" border="1" cellpadding="2" cellspacing="0" bordercolor="#000000" bgcolor="#CCCCCC">
<tr bgcolor="#CC0033">
<td><a href="divxlist.php?order=<?php echo urlencode("Divx_Title"); ?>"><font color="#FFFFFF"><font color="#000000" size="-1">Sort
by title</font></font></a></td>
<td nowrap><a href="divxlist.php?order=<?php echo urlencode("Download_Location"); ?>"><font color="#FFFFFF"><font color="#000000" size="-1">Sort
by link name</font></font></a></td>
<td nowrap><a href="divxlist.php?order=<?php echo urlencode("Language"); ?>"><font color="#FFFFFF"><font color="#000000" size="-1">Sort
by language</font></font></a> </td>
<td nowrap><a href="divxlist.php?order=<?php echo urlencode("Name_Author"); ?>"><font color="#FFFFFF"><font color="#000000" size="-1">Sort
by author</font></font></a></td>
<td nowrap><a href="divxlist.php?order=<?php echo urlencode("E-Mail"); ?>"><font color="#FFFFFF"><font color="#000000" size="-1">Sort
by e-mail</font></font></a></td>
<td nowrap><a href="divxlist.php?order=<?php echo urlencode("Date_Added"); ?>"><font color="#FFFFFF"><font color="#000000" size="-1">Sort
by date</font></font></a></td>
</tr>
<tr bgcolor="#FFFFFF" background="images/bg_cat2.gif">
<td background="images/bg_cat2.gif"> <font color="#FFFFFF"><font color="#000000" size="-1">Divx
Title</font></font></td>
<td width="283" nowrap background="images/bg_cat2.gif"> <font color="#FFFFFF"><font color="#000000" size="-1">Download
Location</font></font></td>
<td width="75" nowrap background="images/bg_cat2.gif"> <font color="#FFFFFF"><font color="#000000" size="-1">Language</font></font></td>
<td width="94" nowrap background="images/bg_cat2.gif"> <font color="#FFFFFF"><font color="#000000" size="-1">Name
Author</font></font></td>
<td width="56" nowrap background="images/bg_cat2.gif"> <font color="#FFFFFF"><font color="#000000" size="-1">E
Mail</font></font></td>
<td width="72" nowrap background="images/bg_cat2.gif"> <font color="#FFFFFF"><font color="#000000" size="-1">Date
Added </font></font> </td>
</tr>
<?php
$recCount = $startRec - 1;
@mysql_data_seek($rs, $recCount);
while (($row = mysql_fetch_assoc($rs)) && ($recCount < $stopRec))
{
$recCount++;
if (intval($recCount) >= intval($startRec))
{
//set row color
$bgcolor="#FFFFFF";
?>
<?php
// Display alternate color for rows
if ($recCount % 2 != 0)
{
$bgcolor = "#F5F5F5";
}
?>
<?php
$x_Divx_Title = $row["Divx_Title"];
$x_Download_Location = $row["Download_Location"];
$x_Language = $row["Language"];
$x_Name_Author = $row["Name_Author"];
$x_E2DMail = $row["E-Mail"];
$x_Date_Added = $row["Date_Added"];
?>
<tr>
<td width="198" nowrap bgcolor="<?php echo $bgcolor; ?>"><font size="-1">
<?php echo $x_Divx_Title ?> </font></td>
<td width="283" nowrap bgcolor="<?php echo $bgcolor; ?>"><font size="-1">
<?php echo $x_Download_Location ?> </font></td>
<td nowrap bgcolor="<?php echo $bgcolor; ?>"><font size="-1"> <?php echo $x_Language ?>
</font></td>
<td nowrap bgcolor="<?php echo $bgcolor; ?>"><font size="-1"> <?php echo $x_Name_Author ?>
</font></td>
<td nowrap bgcolor="<?php echo $bgcolor; ?>"><font size="-1"> <?php echo $x_E2DMail ?>
</font></td>
<td nowrap bgcolor="<?php echo $bgcolor; ?>"><font size="-1"> <?php echo $x_Date_Added ?>
</font></td>
</tr>
<?php
}
}
mysql_free_result($rs);
mysql_close($conn);
?>
</table>
<br>
<a href="/modules.php?name=Feedback" target="_blank">Report broken link</a>
</form>
<?php
if ($totalRecs > 0)
{
// Find out if there should be Backward or Forward Buttons on the table.
if ($startRec == 1)
{
$isPrev = false;
} else {
$isPrev = true;
$PrevStart = $startRec - $displayRecs;
if ($PrevStart < 1)
{
$PrevStart = 1;
}
?>
<hr size="1" noshade>
<strong><a href="divxlist.php?start=<?php echo $PrevStart; ?>"><font size="-1">[<< Prev]</font></a></strong>
<?php
}
// Display Page numbers
if ($isPrev||(!($totalRecs == 0)))
{
if (!$isPrev)
{
?>
<hr size="1" noshade>
<?php
}
$x = 1;
$y = 1;
$dx1 = intval(($startRec - 1)/($displayRecs*$recRange))*$displayRecs*$recRange + 1;
$dy1 = intval(($startRec - 1)/($displayRecs*$recRange))*$recRange + 1;
if (($dx1 + $displayRecs*$recRange - 1) > $totalRecs)
{
$dx2 = intval($totalRecs/$displayRecs)*$displayRecs + 1;
$dy2 = intval($totalRecs/$displayRecs) + 1;
} else {
$dx2 = $dx1 + $displayRecs*$recRange - 1;
$dy2 = $dy1 + $recRange - 1;
}
while ($x <= $totalRecs)
{
if (($x >= $dx1)&&($x <= $dx2))
{
if (intval($startRec) == intval($x))
{
?>
<strong><font size="-1"><?php echo $y; ?></font></strong>
<?php
} else {
?>
<strong><a href="divxlist.php?start=<?php echo $x; ?>"><font size="-1"><?php echo $y; ?></font></a></strong>
<?php
}
$x = $x + $displayRecs;
$y = $y + 1;
} elseif (($x >= ($dx1 - $displayRecs*$recRange))&&($x <= ($dx2 + $displayRecs*$recRange)))
{
if ($x + $recRange*$displayRecs < $totalRecs)
{
?>
<strong><a href="divxlist.php?start=<?php echo $x; ?>"><font size="-1"><?php echo $y; ?>-<?php echo $y + $recRange - 1; ?></font></a></strong>
<?php
} else {
$ny = intval(($totalRecs - 1)/$displayRecs) + 1;
if ($ny == $y)
{
?>
<strong><a href="divxlist.php?start=<?php echo $x; ?>"><font size="-1"><?php echo $y; ?></font></a></strong>
<?php
} else {
?>
<strong><a href="divxlist.php?start=<?php echo $x; ?>"><font size="-1"><?php echo $y; ?>-<?php echo $ny; ?></font></a></strong>
<?php
}
}
$x = $x + $recRange*$displayRecs;
$y = $y + $recRange;
} else {
$x = $x + $recRange*$displayRecs;
$y = $y + $recRange;
}
}
}
// Next link
if ($totalRecs >= $startRec + $displayRecs)
{
$NextStart = $startRec + $displayRecs;
$isMore = true;
?>
<strong><a href="divxlist.php?start=<?php echo $NextStart; ?>"><font size="-1">[Next >>]</font></a></strong>
<?php
} else {
$isMore=false;
}
?>
<hr size="1" noshade>
<?php
if ($stopRec > $recCount)
{
$stopRec = $recCount;
}
?>
<font size="-1">Records <?php echo $startRec; ?> to <?php echo $stopRec; ?> of <?php echo $totalRecs; ?></font>
<?php
} else {
?>
<br><br>
<font size="-1">No records found!</font>
<br><br>
<?php
}
?>
<?php include ("footer.php") ?>
Thnx a lot for looking at it.
Tjendol
Sergeant
Joined: Dec 15, 2003
Posts: 77
Posted:
Fri Jan 09, 2004 3:49 pm
plz? this should be pretty easy for all you programmers out there
I don't know how to fix it
Tjendol
Sergeant
Joined: Dec 15, 2003
Posts: 77
Posted:
Fri Jan 23, 2004 3:45 am
lol, can somebody help me with this?
I started this post over a month ago and I still haven't got a solution.
This forum should be more efficient people
Goto page Previous 1 , 2
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum