Author Topic: [MySQL] what if ?  (Read 4529 times)

0 Members and 1 Guest are viewing this topic.

Offline abdoh2010

  • Jr. Member
  • **
  • Posts: 96
    • View Profile
    • Racing 4 Education
[MySQL] what if ?
« on: April 04, 2005, 03:20:04 PM »
Hello guys

I have a problem and I need your help

I have a script witch I am trying to integrate it with 4images
The template part is solve ok but the query part is the problem that I am talking about

If I have a query and I want to insert it in a file call it test.php and give this query a variable to call it from test.html template

How can I do it? That's the question

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: [MySQL] what if ?
« Reply #1 on: April 04, 2005, 11:52:12 PM »
1) u can not execute any php code from .html files (unless your server configured so)
2) your question is not very clear...u have a database query? and u want execute it outside of 4images? then what?
The entire question is little fussy ;)
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline abdoh2010

  • Jr. Member
  • **
  • Posts: 96
    • View Profile
    • Racing 4 Education
Re: [MySQL] what if ?
« Reply #2 on: April 05, 2005, 01:32:34 AM »
ok no problem

this is the code that i am work on

Code: [Select]
<?php
$query
=mysql_query("SELECT * FROM topics WHERE $topic=id");
while(
$result=mysql_fetch_array($query)){
?>

<table border="0" cellpadding="2" cellspacing="1" width="100%" bgcolor="#969696">
<tr>
<td align="center" width="100%" bgcolor="#969696">
<p align="center"><font color="#FFFFFF">
<?php echo $result[name?>
</font></p>
</td>
</tr>
<tr>
<td align="center" width="100%" bgcolor="#EBEBEB">
<p align="justify"><font color="#416496">
<?php echo $result[description?>
</font></p>
</td>
</tr>
</table>
<?php
}
$query=mysql_query("SELECT * FROM topics WHERE $topic=place ORDER BY id DESC");
while(
$result=mysql_fetch_array($query)){
?>

<br>
<table border="0" cellpadding="2" cellspacing="1" width="100%" bgcolor="#969696">
<tr>
<td align="center" width="100%" bgcolor="#EBEBEB">
<p align="center"><font color="#416496">
<a href="topic.php?topic=<?php echo $result[id?>"><?php echo $result[name?></a>
</font></p>
</td>
</tr>
</table>
<?php
}
?>

<br>
<table border="0" cellpadding="2" cellspacing="1" width="100%" bgcolor="#969696">
<tr>
<td align="center" bgcolor="#969696">
<p align="center"><font color="#FFFFFF">
title
</font></p>
</td>
<td align="center" width="100" bgcolor="#969696">
<p align="center"><font color="#FFFFFF">
writer
</font></p>
</td>
<td align="center" width="100" bgcolor="#969696">
<p align="center"><font color="#FFFFFF">
date of add
</font></p>
</td>
<td align="center" width="50" bgcolor="#969696">
<p align="center"><font color="#FFFFFF">
vist
</font></p>
</td>
</tr>
<?php
$numresults
=mysql_query("SELECT * FROM articles WHERE topic=$topic ORDER BY id DESC");
$numrows=mysql_num_rows($numresults);
if(empty(
$page)){
$page=0;
}
$result=mysql_query("SELECT * FROM articles WHERE topic=$topic ORDER BY id DESC limit $page,$limit");
while(
$data=mysql_fetch_array($result)){
?>

<tr>
<td align="center" bgcolor="#EBEBEB">
<p align="justify"><font color="#416496">
<a href="topic.php?id=<?php echo $data[id?>"><?php echo $data[subject?></a>
</font></p>
</td>
<td align="center" width="100" bgcolor="#EBEBEB">
<p align="center"><font color="#416496">
<?php echo $data[writer?>
</font></p>
</td>
<td align="center" width="100" bgcolor="#EBEBEB">
<p align="center"><font color="#416496">
<?php echo $data[date?>
</font></p>
</td>
<td align="center" width="50" bgcolor="#EBEBEB">
<p align="center"><font color="#416496">
<?php echo $data[counter?>
</font></p>
</td>
</tr>
<?php
}
?>

</table><br> pages :
<?php
$pages
=intval($numrows/$limit);
if(
$numrows%$limit){
$pages++;
}
for(
$i=1;$i<=$pages;$i++){
$newpage=$limit*($i-1);
echo
"( <a href='topic.php?topic=$topic&page=$newpage'>$i</a> ) ";
}
?>


so as you see it is mix of php and templete and i want to make it part of my 4images

the first step is to splet the code into two parts
the templete part and that is easy
and the php & mysql part and that is also easy

but the problem is how to make it work by 4images rules