Thauwa Posted February 23, 2009 Share Posted February 23, 2009 I know how to display records from mysql as a whole (say items in a shop). So there is no logging in or out.. only links. So how can I view each item with its details individually? tks in advance Quote Link to comment https://forums.phpfreaks.com/topic/146467-solved-displaying-mysql-records-individually/ Share on other sites More sharing options...
JoeBuntu Posted February 23, 2009 Share Posted February 23, 2009 Depends what you mean. I think that you are asking how to write a SQL statement that will narrow your result down to one specific record: $sqlStatement = "SELECT * FROM SomeTable WHERE someField = 'somevalue'"; Quote Link to comment https://forums.phpfreaks.com/topic/146467-solved-displaying-mysql-records-individually/#findComment-768934 Share on other sites More sharing options...
Thauwa Posted February 23, 2009 Author Share Posted February 23, 2009 oh...that means I have to make all pages manually....unlike the thing I've seen on smf... ?action=erere anyway....what you meant was right Quote Link to comment https://forums.phpfreaks.com/topic/146467-solved-displaying-mysql-records-individually/#findComment-768944 Share on other sites More sharing options...
dropfaith Posted February 23, 2009 Share Posted February 23, 2009 just have it dynamicly echo out links say page.php?item=$itemName then on page.php MEH SOMETHING LIKE THIS $itemName = mysql_escape_string(trim(htmlentities($_GET['itemName']))); $query = "SELECT * FROM ITEMS WHERE itemName = '$itemName'"; $result = mysql_query($query) or die ("Error in query: $query. " . mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/146467-solved-displaying-mysql-records-individually/#findComment-768948 Share on other sites More sharing options...
Thauwa Posted February 23, 2009 Author Share Posted February 23, 2009 so... I do something like $data = mysql_query("SELECT * FROM items") or die(mysql_error()); while($info = mysql_fetch_array( $data )) //array { $item= $info['item'] echo 'Item: <a href=http://www.ilovedoingstuff.com/items.php?item=$item>' .$info['item'] . ' </a>'; } Quote Link to comment https://forums.phpfreaks.com/topic/146467-solved-displaying-mysql-records-individually/#findComment-768953 Share on other sites More sharing options...
dropfaith Posted February 23, 2009 Share Posted February 23, 2009 yeah if im not mistaken that will loop your database creating links then the links just use the $get method in your search query like i posted above Quote Link to comment https://forums.phpfreaks.com/topic/146467-solved-displaying-mysql-records-individually/#findComment-768960 Share on other sites More sharing options...
Thauwa Posted February 23, 2009 Author Share Posted February 23, 2009 but is my code correct ? ??? I am still a simple programmer! Quote Link to comment https://forums.phpfreaks.com/topic/146467-solved-displaying-mysql-records-individually/#findComment-768986 Share on other sites More sharing options...
keeps21 Posted February 23, 2009 Share Posted February 23, 2009 but is my code correct ? ??? I am still a simple programmer! $data = mysql_query("SELECT item FROM items") or die(mysql_error()); while($info = mysql_fetch_array( $data )) //array { echo "Item: <a href=\"http://www.ilovedoingstuff.com/items.php?item={$info['item']}\">{$info["item"]}</a>"; } I believe that should do it. Quote Link to comment https://forums.phpfreaks.com/topic/146467-solved-displaying-mysql-records-individually/#findComment-769194 Share on other sites More sharing options...
Thauwa Posted February 24, 2009 Author Share Posted February 24, 2009 wow...and I think it did! Quote Link to comment https://forums.phpfreaks.com/topic/146467-solved-displaying-mysql-records-individually/#findComment-769905 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.