If I choose to retrieve some MySQL data using PHP, how do I put it in a certain area of my page? For example, if there is a div with an id of "putTextHere", how to make PHP echo/put text in this div? And how to get a certain value from MySQL? If there is a column named 'Name' and another one named 'Age', how to retrieve only the value of Name?
jackbauer24-2
0
Light Poster
Recommended Answers
Jump to Posthttp://www.w3schools.com/php/php_mysql_select.asp
look at this, try your code and then tell your problem
Jump to PostIn a nutshell:
// connect to a database (mysql in this example, using mysqli extension) $link = mysqli_connect('localhost', 'my_user', 'my_password', 'my_db'); // check connection if (mysqli_connect_errno()) { die("Connect failed: " . mysqli_connect_error()); } // a query for selecting age $query = 'SELECT Age FROM tablename WHERE condition=something'; …
Jump to PostOK, clashed with Utrivedi's post which directs you to the same concept. I would only recomend using mysqli extension instead of mysql since the former is newer and offers more functionalities. Anyway, the approach is the same in both posts.
Jump to PostAlso have a look at the example here. You can se the process of connecting to db, querying and fetching rows in both procedural and object oriented ways. At some stage it is …
Jump to Postwhat you asking is called embeding, simple php or simple html can not work alone
see sample embeded code here. this page must be named with extenstion .php
<html> <?php //some php processing, it could be anythingin php, may be database fetch or vriables $myname="hello"; $myaddress="someplace"; ?> …
All 20 Replies
urtrivedi
276
Nearly a Posting Virtuoso
broj1
356
Humble servant
Featured Poster
broj1
356
Humble servant
Featured Poster
broj1
356
Humble servant
Featured Poster
jackbauer24-2
0
Light Poster
jackbauer24-2
0
Light Poster
urtrivedi
276
Nearly a Posting Virtuoso
broj1
356
Humble servant
Featured Poster
jackbauer24-2
0
Light Poster
pritaeas
2,194
¯\_(ツ)_/¯
Moderator
Featured Poster
broj1
356
Humble servant
Featured Poster
jackbauer24-2
0
Light Poster
broj1
356
Humble servant
Featured Poster
jackbauer24-2
0
Light Poster
broj1
356
Humble servant
Featured Poster
jackbauer24-2
0
Light Poster
broj1
356
Humble servant
Featured Poster
broj1
356
Humble servant
Featured Poster
broj1
356
Humble servant
Featured Poster
jackbauer24-2
0
Light Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.