Author |
Message |
Bigboy177
Worker


Joined: Jul 07, 2004
Posts: 192
|
Posted:
Tue Aug 03, 2004 1:30 pm |
|
I'm making a module... I've got some problems... I hope someone will help...
1. Why isn't this working...
Code:
$result5 = $db->sql_query("SELECT title, tid FROM ".$prefix."_reviews where title='$mypage[title]' AND eid='3'");
$row5 = $db->sql_fetchrow($result5);
$solucja = $row5['title'];
$stid = $row5['tid'];
echo "<br><b>Tipsy:</b><br> ";
echo "<a href=modules.php?name=Encyclopedia&op=content&tid=$stid><font color=yellow><strong><big>·</big></strong>$solucja</font></a>";
|
It's working when I cut out the AND eid='3' part... But I want to work with it...
2. How to make a loop... I've got this code above...
And I want it to show all the things from the table that are right according to the querry...
3. The querry above compares the titles from two tables... But it won't work if the titles are a bit different for example... It won't work if one Title is DOOM 3 and the other title is DOOM3 (PC)... Can I somehow do a querry that will work with similar titles...
Please help... I'm trying to do it for hours... Please help... |
Last edited by Bigboy177 on Tue Aug 03, 2004 3:11 pm; edited 1 time in total |
|
|
 |
sixonetonoffun
Spouse Contemplates Divorce

Joined: Jan 02, 2003
Posts: 2496
|
Posted:
Tue Aug 03, 2004 2:20 pm |
|
You'll want to read up on MySQL joins if its from 2 tables. You could also try using LIKE to find close matches. Something like this:
where title like '%$mypage[title]%' |
_________________ [b][size=5]openSUSE 11.4-x86 | Linux 2.6.37.1-1.2desktop i686 | KDE: 4.6.41>=4.7 | XFCE 4.8 | AMD Athlon(tm) XP 3000+ | MSI K7N2 Delta-L | 3GB Black Diamond DDR
| GeForce 6200@433Mhz 512MB | Xorg 1.9.3 | NVIDIA 270.30[/size:2b8 |
|
|
 |
Raven
Site Admin/Owner

Joined: Aug 27, 2002
Posts: 17088
|
Posted:
Tue Aug 03, 2004 2:40 pm |
|
For the title compare, you might want to explore the soundex() function. Something likeCode:"SELECT * FROM table1 t1, table2 t2 WHERE soundex(t1.title) = soundex(t2.title)";
|
You could also use the substr() function to only compare the first 4 or 5 bytes of each title or even wrap the soundex() in a substr(). |
|
|
|
 |
Bigboy177

|
Posted:
Tue Aug 03, 2004 2:51 pm |
|
But what about, the loops... and what about the code... Why doesn't it work... |
|
|
|
 |
Raven

|
Posted:
Tue Aug 03, 2004 3:21 pm |
|
Well, on the #1, you are asking for eid = '3'. i don't find a column like that (eid), however there is a TID. |
|
|
|
 |
Bigboy177

|
Posted:
Tue Aug 03, 2004 3:28 pm |
|
I would like to ask for $title and $tid from the line:
in which the $title='$mypage[title]' and the $eid value is 3... I don't want to see lines in which eid=2 or eid=5 just eid=3... |
|
|
|
 |
Raven

|
Posted:
Tue Aug 03, 2004 3:29 pm |
|
But there is no column called EID on that table. |
|
|
|
 |
Bigboy177

|
Posted:
Tue Aug 03, 2004 3:46 pm |
|
Ups... I overlooked that... Thanks Raven... It's supposed to be an other table...
I've got another question...
I want to make a button...
I've put this code into the module... But the page doesn't show at all after adding it... Not after I press the button... but while loading the page with button...
The button code:
Code:
echo "<input type=\"hidden\" name=\"pa\" value=\"vote\">
<input type=\"submit\" value=\"Głosuj\">
|
Than the function:
Code:
function vote($scoreusr, $votes){
include ('header.php');
OpenTable();
$db->sql_query("UPDATE ".$prefix."_score_user SET scoreusr=scoreusr+".$scoreuser."");
echo "<b>Dziękujemy za twój głos...</b>"
CloseTable();
include("footer.php");
}
|
And the case...
Code:
case "vote":
vote($scoreusr, $votes);
break;
|
Maybe you will be able to help... I don't know where the mistake is...  |
|
|
|
 |
Raven

|
Posted:
Tue Aug 03, 2004 3:52 pm |
|
Not sure just what you're after here, but you have " w/i " which is causing it to die. Try this ("UPDATE ".$prefix."_score_user SET scoreusr=(scoreusr+'$scoreuser'"); |
|
|
|
 |
antinportugal
Hangin' Around

Joined: Feb 24, 2004
Posts: 31
|
Posted:
Tue Aug 03, 2004 4:09 pm |
|
ignore this post: by the time i had posted my reponse the topic had aleady moved on i would have deleted it if allowed that option
if I make a squeak here
i think the eid is referring to a column in the encyclopedia table (nuke_encyclopedia) , sixonetonoffun has already mentioned above about joining tables so I will say no more apart from : Bigboy177 what module are you trying to make? |
Last edited by antinportugal on Tue Aug 03, 2004 4:26 pm; edited 1 time in total |
|
|
 |
Bigboy177

|
Posted:
Tue Aug 03, 2004 4:18 pm |
|
I'm making a module that will display related stuff on My site... When I select a name, from the list... It'll display everything that is related... |
|
|
|
 |
Bigboy177

|
Posted:
Tue Aug 03, 2004 4:29 pm |
|
The Module is now working... Thanks Raven... But the button isn't...
Maybe you can suggest the code I could use... to make a button, to run a specific function... |
|
|
|
 |
Raven

|
Posted:
Tue Aug 03, 2004 6:23 pm |
|
<input type="button" onClick="doSomething()"> |
|
|
|
 |
Bigboy177

|
Posted:
Wed Aug 04, 2004 5:43 am |
|
Raven wrote: | <input type="button" onClick="doSomething()"> |
So what should I put instead of "doSomething()" to call a function preview_baza in that module... |
|
|
|
 |
Raven

|
Posted:
Wed Aug 04, 2004 5:46 am |
|
|
|
 |
Bigboy177

|
Posted:
Wed Aug 04, 2004 5:55 am |
|
So how should the whole button code look like...
With the name... Bacuse I inserted something like this...
Code:
echo "<input type="button" onClick="preview_baza()" value=\"Podgląd\">"
."</form>";[/b]
|
And now the page won't load...  |
|
|
|
 |
Bigboy177

|
Posted:
Wed Aug 04, 2004 6:00 am |
|
OK. I fixed the button... But when I press on it... nothing happens...  |
|
|
|
 |
Bigboy177

|
Posted:
Wed Aug 04, 2004 6:10 am |
|
I've got two buttons... Maybe it's because of that...
This is how the buttons code looks like...
Code:
echo "<input type=\"submit\" value=\"Submit\">"
."</form>";
echo "<input type=\"button\" onClick=\"preview_baza()\" value=\"Preview\">";
|
The first button is working... But the second isn't...
Please help... I've been trying to fix this for so long now...  |
|
|
|
 |
Raven

|
Posted:
Wed Aug 04, 2004 6:20 am |
|
First of all you need to place all form elements inside of the <form> </form> tags. Try that and see if that helps. |
|
|
|
 |
Bigboy177

|
Posted:
Wed Aug 04, 2004 6:35 am |
|
Still nothing... The first button is working... the second isn't...
Maybe I need to define these button somewhere... |
|
|
|
 |
Raven

|
Posted:
Wed Aug 04, 2004 6:44 am |
|
The syntax is correct. If nothing is happening then I would suspect that your function is not working. |
|
|
|
 |
chatserv
Member Emeritus

Joined: May 02, 2003
Posts: 1389
Location: Puerto Rico
|
Posted:
Wed Aug 04, 2004 6:54 am |
|
Quote: | function vote($scoreusr, $votes){
include ('header.php');
OpenTable();
$db->sql_query("UPDATE ".$prefix."_score_user SET scoreusr=scoreusr+".$scoreuser."");
echo "<b>Dziękujemy za twój głos...</b>" Shouldn't there be a semi-colon in here?
CloseTable();
include("footer.php");
} |
|
|
|
|
 |
Bigboy177

|
Posted:
Wed Aug 04, 2004 7:30 am |
|
Yes it should... this function thu is working OK...
Now I'm trying to modify a Conteudo module... because there's no preview in it...
And i think I won't do it...
I've changed my function to something like this:
Code:
function preview_baza() {
global $prefix, $db, $sitename, $admin, $module_name, $config;
include ('header.php');
OpenTable();
echo "<b><font color=00b7eb><center>Ocena Gry</center></font></b><br><br><hr>";
echo "<center><b>Grafika:</b><br>";
CloseTable();
include("footer.php");
}
|
And it still isn't working... maybe it's because of this line... At the bigning of the function in which I want this button to be:
Code:
echo "<form action=\"modules.php?name=$module_name&file=admin\" method=\"post\">";
|
the [/form] tag is ending right after the first button which is working...
I've opened another <form> tag and closed it after my new button... But I didn't write anything like <form action=....>
Maybe I could post the entire module code... maybe then you will be able to help me... |
|
|
|
 |
sixonetonoffun

|
Posted:
Wed Aug 04, 2004 8:38 am |
|
If you do just upload it and post an url to the file/'s rather then post the whole page here. |
|
|
|
 |
Bigboy177

|
Posted:
Wed Aug 04, 2004 9:08 am |
|
I've finally managed to do this button... And It's working... but when I press it, it displays an empty preview page... everytable is on it's place, but there's no data I've written....
Here is the code that finally worked with the button...
Code:
echo "<form action=\"modules.php?name=$module_name&file=admin\" method=\"post\">";
echo "<br><br><input type=\"submit\" name=\"op\" value=\""._PREVIEW."\"> </form>";
|
I don't know if it's perfectly OK, so I've uploaded the module so you can check it for me if you have time... I think it's not so hard to do... But I'm a total noob... so I can't figure out what's wrong... why doesn't it show the preview contents...
Only registered users can see links on this board! Get registered or login!
Please Help Me... I think it's not too hard to fix it... But I don't know PHP that well... |
|
|
|
 |
|