Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> PHP
Author Message
Bigboy177
Worker
Worker



Joined: Jul 07, 2004
Posts: 192

PostPosted: Tue Aug 03, 2004 1:30 pm Reply with quote

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>&middot;</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 
View user's profile Send private message
sixonetonoffun
Spouse Contemplates Divorce



Joined: Jan 02, 2003
Posts: 2496

PostPosted: Tue Aug 03, 2004 2:20 pm Reply with quote

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 
View user's profile Send private message
Raven
Site Admin/Owner



Joined: Aug 27, 2002
Posts: 17088

PostPosted: Tue Aug 03, 2004 2:40 pm Reply with quote

For the title compare, you might want to explore the soundex() function. Something like
Code:
"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().
 
View user's profile Send private message
Bigboy177







PostPosted: Tue Aug 03, 2004 2:51 pm Reply with quote

But what about, the loops... and what about the code... Why doesn't it work...
 
Raven







PostPosted: Tue Aug 03, 2004 3:21 pm Reply with quote

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







PostPosted: Tue Aug 03, 2004 3:28 pm Reply with quote

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







PostPosted: Tue Aug 03, 2004 3:29 pm Reply with quote

But there is no column called EID on that table.
 
Bigboy177







PostPosted: Tue Aug 03, 2004 3:46 pm Reply with quote

Ups... I overlooked that... Thanks Raven... It's supposed to be an other table... Bang Head

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... Sad
 
Raven







PostPosted: Tue Aug 03, 2004 3:52 pm Reply with quote

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

PostPosted: Tue Aug 03, 2004 4:09 pm Reply with quote

ignore this post: by the time i had posted my reponse the topic had aleady moved on Cool i would have deleted it if allowed that option Laughing

if I make a squeak here Smile

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 Smile 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 
View user's profile Send private message Send e-mail
Bigboy177







PostPosted: Tue Aug 03, 2004 4:18 pm Reply with quote

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







PostPosted: Tue Aug 03, 2004 4:29 pm Reply with quote

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







PostPosted: Tue Aug 03, 2004 6:23 pm Reply with quote

<input type="button" onClick="doSomething()">
 
Bigboy177







PostPosted: Wed Aug 04, 2004 5:43 am Reply with quote

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







PostPosted: Wed Aug 04, 2004 5:46 am Reply with quote

preview_baza()
 
Bigboy177







PostPosted: Wed Aug 04, 2004 5:55 am Reply with quote

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... Sad
 
Bigboy177







PostPosted: Wed Aug 04, 2004 6:00 am Reply with quote

OK. I fixed the button... But when I press on it... nothing happens... Sad
 
Bigboy177







PostPosted: Wed Aug 04, 2004 6:10 am Reply with quote

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... Sad
Please help... I've been trying to fix this for so long now... Sad
 
Raven







PostPosted: Wed Aug 04, 2004 6:20 am Reply with quote

First of all you need to place all form elements inside of the <form> </form> tags. Try that and see if that helps.
 
Bigboy177







PostPosted: Wed Aug 04, 2004 6:35 am Reply with quote

Still nothing... The first button is working... the second isn't... Sad
Maybe I need to define these button somewhere...
 
Raven







PostPosted: Wed Aug 04, 2004 6:44 am Reply with quote

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

PostPosted: Wed Aug 04, 2004 6:54 am Reply with quote

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");
}
 
View user's profile Send private message Visit poster's website
Bigboy177







PostPosted: Wed Aug 04, 2004 7:30 am Reply with quote

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&amp;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







PostPosted: Wed Aug 04, 2004 8:38 am Reply with quote

If you do just upload it and post an url to the file/'s rather then post the whole page here.
 
Bigboy177







PostPosted: Wed Aug 04, 2004 9:08 am Reply with quote

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&amp;file=admin\" method=\"post\">";
    echo "<br><br><input type=\"submit\" name=\"op\" value=\""._PREVIEW."\">&nbsp;&nbsp;</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...
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> PHP

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©