Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,153,490 members, 7,819,781 topics. Date: Monday, 06 May 2024 at 11:08 PM

Php/mysql Help:how To Run Sql Query From A Link - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Php/mysql Help:how To Run Sql Query From A Link (6878 Views)

How To Make a DESKTOP Executable Software Using PHP,MYSQL,SQLITE / Urgent Help On Sparql Query Ontology / Trying To Run Php Project After Installing Wamp Server (2) (3) (4)

(1) (Reply) (Go Down)

Php/mysql Help:how To Run Sql Query From A Link by GoodMuyis(m): 5:44pm On Oct 07, 2011
Hello friend I need some help on How i canĀ  Execute sql query from a link as in :
 
<a>Edit</a>


Where the link will point to PHP file and at end echo[/b]some stuff out
please attach some cash of code to your answer to help me much while i keep Goooogling

What i really want to do is display row of result like below

Name | ID |
==================
Shola |256 | Edit
John | 128 |Edi

Here Edit will be a link [b]<a>Edit</a>
to a PHP page
Where the result will be handle by html form, Which Am sure i can handle
Regards
Re: Php/mysql Help:how To Run Sql Query From A Link by dellnet: 6:20pm On Oct 07, 2011
You can pass querystring to your php file. For example you <a href="http://example.com/phpfile.php?q=shola">click here to get shola's id</a>

in the php file you do

$query_from_a = $_REQUEST['q'];

$sqlquery= "SELECT ID FROM table_name WHERE Name='".$query_from_a."'";
Re: Php/mysql Help:how To Run Sql Query From A Link by Mobinga: 1:25am On Oct 08, 2011
Re: Php/mysql Help:how To Run Sql Query From A Link by GoodMuyis(m): 11:18am On Oct 08, 2011
dell_net:

You can pass querystring to your php file. For example you <a href="http://example.com/phpfile.php?q=shola">click here to get shola's id</a>

in the php file you do

$query_from_a = $_REQUEST['q'];

$sqlquery= "SELECT ID FROM table_name WHERE Name='".$query_from_a."'";

Mobinga:

http://goodmuyis.com/profile?get=lols

Use the $_GET array!!
Thank You guys for the help all work well my Own code below


<a href='updateEntry.php?edit=$getReport[studentID]
,
$request = $_REQUEST['edit'];

$sql = mysql_query("SELECT *FROM student, accomodation, class, guardian,passport WHERE student.studentID=$request\n"
. "AND accomodation.accomodationID=$request\n"
. "AND class.classID=$request\n"
. "AND guardian.guardianID=$request\n"
. "AND passport.passportID=$request\n"
. "LIMIT 1"wink;
Re: Php/mysql Help:how To Run Sql Query From A Link by Mobinga: 11:49am On Oct 08, 2011
Be careful, always use mysqli_real_escape_string(); to escape your data.

Somebody can just do this goodmuyis.com/mysql.php?q=DROP%20DB;
Re: Php/mysql Help:how To Run Sql Query From A Link by GoodMuyis(m): 2:57pm On Oct 08, 2011
Mobinga:

Be careful, always use mysqli_real_escape_string(); to escape your data.

Somebody can just do this goodmuyis.com/mysql.php?q=DROP%20DB;
Yea thank you i won't play with that, even thought i don;t care much about the project
Re: Php/mysql Help:how To Run Sql Query From A Link by dellnet: 4:47am On Oct 09, 2011
<a href='updateEntry.php?edit=$getReport[studentID] ?

where did you get with it?
Re: Php/mysql Help:how To Run Sql Query From A Link by GoodMuyis(m): 10:59am On Oct 11, 2011
dell_net:

<a href='updateEntry.php?edit=$getReport[studentID] ?

where did you get with it?

The above is from my project Code file although written badly


Pls Guys is OK to do SQL Query(MySQL) like this from PHP although i have not tried it "

$search = $_POST['search'];

$sql = "SELECT FROM one, two, three WHERE one.ID=$search OR two.ID=$search or three.ID=$search"
Re: Php/mysql Help:how To Run Sql Query From A Link by dellnet: 1:44pm On Oct 11, 2011
GoodMuyis:

The above is from my project Code file although written badly


Pls Guys is OK to do SQL Query(MySQL) like this from PHP although i have not tried it "

$search = $_POST['search'];

$sql = "SELECT FROM one, two, three WHERE one.ID=$search OR two.ID=$search or three.ID=$search"


Be wary of security issues if you are deploying it to the internet.

(1) (Reply)

Python Tutorial Group / How Was Nairaland Able To Achieve Its Speed / My Journey To Programming

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 17
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.