Web design help : im stumped for once lol - HotUKDeals
We use cookie files to improve site functionality and personalisation. By continuing to use HotUKDeals, you accept our cookie and privacy policy.
Get the HotUKDeals app free at Google Play

Search Error

An error occurred when searching, please try again!

Login / Sign UpSubmit

Web design help : im stumped for once lol

£0.00 @
ok im inserting data into a database that anyone can view using the search function i built on, but i have no idea how to make the data (gonna be links to websites) clickable links/ e,g, basicall…
faevilangel Avatar
8y, 3m agoPosted 8 years, 3 months ago
ok im inserting data into a database that anyone can view using the search function i built on, but i have no idea how to make the data (gonna be links to websites) clickable links/


e,g, basically its a more subtle version of google Lol

lot more basic for time being
faevilangel Avatar
8y, 3m agoPosted 8 years, 3 months ago
Options

All Comments

(17) Jump to unreadPost a comment
Comments/page:
#1
same way you make anything a clickable link...

Link text

replacing linkUrl and link text with the data from your database.
#2
chrishill
same way you make anything a clickable link...

Link text

replacing linkUrl and link text with the data from your database.


i tried that and got a mysql error ..... thats the first thing i tried :lol:

unless im using the wrong data type ...... im using varchar :|
banned#3
Is it the movie Passenger 57 starring Hollywood's Wesley Snipes?
#4
What scripting language are you using?

If you're using php then you'll need this: http://uk.php.net/mysql_real_escape_string
#5
faevilangel;3835888
i tried that and got a mysql error ..... thats the first thing i tried :lol:

unless im using the wrong data type ...... im using varchar :|


Datatype probably won't make any difference, although I'd use 'text' since its possible your URL's or page descriptions could run to longer than 255 characters (varchar's limit).

A mySQL error probably means theres an issue with your SQL statement rather than the HTML.

This won't fix it for you since its mostly pseudo code, but it should give you some hints. I've also added comments.


$query = "SELECT * FROM tableName WHERE columnName LIKE 'string';"; // this tells the database to go off and find all rows in the specified table where the data in the specified column matches the string, so it could be WHERE id LIKE '1' or WHERE name LIKE 'Tarquin'.

$result = mysql_query($query)
or die ("couldnt execute query".mysql_error()); //send the query to the dB and put the results in a variable called '$result' or return an error if theres a problem

while ($row = mysql_fetch_array($result)) // while $result contains data (ie, while the dB is returning data from the query) do the following
{
$linkList_HTML = "url'])."'>".html_entity_decode($row['linkText'])."
";
}

// this last bit creates a string which contains the html for links with the results from the dB in the relivant places. The html_entity_decode bit is worth remembering since whenever you put data in to a dB you really need to encode it to convert all special symbols in to their HTML equivalent codes (such as & becoming &). html_entity_decode reverses this encoding.

// finally...

echo $linkList_HTML; //shows the list of links on screen.
#6
megalomaniac;3835981
What scripting language are you using?

If you're using php then you'll need this: http://uk.php.net/mysql_real_escape_string


thats for inserting data.
banned#7
chrishill;3842084
Datatype probably won't make any difference, although I'd use 'text' since its possible your URL's or page descriptions could run to longer than 255 characters (varchar's limit).

A mySQL error probably means theres an issue with your SQL statement rather than the HTML.

This won't fix it for you since its mostly pseudo code, but it should give you some hints. I've also added comments.


$query = "SELECT * FROM tableName WHERE columnName LIKE 'string';"; // this tells the database to go off and find all rows in the specified table where the data in the specified column matches the string, so it could be WHERE id LIKE '1' or WHERE name LIKE 'Tarquin'.

$result = mysql_query($query)
or die ("couldnt execute query".mysql_error()); //send the query to the dB and put the results in a variable called '$result' or return an error if theres a problem

while ($row = mysql_fetch_array($result)) // while $result contains data (ie, while the dB is returning data from the query) do the following
{
$linkList_HTML = "url'])."'>".html_entity_decode($row['linkText'])."
";
}

// this last bit creates a string which contains the html for links with the results from the dB in the relivant places. The html_entity_decode bit is worth remembering since whenever you put data in to a dB you really need to encode it to convert all special symbols in to their HTML equivalent codes (such as & becoming &). html_entity_decode reverses this encoding.

// finally...

echo $linkList_HTML; //shows the list of links on screen.

I think you mean = rather than LIKE

LIKE is for pattern matching (e.g columname LIKE 'TAR%', columname LIKE 'TAR_UIN' )

Use IN for list value matches and use BETWEEN for a range. :thumbsup:
#8
chrishill
thats for inserting data.


From the OP: "ok im inserting data into a database " :whistling:
#9
How about showing us some of the code?
#10
megalomaniac;3842196
From the OP: "ok im inserting data into a database " :whistling:


Hes wanting to turn the data in to clickable links, which should be done at the output stage.

csiman;3842160
I think you mean = rather than LIKE

LIKE is for pattern matching (e.g columname LIKE 'TAR%', columname LIKE 'TAR_UIN' )

Use IN for list value matches and use BETWEEN for a range. :thumbsup:


nope, i mean 'LIKE'. Most mysql/php tutorials you see will give you statements using LIKE unless you explicitly go looking for ones that use 'IN'.

Lets not start waving our coding willys though eh? its not going to help faevilangel.
banned#11
chrishill;3842437
Hes wanting to turn the data in to clickable links, which should be done at the output stage.



nope, i mean 'LIKE'. Most mysql/php tutorials you see will give you statements using LIKE unless you explicitly go looking for ones that use 'IN'.

Lets not start waving our coding willys though eh? its not going to help faevilangel.

then the tutorials are lazy as its inefficient to use LIKE when you explicitly know the search variable
#12
csiman;3842487
then the tutorials are lazy as its inefficient to use LIKE when you explicitly know the search variable


its debatable if the search variable is a known element in this instance. I doubt it, since the op suggested search engine functionality which would, IMO, constitute a need for pattern matching rather than exact string matching.
banned#13
chrishill;3842656
its debatable if the search variable is a known element in this instance. I doubt it, since the op suggested search engine functionality which would, IMO, constitute a need for pattern matching rather than exact string matching.

yes, I take your point although the example you gave had a fixed constant.

Damn! Feel like I'm back at work. Used to be a cobol/db2 programmer for 25 years until technology overtook my skillset (and my age lol) ;-)
#14
chrishill
its debatable if the search variable is a known element in this instance. I doubt it, since the op suggested search engine functionality which would, IMO, constitute a need for pattern matching rather than exact string matching.


You're right, LIKE isn't particularly powerful though, by the sounds of what he's trying to do regular expressions are much more suitable.
#15
thanks for the info chris .......... im normally pretty dandy with sql but this stumped me :lol: didnt think it would be that simple :w00t:

basically the idea is an ajax search engine, which the user can add links to the database (its a small scale for a website by itself (not a full on search engine (yet))

i really did think i may have to use some php coding to make the data from the db, be outputted as a link, darn me for thinking beynd the lines :lol:

i will change my data type to text to see if that solves the problem :)
#16
csiman;3842956
yes, I take your point although the example you gave had a fixed constant.

Damn! Feel like I'm back at work. Used to be a cobol/db2 programmer for 25 years until technology overtook my skillset (and my age lol) ;-)


;-) you'll have to excuse my hasty early morning sloppy code for that. I'd imagine theres still a call for people who can code complex sql is there not? My skills are purely web-based and self taught over the 10 years I've been doing this and I'd consider myself an amateur with SQL, my complex joins are bl**dy horrible! I really only learn what my job requires me to know, I've no time for anything else at the moment!

megalomaniac;3842963
You're right, LIKE isn't particularly powerful though, by the sounds of what he's trying to do regular expressions are much more suitable.


regex... *shudder* no need to swear ;-) You're right, though I think we're over complicating things for now.

faevilangel;3843068
thanks for the info chris .......... im normally pretty dandy with sql but this stumped me :lol: didnt think it would be that simple

basically the idea is an ajax search engine, which the user can add links to the database (its a small scale for a website by itself (not a full on search engine (yet))

i really did think i may have to use some php coding to make the data from the db, be outputted as a link, darn me for thinking beynd the lines

i will change my data type to text to see if that solves the problem


Personally I'd store the url, page title and a page description in three columns in the dB. Use the SQL query to match the search terms a visitor enters to the page description (and possibly title too) then return the urls. loop through the results and add the html to turn them in to links.

I'm not saying thats the absolute, final, one and only correct way of doing it - google certainly doesn't work that way and it'll require management on your part to create the page descriptions - but for what you're trying to do, thats how I'd do it.

good luck!
#17
chrishill
;-) you'll have to excuse my hasty early morning sloppy code for that. I'd imagine theres still a call for people who can code complex sql is there not? My skills are purely web-based and self taught over the 10 years I've been doing this and I'd consider myself an amateur with SQL, my complex joins are bl**dy horrible! I really only learn what my job requires me to know, I've no time for anything else at the moment!



regex... *shudder* no need to swear ;-) You're right, though I think we're over complicating things for now.



Personally I'd store the url, page title and a page description in three columns in the dB. Use the SQL query to match the search terms a visitor enters to the page description (and possibly title too) then return the urls. loop through the results and add the html to turn them in to links.

I'm not saying thats the absolute, final, one and only correct way of doing it - google certainly doesn't work that way and it'll require management on your part to create the page descriptions - but for what you're trying to do, thats how I'd do it.

good luck!


i was going to make it a basic search for now but add something called the "stemmer" onto the database query in the near future .......

im thinking thats the way to go for the time being ...... just insert the link as html code into the db

Post a Comment

You don't need an account to leave a comment. Just enter your email address. We'll keep it private.

...OR log in with your social account

...OR comment using your social account

Looking for Twitter login?
Thanks for your comment! Keep it up!
We just need to have a quick look and it will be live soon.
The community is happy to hear your opinion! Keep contributing!