Irish SEO,  Marketing & Webmaster Discussion
 

 

Go Back   Irish SEO, Marketing & Webmaster Discussion > Webmaster Help > Coding Help


Notices

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 15-03-2008, 04:30 PM
Frontpage User
 
Join Date: Apr 2007
Posts: 13
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
Keewee6 will become famous soon enough
Default php question

i have one result page and i want that when you click one the link it goes to details of that result but it does not work here is the code:

search page

<?php
mysql_connect("localhost", "username", "password")or die("cannot connect server ");
mysql_select_db("squarebar_db1")or die("cannot select DB");
?>
<?php
$sql="SELECT * FROM events";
$result = mysql_query($sql) or die (mysql_error);

while ($row = mysql_fetch_array($result))
{
echo $row ['events']. " - " ;
echo "<a href=details.php?$id=id>Click Here For Details</a></br>";
}
?>

details page

<?php
mysql_connect("localhost", "username", "password")or die("cannot connect server ");
mysql_select_db("squarebar_db1")or die("cannot select DB");

while ($row = mysql_fetch_array($result));
{
echo $row ['date'];
echo "<br>";
}
?>


any help would be good thanks
Reply With Quote
  #2 (permalink)  
Old 15-03-2008, 04:56 PM
louie's Avatar
Senior Member
 
Join Date: Jan 2006
Location: Dublin, Ireland
Posts: 1,934
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
louie has much to be proud oflouie has much to be proud oflouie has much to be proud oflouie has much to be proud oflouie has much to be proud oflouie has much to be proud oflouie has much to be proud oflouie has much to be proud of
Send a message via Yahoo to louie Send a message via Skype™ to louie
Default

erhhh where is the database query for the details page?

you connect to the db but you are not calling any tables so what kind of output do you expect?
__________________
:. Web Design & Development Web Design Ireland
:. Search Engines Optimization Search Engines Optimization
:. Directory Submission Directory Submission
:. News & Press Release Ireland GiveItSocks.com
:. Used Cars Ireland, Car Parts & Car Audio Cars For Sale, Car Parts & Accessories
:. I Have 2 Find It Directory SEF Directory
Reply With Quote
  #3 (permalink)  
Old 15-03-2008, 05:05 PM
Frontpage User
 
Join Date: Apr 2007
Posts: 13
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
Keewee6 will become famous soon enough
Default

<?php
mysql_connect("localhost", "username", "password")or die("cannot connect server ");
mysql_select_db("database")or die("cannot select DB");


$sql="SELECT * FROM events WHERE id=$id";
$result = mysql_query($sql) or die (mysql_error);

while ($row = mysql_fetch_array($result));
{
echo $row ['date'];
echo "<br>";
}
?>
Reply With Quote
  #4 (permalink)  
Old 15-03-2008, 05:47 PM
louie's Avatar
Senior Member
 
Join Date: Jan 2006
Location: Dublin, Ireland
Posts: 1,934
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
louie has much to be proud oflouie has much to be proud oflouie has much to be proud oflouie has much to be proud oflouie has much to be proud oflouie has much to be proud oflouie has much to be proud oflouie has much to be proud of
Send a message via Yahoo to louie Send a message via Skype™ to louie
Default

and that's still not working...
lets see...
revised code
PHP Code:
<?php 
//set var
$id = !empty($_GET['id']) ? preg_replace("#[^0-9]#","",$_GET['id']) : "";
 
if(empty(
$id)){
  echo (
"no id for this query");
  exit();
}
mysql_connect("localhost""username""password")or die("cannot connect server "); 
mysql_select_db("database")or die("cannot select DB");
 
$sql="SELECT * FROM events WHERE id='".addslashes($id)."'"
$result mysql_query($sql) or die (mysql_error);
 
while (
$row mysql_fetch_array($result));
{
echo 
$row ['date'];
echo 
"<br>";
}
?>
__________________
:. Web Design & Development Web Design Ireland
:. Search Engines Optimization Search Engines Optimization
:. Directory Submission Directory Submission
:. News & Press Release Ireland GiveItSocks.com
:. Used Cars Ireland, Car Parts & Car Audio Cars For Sale, Car Parts & Accessories
:. I Have 2 Find It Directory SEF Directory
Reply With Quote
  #5 (permalink)  
Old 15-03-2008, 05:50 PM
louie's Avatar
Senior Member
 
Join Date: Jan 2006
Location: Dublin, Ireland
Posts: 1,934
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
louie has much to be proud oflouie has much to be proud oflouie has much to be proud oflouie has much to be proud oflouie has much to be proud oflouie has much to be proud oflouie has much to be proud oflouie has much to be proud of
Send a message via Yahoo to louie Send a message via Skype™ to louie
Default

also this line is not right:
PHP Code:
echo "<a href=details.php?$id=id>Click Here For Details</a><br />";
 
//should be
//set id
$id $row['id']; //where id is the name of the field in the DB
echo "<a href='details.php?id=$id'>Click Here For Details</a><br />"
your php coding is way down the drain and I have to say your html knowledge is as good...
__________________
:. Web Design & Development Web Design Ireland
:. Search Engines Optimization Search Engines Optimization
:. Directory Submission Directory Submission
:. News & Press Release Ireland GiveItSocks.com
:. Used Cars Ireland, Car Parts & Car Audio Cars For Sale, Car Parts & Accessories
:. I Have 2 Find It Directory SEF Directory
Reply With Quote
  #6 (permalink)  
Old 15-03-2008, 06:10 PM
Frontpage User
 
Join Date: Apr 2007
Posts: 13
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
Keewee6 will become famous soon enough
Default

i am trying to learn any advice on good tutorial sites
Reply With Quote
  #7 (permalink)  
Old 15-03-2008, 06:43 PM
louie's Avatar
Senior Member
 
Join Date: Jan 2006
Location: Dublin, Ireland
Posts: 1,934
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
louie has much to be proud oflouie has much to be proud oflouie has much to be proud oflouie has much to be proud oflouie has much to be proud oflouie has much to be proud oflouie has much to be proud oflouie has much to be proud of
Send a message via Yahoo to louie Send a message via Skype™ to louie
Default

start with W3Schools Online Web Tutorials
__________________
:. Web Design & Development Web Design Ireland
:. Search Engines Optimization Search Engines Optimization
:. Directory Submission Directory Submission
:. News & Press Release Ireland GiveItSocks.com
:. Used Cars Ireland, Car Parts & Car Audio Cars For Sale, Car Parts & Accessories
:. I Have 2 Find It Directory SEF Directory
Reply With Quote
  #8 (permalink)  
Old 15-03-2008, 06:50 PM
Frontpage User
 
Join Date: Apr 2007
Posts: 13
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
Keewee6 will become famous soon enough
Default

<?php
//set var
$id = !empty($_GET['id']) ? preg_replace("#[^0-9]#","",$_GET['id']) : "";

if(empty($id)){
echo ("no id for this query");
exit();
}

mysql_connect("localhost", "username", "password")or die("cannot connect server ");
mysql_select_db("database")or die("cannot select DB");

$sql="SELECT * FROM events WHERE id='".addslashes($id)."'";
$result = mysql_query($sql) or die (mysql_error);

while ($row = mysql_fetch_array($result));
{
echo $row ['date'];
echo "<br>";
}
?>

now i get a mysql error
Reply With Quote
  #9 (permalink)  
Old 15-03-2008, 09:31 PM
louie's Avatar
Senior Member
 
Join Date: Jan 2006
Location: Dublin, Ireland
Posts: 1,934
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
louie has much to be proud oflouie has much to be proud oflouie has much to be proud oflouie has much to be proud oflouie has much to be proud oflouie has much to be proud oflouie has much to be proud oflouie has much to be proud of
Send a message via Yahoo to louie Send a message via Skype™ to louie
Default

what does the error says?
check the where statement making sure the "id" is the name of your DB field.
__________________
:. Web Design & Development Web Design Ireland
:. Search Engines Optimization Search Engines Optimization
:. Directory Submission Directory Submission
:. News & Press Release Ireland GiveItSocks.com
:. Used Cars Ireland, Car Parts & Car Audio Cars For Sale, Car Parts & Accessories
:. I Have 2 Find It Directory SEF Directory
Reply With Quote
  #10 (permalink)  
Old 16-03-2008, 04:35 PM
Frontpage User
 
Join Date: Apr 2007
Posts: 13
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
Keewee6 will become famous soon enough
Default

it just says "mysql_error" thats all on the details page when i click on the link on the search page

here is the search page

<?php
mysql_connect("localhost", "username", "password")or die("cannot connect server ");
mysql_select_db("database")or die("cannot select DB");
?>
<?php
$sql="SELECT * FROM events";
$result = mysql_query($sql) or die (mysql_error);

while ($row = mysql_fetch_array($result))
{
//set id
$id = $row['id']; //where id is the name of the field in the DB
echo $row['events'];
echo "<a href='details.php?id=$id'>Click Here For Details</a><br />";
}
?>

details page

<?php
//set var
$id = !empty($_GET['id']) ? preg_replace("#[^0-9]#","",$_GET['id']) : "";

if(empty($id)){
echo ("no id for this query");
exit();
}

mysql_connect("localhost", "username", "password")or die("cannot connect server ");
mysql_select_db("database")or die("cannot select DB");

$result('SELECT * from events WHERE id=$id');
$result = mysql_query($sql) or die (mysql_error);

while ($row = mysql_fetch_array($result));
{
echo $row ['date'];
echo "<br>";
}
?>

thanks you in advance much appreciated i am trying to learn it aint easy
Reply With Quote
Reply

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
php question Keewee6 Coding Help 3 14-03-2008 11:34 PM
Ruby on Rails VS PHP Code Igniter gav240z Coding Help 10 03-02-2008 11:04 PM
General Blog questions & BLOG URL SEO question. Help Please? :-) Gman290 Search Engine Optimisation 4 07-12-2007 10:24 AM
php question Keewee6 Coding Help 2 17-08-2007 12:51 PM
HELP :: PHP regular expression question littleBird Coding Help 3 13-03-2007 09:33 PM


All times are GMT +1. The time now is 08:17 AM.


Powered by: vBulletin Version 3.7.2, Copyright ©2000 - 2008, Jelsoft Enterprises Limited.

Search Engine Friendly URLs by vBSEO 3.2.0