₦airaland Forum

Welcome, Guest: Register • Login • With Google • Trending • Recent • New

Stats: 3,344,453 members, 8,511,982 topics. Date: Monday, 02 November 2026 at 03:40 PM

Toggle theme

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 (7116 Views)

1 Reply (Go Down)

Php/mysql Help:how To Run Sql Query From A Link by GoodMuyis(op): 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(op): 11:18am On Oct 08, 2011
[quote author=dell_net link=topic=777137.msg9295020#msg9295020 date=1318008052]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."'";[/quote]
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(op): 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] huh?

where did you get with it?
Re: Php/mysql Help:how To Run Sql Query From A Link by GoodMuyis(op): 10:59am On Oct 11, 2011
[quote author=dell_net link=topic=777137.msg9302755#msg9302755 date=1318132057]<a href='updateEntry.php?edit=$getReport[studentID] huh?

where did you get with it?[/quote]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

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

Android Code Competition For Nigerian Developers - The result is out • Nairaland Programmers That Share Language And City In Common • Have Never Heard About HACKING, Dont We Have Serious HACKERS ?