PDA

View Full Version : <%fields%>


Payless
07-22-2003, 11:19 AM
Hi,

I am quite new to mysql/php.

My question is how to use this kind of syntax in php pages (mysql queries): fx: <%fields%>

I have a database table called 'clients' with the following fields:

name
description
photo
thumb
--------
I would like to put these fields into a php-table/template:

<table width="400" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<%name%>
</td>
</tr>
<tr>
<td>
<%thumb%>
<br>
<a href="<%name%>.php" target="_blank">View big version</a> </td>
</tr>
<tr>
<td>
<%description%>
</td>
</tr>
</table>


the photo field <%photo%> will be used on the page "<%name%>.php"

Any suggestions as to how I can obtain such a function?

Best regards
Jens

mordred
07-22-2003, 12:10 PM
I didn't quite understand what your question aims at. Do you need help writing the SQL query, sending the query from PHP or obtaining PHP variables from the SQL result set? Or all three?

Your query might look like that:


SELECT
name
description
photo
thumb
FROM
tableName
WHERE
photoId = $id


assuming your records have an ID field which can be used as a primary ID. You send this query with mysql_query() and can extract an associative array with mysql_fetch_assoc() from it. Like


$result = mysql_query($sql);
if ($result) {
$row = mysql_fetch_assoc($result);
print $row['description'];
} else {
print mysql_error();
}


Does that help?