473,661 Members | 2,449 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Trying to make a simple book catalog

Hi!
I'm a librarian with a little PHP knowledge.. I'm trying to make a
catalog from scratch for my library. I don't like the look of the
current catalog so I'm trying to make a custom PHP/MySQL
implementation.

I can do everything I need to do except, I don't completely understand
a detail. Ideally I could write this:

<a href="catalogre cord.php?record num=4">Tom Sawyer</a>

The idea would be to pass the number 4 to the catalogrecord.p hp page
when the hyperlink is clicked. Then it would know which number in the
catalog it should pull up and display on the next page. Is this
possible? And if so, how could I access the recordnum=4 on the next
php file?

Will

Feb 21 '07 #1
11 3584
Yes, it is possible. There look for $_GET["recordnum"] in your
catalogrecord.p hp script.

On Feb 21, 10:20 am, fishmonger1...@ gmail.com wrote:
Hi!
I'm a librarian with a little PHP knowledge.. I'm trying to make a
catalog from scratch for my library. I don't like the look of the
current catalog so I'm trying to make a custom PHP/MySQL
implementation.

I can do everything I need to do except, I don't completely understand
a detail. Ideally I could write this:

<a href="catalogre cord.php?record num=4">Tom Sawyer</a>

The idea would be to pass the number 4 to the catalogrecord.p hp page
when the hyperlink is clicked. Then it would know which number in the
catalog it should pull up and display on the next page. Is this
possible? And if so, how could I access the recordnum=4 on the next
php file?

Will

Feb 21 '07 #2
Rik
On Wed, 21 Feb 2007 02:20:49 +0100, <fi************ @gmail.comwrote :
Hi!
I'm a librarian with a little PHP knowledge.. I'm trying to make a
catalog from scratch for my library. I don't like the look of the
current catalog so I'm trying to make a custom PHP/MySQL
implementation.

I can do everything I need to do except, I don't completely understand
a detail. Ideally I could write this:

<a href="catalogre cord.php?record num=4">Tom Sawyer</a>

The idea would be to pass the number 4 to the catalogrecord.p hp page
when the hyperlink is clicked. Then it would know which number in the
catalog it should pull up and display on the next page. Is this
possible? And if so, how could I access the recordnum=4 on the next
php file?
The question is a bit vague, but to get you started:

You say MySQL, so I assume that number 4 is an index in the database where
the records are stored? A list of links could be made by:

<?php
mysql_connect(' hostname','user name','password ');//of you mysql db
mysql_select_db ('catalogue');
$books = mysql_query('SE LECT `id`, `name` FROM `book`');
while($book = mysql_fetch_ass oc($books)){
print '<a
href="catalogre cord.php?record num='.$book['id'].'">'.$book['name'].'</a><br>';
}
?>

And the receiving script would do something like this:

<?php
$book_id = intval($_GET['recordnum']);
mysql_connect(' hostname','user name','password ');//of you mysql db
mysql_select_db ('catalogue');
$bookresult = mysql_query('SE LECT * FROM `book` WHERE `id` = '.$book_id);
if(mysql_num_ro ws($bookresult) 0){
$book = mysql_fetch_ass oc($bookresult) ;
foreach($book as $key =$value){
print $key.':'.$value .'<br>';
}
} else {
echo 'Book not found in database.';
}
?>

--
Rik Wasmus
Feb 21 '07 #3
"Klarth" <ka*****@gmail. comwrites:
Yes, it is possible. There look for $_GET["recordnum"] in your
catalogrecord.p hp script.
Could someone explain to a noob the use of _get here and why not _post?
Feb 21 '07 #4
Richard wrote:
"Klarth" <ka*****@gmail. comwrites:
>Yes, it is possible. There look for $_GET["recordnum"] in your
catalogrecord. php script.

Could someone explain to a noob the use of _get here and why not _post?
Because he's passing it as part of the URL, so it's a GET request. A
POST request would come from a form with method=post.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Feb 21 '07 #5
Richard wrote:
"Klarth" <ka*****@gmail. comwrites:
>Yes, it is possible. There look for $_GET["recordnum"] in your
catalogrecord. php script.

Could someone explain to a noob the use of _get here and why not _post?
Oops - pressed send too quickly.

When the POST method is used, the parameters are not passed in the link
as part of the query string; rather they are passed by the browser out
of sight of the user.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Feb 21 '07 #6
Rik
On Wed, 21 Feb 2007 03:59:56 +0100, Jerry Stuckle
<js*******@attg lobal.netwrote:
Richard wrote:
>"Klarth" <ka*****@gmail. comwrites:
>>Yes, it is possible. There look for $_GET["recordnum"] in your
catalogrecord .php script.
Could someone explain to a noob the use of _get here and why not _post?

Oops - pressed send too quickly.

When the POST method is used, the parameters are not passed in the link
as part of the query string; rather they are passed by the browser out
of sight of the user.
Which on an 'open' site (this particular project seems to be local) would
have the advantage of being both bookmarkable (hmmmz, something doesn't
feel right about that word) and indexable by a search-engine.

--
Rik Wasmus
Feb 21 '07 #7
Rik wrote:
On Wed, 21 Feb 2007 03:59:56 +0100, Jerry Stuckle
<js*******@attg lobal.netwrote:
>Richard wrote:
>>"Klarth" <ka*****@gmail. comwrites:

Yes, it is possible. There look for $_GET["recordnum"] in your
catalogrecor d.php script.
Could someone explain to a noob the use of _get here and why not _post?

Oops - pressed send too quickly.

When the POST method is used, the parameters are not passed in the
link as part of the query string; rather they are passed by the
browser out of sight of the user.

Which on an 'open' site (this particular project seems to be local)
would have the advantage of being both bookmarkable (hmmmz, something
doesn't feel right about that word) and indexable by a search-engine.

--Rik Wasmus
Groan, Rik - was that on purpose? :-)

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Feb 21 '07 #8
>
And the receiving script would do something like this:

<?php
$book_id = intval($_GET['recordnum']);
mysql_connect( 'hostname','use rname','passwor d');//of you mysql db
mysql_select_d b('catalogue');
$bookresult = mysql_query('SE LECT * FROM `book` WHERE `id` =
'.$book_id);
if(mysql_num_r ows($bookresult ) 0){
$book = mysql_fetch_ass oc($bookresult) ;
foreach($book as $key =$value){
print $key.':'.$value .'<br>';
}
} else {
echo 'Book not found in database.';
}
?>
Ask why
$book_id = intval($_GET['recordnum']);
is used early on in the script and is it there just to 'keep things
tidy'? What naughty things could happen if it was just
$book_id = $_GET['recordnum'];

Supplementary question: What would you do here if you were getting a
string instead of a number to use in your SQL?

Another supplementary question: Why would it be a _bad_ idea to 'be
helpful' with the 'not found' message by echoing back the input as
follows:
$recno = GET['recordnum'];
print("Sorry we could not find your request for $recno");
--
PETER FOX Not the same since the submarine business went under
pe******@eminen t.demon.co.uk.n ot.this.bit.no. html
2 Tees Close, Witham, Essex.
Gravity beer in Essex <http://www.eminent.dem on.co.uk>
Feb 21 '07 #9
Rik
Peter Fox <pe******@emine nt.demon.co.uk. not.this.bit.no .htmlwrote:
>And the receiving script would do something like this:

<?php
$book_id = intval($_GET['recordnum']);
>$bookresult = mysql_query('SE LECT * FROM `book` WHERE `id` =
'.$book_id);
if(mysql_num_r ows($bookresult ) 0){
$book = mysql_fetch_ass oc($bookresult) ;
//
> }
} else {
echo 'Book not found in database.';
}
?>

Ask why
$book_id = intval($_GET['recordnum']);
is used early on in the script and is it there just to 'keep things
tidy'? What naughty things could happen if it was just
$book_id = $_GET['recordnum'];
Google SQL injection.
Supplementary question: What would you do here if you were getting a
string instead of a number to use in your SQL?
If possible prepared statements, else mysql_real_esca pe_string();
Another supplementary question: Why would it be a _bad_ idea to 'be
helpful' with the 'not found' message by echoing back the input as
follows:
$recno = GET['recordnum'];
print("Sorry we could not find your request for $recno");
Because it could containt evil code. I think you know the answers to these
already :P. It's far beyond the scope of the question to go in great
detail about security and database handling, as it was local, I was only
offering a starting point.
--
Rik Wasmus
Feb 21 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
1743
by: christof hoeke | last post by:
hi, does anyone know about this book which sounds great? unfortunately i could not find anything more about it apart from the following entry at amazon (germany only, strange...) http://www.amazon.de/exec/obidos/ASIN/0764547798/qid=1069188100/sr=1-4/ref=sr_1_8_4/302-8869636-4168805 at least Uche should know about it? thanks
1
1601
by: Larry | last post by:
I am a C++/Java programmer trying to get going with some simpe xml transformations at work here. I bought the O'Reilly book Learning xlst for kicks. Someone at work sent me this xml shown below, they wanted me to try to output some simple text which summarizes the basic data in the xml and do it without perl. After that I guess they will want me to convert other xml files into some kind of text file I am assuming. I downloaded xalan, but...
2
1865
by: DonMiche | last post by:
I'm having trouble producing an xml output from another xml file using xsl. The proper values are output to the browser as text with no formating or xml tags (<rowset> and <row>). Any ideas? (The xml source is available below) Here is my xsl:
6
1297
by: nemo | last post by:
Hi, I'm looking for a good introductory book on ASP.Net for teaching undergraduates who know VB.Net but are not programmers as such. Last year I used "Programming ASP.Net" - second edition, by Jesse Liberty and Dan Hurwitz. This was an excellent book for my purpose but now the second edition is out of print and the third edition has the example codes in C#. In the second edition the example codes were in C# as well as VB.
1
1504
momotaro
by: momotaro | last post by:
You are to write a card catalog type definition. There are up to 1000 books, and for each one you need: Title A list of up to 5 authors Catalog number A list of up to 5 subject headings Status (checked out or in the library) Write a function “SearchBySubject” that takes as parameters the database of books and a subject (string). It should find all books with that subject and print their title, first author, and catalog number. ...
1
2086
by: Paw64 | last post by:
The book code would uniquely identify a book in a book catalog. The book code is a ten digits value, where the first nine digits must be decimal digits (0...9), and the tenth can be either a decimal digit or the letter X. Three single dashes may be between any of the characters. (That is, a book code may either have no dashes or exactly three dashes). Also, a book code must not begin or end with a dash. What is a good way to start this? ...
4
3059
by: =?Utf-8?B?VGVycmFuY2U=?= | last post by:
I have an application that runs fine on my machine(of course) that access the local Sql Server. However, when trying to run this application from another machine I receive a Sql timeout error. I thought it was my stored procedure but that doesn't seem to be the case. The following are the connection strings that I've tried: //private string connstring = "integrated security=SSPI;data source=<ip address>;" // "persist security...
15
1882
by: dhr | last post by:
newbie question: Is there a 'K&R" type of Python book? The book that you'd better have on your shelf if you are going into Python?
5
184
by: Phil Hunt | last post by:
What is the significance of and @ prefix of a string. I see it mostly used in a SQL statement . Thanks
0
8855
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8758
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8545
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8633
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7364
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6185
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5653
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4179
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
1986
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.