Page 1 of 1

Inserting data via serach

Posted: Sat May 21, 2005 5:00 am
by barney0o0
Sorry for the repost...i didnt submit the first topic correctly, so it got ignored...ok, total newbie....ive been going through a book and trying to alter for my own needs, but i just cant get it to work....could anyone help

I understand that i need to create a dummy table prior to retrieving actual data in result page. What i have so far the the following, but i need help as i think i made a total mess of it.I just want to retreive, via a search informtion from one database table.

The first bit to ive tried to insert into a empty table, but i think that this is totally wrong!

Code: Select all

<?php 
mysql_select_db($database_tapfinalconnection, $tapfinalconnection); 
$query_LibraryLookup = "INSERT INTO librarylookup SELECT library_1.BookID, library_1.BookTitle, library_1.Author, library_1.BookISDM, library_1.AuthorInitail, library_1.Comment, library_1.SessionCube FROM library, library library_1, library"; 
mysql_query($query_Librarylookup,$tapfinalconnection); 
?>
The next 2 section are as:

Code: Select all

<?php 
$WhereParam_Library = "Where BookID <>0"; 
if (isset($WhereParam)) { 
$WhereParam_Library = (get_magic_quotes_gpc()) ? $WhereParam : addslashes($WhereParam); 
} 
mysql_select_db($database_tapfinalconnection, $tapfinalconnection); 
$query_Library = sprintf("SELECT * FROM LibraryLookup %s", $WhereParam_Library); 
$Library = mysql_query($query_Library, $tapfinalconnection) or die(mysql_error()); 
$row_Library = mysql_fetch_assoc($Library); 
$totalRows_Library = mysql_num_rows($Library); 
?> 
<?php 
$query_LibraryLookup = "DELETE FROM librarylookup"; 
mysql_query($query_LibraryLookup,$tapfinalconnection); 
?>
I hope someone is able to help and point me in the right direction. Many thanks in advance

Posted: Mon May 23, 2005 7:24 am
by ody
The first query should look something like this:

Code: Select all

$query_LibraryLookup = "INSERT INTO librarylookup SELECT BookID, BookTitle, Author, BookISDM, AuthorInitail, Comment, SessionCube FROM library_1";
The second peace of code more like:

Code: Select all

<?php
mysql_select_db($database_tapfinalconnection, $tapfinalconnection); 
$query_Library = "SELECT * FROM LibraryLookup Where BookID <>0"; 
$Library = mysql_query($query_Library, $tapfinalconnection) or die(mysql_error()); 
$row_Library = mysql_fetch_assoc($Library); 
$totalRows_Library = mysql_num_rows($Library); 

$query_LibraryLookup = "DELETE FROM librarylookup"; 
mysql_query($query_LibraryLookup,$tapfinalconnection); 
?>
I've attempted to clean things up a little.. you don't seem to do anything with the first query in the second peace of code..

d11wtq | Changed to

Code: Select all

tags [/size][/color]

Posted: Mon May 23, 2005 8:05 am
by barney0o0
Cheers Ody for your reponse...

Does the first bit of script temporarily fill a table with data, as according to this book ive been trying to work from " to compensate MySQLs lack of support for views"?.....Is this then referred to in the second section of text i.e. retrieving the data from libraryLookup into library?

Ive copied and pasted, by no results show (without any error messages also. Please excuse me, but im a total nonce, if you have a mo, would you be able to makes some changes?

Many many thanks

B