How to create Links in results from a MySQL Database
Moderator: General Moderators
How to create Links in results from a MySQL Database
Hello Everyone!
I have been searching for the answer to this simple question for ages, and i am guessing it is probably a simple answer. I just can not work this out. I am teaching myself MySQL and PHP and I have a page which work fine as a search. But what i need is to have links to .php files to appear in the search results.
Basically what the website does is advertises. Each advertiser has their own page, which i need to bring up in the search results so users can click on the link and go to their particular page, I also need the search results to bring up other advertisers with similar products etc.
Any advice, tutorials or direction would be GREAT!
Thanks heaps
Rachael
I have been searching for the answer to this simple question for ages, and i am guessing it is probably a simple answer. I just can not work this out. I am teaching myself MySQL and PHP and I have a page which work fine as a search. But what i need is to have links to .php files to appear in the search results.
Basically what the website does is advertises. Each advertiser has their own page, which i need to bring up in the search results so users can click on the link and go to their particular page, I also need the search results to bring up other advertisers with similar products etc.
Any advice, tutorials or direction would be GREAT!
Thanks heaps
Rachael
Are you looking for something like this
Code: Select all
<?php
$link = 'http://www.somesite.com';
$link_desc = 'Click here to visit site';
?>
<a href="<?php echo $link?>"><?php echo $link_desc ?></a>Hey Boo,
Thanks for the response, that is close, but what i need is maybe the headings of each result to link to their related page.
So for example:
Gary's Lawn Seed - (this to link to garys_lawn_seed.php)
gary stocks a wide range of lawn seed.....
Bills Lawn Seed - (this to link to bill_lawn_seed.php)
bills lawn seed is better then gary's......
Lawn Seed - (links to main page lawn_seed.php)
listing of lawn seed products and company's.....
So a user would click on the link (title) and it would take them to the page?
Hope i make sense, I dont even know where to start with this! lol
Thanks for the response, that is close, but what i need is maybe the headings of each result to link to their related page.
So for example:
Gary's Lawn Seed - (this to link to garys_lawn_seed.php)
gary stocks a wide range of lawn seed.....
Bills Lawn Seed - (this to link to bill_lawn_seed.php)
bills lawn seed is better then gary's......
Lawn Seed - (links to main page lawn_seed.php)
listing of lawn seed products and company's.....
So a user would click on the link (title) and it would take them to the page?
Hope i make sense, I dont even know where to start with this! lol
-
Tarquinius999
- Forum Newbie
- Posts: 2
- Joined: Mon Jul 02, 2007 8:32 am
Code: Select all
<?php
$link = 'http://www.somesite.com';
$link_desc = 'Click here to visit site';
?>
<a href="<?php echo $link?>"><?php echo $link_desc ?></a>Code: Select all
$get_data = @mysql_query("SELECT * FROM tbl_users ORDER BY `id` ASC");
while($data=mysql_fetch_array($data))
{
$link = $data['users_link'];
$link_title = $data['users_link_title'];
echo "<a href=\"".$link."\">".$link_title."</a><br>";
}in the $data[' '] just enter your column name for each variable. and assuming you know mysql, change your query to match your table
Where would I place the link code?
Would I create another column in my database with the .php file link?
Sorry to be a pain, but I have search for tutorials everywhere. Also if you had a moment could you note what the code you posted is doing so i can understand a bit better?
Thank you so much for your time.
Would I create another column in my database with the .php file link?
Sorry to be a pain, but I have search for tutorials everywhere. Also if you had a moment could you note what the code you posted is doing so i can understand a bit better?
Thank you so much for your time.
Last edited by rach99 on Wed Jul 11, 2007 5:21 am, edited 1 time in total.
So do i just add for example
lawn_seed.php under a 'links' column?
or the full address where the website is upload like http://www.lawnseed.com.au/lawn_advertiser1.php?
Also where is the above link code meant to be placed in my code?
Thanks
Rachael
lawn_seed.php under a 'links' column?
or the full address where the website is upload like http://www.lawnseed.com.au/lawn_advertiser1.php?
Also where is the above link code meant to be placed in my code?
Thanks
Rachael
- Gente
- Forum Contributor
- Posts: 252
- Joined: Wed Jun 13, 2007 9:43 am
- Location: Ukraine, Kharkov
- Contact:
First one.rach99 wrote:So do i just add for example
lawn_seed.php under a 'links' column?
or the full address where the website is upload like http://www.lawnseed.com.au/lawn_advertiser1.php?
The place where you want to see itrach99 wrote: Also where is the above link code meant to be placed in my code?
Code: Select all
$get_data = @mysql_query("SELECT * FROM tbl_users ORDER BY `id` ASC");
while($data=mysql_fetch_array($data))
{
$link = $data['users_link'];
$link_title = $data['users_link_title'];
echo "<a href=\"".$link."\">".$link_title."</a><br>";
}And where do i place this piece of code in the php code i posted above that I have? And do i need to remove any code which conflicts with this? Also do i need to add the top bit of the php that was first posted by boo with the one I just asked about in this post?
Thank you very much for you help so far, and your patience.
I am having so much trouble getting this part of it to work!
I have been working on this and going through tutorials for 2 weeks, I am trying to learn php & mysql I am not just after people to fix my code as I respect the fact that people take the time on forums to help others out for nothing.
I didnt want the answer so to speak, the code doesnt mean much at all to me that was posted, I was just after a tutorial or explaination of how to link my results to individual php pages like how google shows results and has links that follow off to different pages. Even just what i should be looking for, for example should i be reading up on array and query statements etc. (I wanted more of an understanding so to speak)
thanks to everyone who helped me out so far, I do apologise if I have given the impression I am just here for people to do my work for me.
Goodluck with the forums
I didnt want the answer so to speak, the code doesnt mean much at all to me that was posted, I was just after a tutorial or explaination of how to link my results to individual php pages like how google shows results and has links that follow off to different pages. Even just what i should be looking for, for example should i be reading up on array and query statements etc. (I wanted more of an understanding so to speak)
thanks to everyone who helped me out so far, I do apologise if I have given the impression I am just here for people to do my work for me.
Goodluck with the forums