Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Trouble Bookmarking PHP Page
Old 05-22-2008, 11:47 PM Trouble Bookmarking PHP Page
Junior Talker

Posts: 1
Trades: 0
I apologize for how confusing this might get. I'm using PHP to pull items from a SQL database. This is the relevant portion of the code from my main results page:

PHP Code:
// see if any rows were returned
if (mysql_num_rows($result) > 0) {
// yes
// print them one after another


echo "<table width=100% border=0 cellspacing=0 cellpadding=0 class=box_width_cont product><tr>";
$i 0;
while(
$row mysql_fetch_row($result)) {

if (
$i == 3)
{
echo 
"</tr><tr>";
$i 0;
}

echo 
"<td width=33%>";

echo 
"<a class='thumbnail' href='javascript:void(0)'><img src='images/3stone/rings/".$row[0]."fronts.jpg'>";

echo 
"<span><img src='images/3stone/rings/".$row[0]."front.jpg'></span></a><br>";

echo 
"<font color=#855b63><b>".$row[1]."<br>".$row[2]."<br>".$row[6]." Cut<br>Size: ".$row[3]."</b><br><br></font><font color=#855b63 size=3><b>".$row[9]."</b></font><br><br>";

echo 
"<form action='details.php' method='post'><input type='image' src='images/button_details.gif' name='0' value='".$row[0]."'></form><br><img height='2' src='images/spacer.gif'><br><img src='images/button_add_to_cart1.gif'><br><br><br>";

echo 
"</td>";

$i++;

}



echo 
"</table>";


As you can see, I have a details button under each row. I'm using a form POST method to send $row[0], which is the item number, to details.php when the button is clicked. Here is the query from details.php with the variable plugged in.

PHP Code:
$query "SELECT * FROM wwjitems WHERE item = '".$_POST["0"]."'"
Details.php is a page that returns just one result with more details on that particular item. Everything works great, with one little problem. When someone bookmarks details.php and comes back later, they get a blank page. Is there any way around this, or will I have to use a different method for creating the single item page?
stragglerat is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 05-22-2008, 11:54 PM Re: Trouble Bookmarking PHP Page
cbeaudin's Avatar
Extreme Talker

Posts: 158
Name: cbeaudin
Location: Proud to be Canadian
Trades: 1
Probably not the best way, but i would suggest using cookies or use GET instead of POST.
__________________
- cbeaudin

Last edited by cbeaudin; 05-23-2008 at 12:08 AM..
cbeaudin is offline
Reply With Quote
View Public Profile
 
Old 05-24-2008, 03:35 AM Re: Trouble Bookmarking PHP Page
Arenlor's Avatar
Ultra Talker

Posts: 462
Name: Jerod Lycett
Location: /home/arenlor
Trades: 0
Does your page contain any PII or anything like that? If it's ok for the public to see the use GET to allow them to share the link, if it's not ok for the public to see but you still want them to be able to come back to it in that browser session only use sessions, if it's not ok for the public to see and you're willing to take the risk then use cookies. POST is known for this 'issue' that you don't save the results in a bookmarkable way.
__________________
PHP Code:
<?php echo "Hello World"?>
HTML Code:
<html><head><title>Hello World</title></head><body><p>Hello World</p></body></html>
Arenlor is offline
Reply With Quote
View Public Profile Visit Arenlor's homepage!
 
Old 05-24-2008, 11:43 AM Re: Trouble Bookmarking PHP Page
Average Talker

Posts: 28
Trades: 0
The problem is that if $_POST isn't set, then no items are selected.

PHP Code:
$query "SELECT * FROM wwjitems WHERE item = '".$_POST["0"]."'"
So what you really want to do, is if no item is found, send them back to the list of items so that they can get to one that will work. Maybe try something along the lines of

PHP Code:
if(!isset($_POST["0"]))
        
header('Location:itemListingPage.php');
$query "SELECT * FROM wwjitems WHERE item = '".$_POST["0"]."'"

Last edited by Cory Dee; 05-24-2008 at 11:45 AM..
Cory Dee is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Trouble Bookmarking PHP Page
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.85380 seconds with 12 queries