kamal213 Posted July 20, 2011 Share Posted July 20, 2011 Hi guys, Can you tell me if it is possible. Let say you had a table which stores names and address (with a primary key and auto-increment) , and a PHP script which display every thing on you SQL Table dynamically. Is it possible to write a PHP code such that if a name and address is added it display and its clickable "i.e. <a href="">$name,$address</a>", and if a new name and address is added its also clickable BUT the older/previous added become unclickable. I would really appreciate your inputs Thanks guys! Quote Link to comment https://forums.phpfreaks.com/topic/242422-php-code-help/ Share on other sites More sharing options...
trq Posted July 20, 2011 Share Posted July 20, 2011 Of course it's possible. Quote Link to comment https://forums.phpfreaks.com/topic/242422-php-code-help/#findComment-1245082 Share on other sites More sharing options...
QuickOldCar Posted July 20, 2011 Share Posted July 20, 2011 Do you mean something like this? <?php $testArray = range(1,20); $testArray[0] = "<a href='$testArray[0]'>$testArray[0]</a>"; foreach($testArray as $value){ echo $value."<br />";; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/242422-php-code-help/#findComment-1245085 Share on other sites More sharing options...
kamal213 Posted July 20, 2011 Author Share Posted July 20, 2011 Thanks for your reply QuickOldCar! Please explain what the testArray variable and the foreach function do. Thanks alot Quote Link to comment https://forums.phpfreaks.com/topic/242422-php-code-help/#findComment-1245087 Share on other sites More sharing options...
QuickOldCar Posted July 20, 2011 Share Posted July 20, 2011 $testArray = range(1,20); That is a range, it saved me from doing this....(but now I see I'm doing it anyway) same as $testArray = array("1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20"); foreach will loop each value within the array http://php.net/manual/en/control-structures.foreach.php Arrays start at key position zero $value[0] All i did is replace the first key value with something else Quote Link to comment https://forums.phpfreaks.com/topic/242422-php-code-help/#findComment-1245115 Share on other sites More sharing options...
kamal213 Posted July 20, 2011 Author Share Posted July 20, 2011 Thanks QuickOldCar, I take it the numbers in the array would for example be the items in my database table? if yes can the code make the items from 0-19 unclickable and item 20 clickable? as this would exactly what am looking for and would solve the problem. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/242422-php-code-help/#findComment-1245124 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.