![]() | |
| ||||
| 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 |
| |||||
| 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 |
| ||||
| <?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>"; } ?> |
| |||||
| and that's still not working... lets see... revised code PHP Code:
__________________ :. 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 |
| |||||
| also this line is not right: PHP Code:
__________________ :. 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 |
| |||||
| 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 |
| ||||
| <?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 |
| |||||
| 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 |
| ||||
| 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 |
| Thread Tools | |
| Display Modes | |
|
|
| | ||||
| 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 |