Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Let me start by saying I am totally new to PHP and MySQL
I am trying to create an intranet page that has an index, a random quote section and a search function. I am using Dreamweaver for the site layout, php for the scripts, and MySQL for the database
$host = 'localhost';
$dbUser = 'foo';
$dbPass = 'bar';
$dbName = 'Somename';Table structure – Table_Name
ID || File_Name || Folder_Name || date
I will probably only search for either File_Name or Folder_Name at this stage!Here is the way I have my page setup, and what I am trying to achieve.
Up the top of the page is a tabbed navigation bar consisting of 10 tabs done with CSS (no problems here).
1 table for the body of the site consisting of 3 columns, the left column is split in 2 (no problem here), the top half has a form, an input box -text field, a list/menu box with file and folder . The Bottom half has a random quotes script (php) (no problem here)
The middle column has an index listing all files and folders in the directory (no problem here).
The right column is where I want to put the search results.The bit I am having troubles with is displaying the results of a search. By troubles I mean I am not getting any results at all or at least 99% of the time. I know I can connect to the database as I have had all the columns return a value at one time, ( I cannot even remember what I did to get that as it was about 3 AM when I got that result) essentially making that another index, this isn’t what I wanted though, I want to enter a search word, for instance “cat”, into the search field in the left column, have the scripts connect to the database, search through the database and return the file to the right column as a link, clicking on that link will open up the “cat” file. And then close the connection.
For someone with a little – lot of experience this would probably take 5 minutes tops, I have no experience and have been stuck on this for a number of days
This is what I have so far from trying to follow several different tutorials and manuals and using DW's built in functions. It is not effective at all. And I am totally out of ideas
<?php require_once('Connections/Somename.php'); ?>
<?php
$currentPage = $_SERVER["PHP_SELF"];$maxRows_Somename = 1;
$pageNum_Somename = 0;
if (isset($_GET['pageNum_Somename'])) {
$pageNum_Somename = $_GET['pageNum_Somename'];
}
$startRow_Somename = $pageNum_Somename * $maxRows_Somename;mysql_select_db($database_Somename, $Somename);
$query_Somename = "SELECT File_Name, Folder_Name FROM Table_Name";
$query_limit_Somename = sprintf("%s LIMIT %d, %d", $query_Somename, $startRow_Somename, $maxRows_Somename);
$Somename = mysql_query($query_limit_Somename, $Somename) or die(mysql_error());
$row_Somename = mysql_fetch_assoc($Somename);if (isset($_GET['totalRows_Somename'])) {
$totalRows_Somename = $_GET['totalRows_Somename'];
} else {
$all_Somename = mysql_query($query_Somename);
$totalRows_Somename = mysql_num_rows($all_Somename);
}
$totalPages_Somename = ceil($totalRows_Somename/$maxRows_Somename)-1;$queryString_Somename = "";
if (!empty($_SERVER['QUERY_STRING'])) {
$params = explode("&", $_SERVER['QUERY_STRING']);
$newParams = array();
foreach ($params as $param) {
if (stristr($param, "pageNum_Somename") == false &&
stristr($param, "totalRows_Somename") == false) {
array_push($newParams, $param);
}
}
if (count($newParams) != 0) {
$queryString_Somename = "&" . htmlentities(implode("&", $newParams));
}
}
$queryString_Somename = sprintf("&totalRows_Somename=%d%s", $totalRows_Somename, $queryString_Somename);
?>I have tried to include all relevant information but no doubt I have left some things out.
Sorry for the long post.

Well no one has answered this, so i will give some general advice. I say general advice, because - to be honest - I'm not going to go through your code line by line to try and figure out what you meant to do and what you should have done.
When working with new language or new technology, start with something VERY simple then add to it. In this case, hit the table in question and return all rown and display them to the page. Then start adding functionality to that to build what you need.
Second, during the development phase, always write variable names and their values to the page before and after any statements that use those variables. Sometimes you might inadvertantly mistype a mathmatical function that transforms a variable incorrectly or the variables passed to a correct function are invalid. Never assume the values being passed to a function are correct.
Michael J

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |