Home | Community | Message Board


This site includes paid links. Please support our sponsors.


Welcome to the Shroomery Message Board! You are experiencing a small sample of what the site has to offer. Please login or register to post messages and view our exclusive members-only content. You'll gain access to additional forums, file attachments, board customizations, encrypted private messages, and much more!

Shop: Kraken Kratom Red Vein Kratom   Bridgetown Botanicals CBD Concentrates   PhytoExtractum Kratom Powder for Sale, Maeng Da Thai Kratom Leaf Powder

Jump to first unread post Pages: < Back | 1 | 2 | 3 | Next >  [ show all ]
OfflineGypsy Boy
Redeemer
Male


Registered: 03/17/17
Posts: 4,501
Loc: Deep in the discoteka
Last seen: 2 months, 25 days
Re: Please help me with my website [Re: Gypsy Boy]
    #26655473 - 05/07/20 04:09 PM (3 years, 8 months ago)

Silly lol

I just noticed that as awell :lol:


--------------------





Extras: Filter Print Post Top
OfflineGypsy Boy
Redeemer
Male


Registered: 03/17/17
Posts: 4,501
Loc: Deep in the discoteka
Last seen: 2 months, 25 days
Re: Please help me with my website [Re: Gypsy Boy]
    #26655505 - 05/07/20 04:23 PM (3 years, 8 months ago)

Still need more help dudes:

Tried to customise teaxtarea:

while ($resultarr = mysqli_fetch_assoc($result)){
  $r1 = $resultarr["message"];
  echo "<textarea name="party" cols="70" rows="12" maxlength="750" wrap="soft" class="party">";
  echo $r1;
  echo "\r\n";
  echo "\r\n";
  echo "</textarea>";
  echo "<br>";
  echo "<br>";
}

It gives error: Parse error: syntax error, unexpected '70' (T_LNUMBER), expecting ',' or ';' in C:\wamp64\www\sandbox\html.php on line 26

What do i do :strokebeard:


Ohh and dont worry i will incluid everyone who helped me in about/credits section of my site ! :wink:


--------------------





Extras: Filter Print Post Top
Invisiblestubb
Dahg Rastubfari
 User Gallery


Registered: 03/23/19
Posts: 1,310
Loc: Memory Flag
Re: Please help me with my website [Re: Gypsy Boy]
    #26655522 - 05/07/20 04:32 PM (3 years, 8 months ago)

You gotsta escape those quotation marks around the HTML tag attribute values, else php will interpret them as string terminators:

echo "<textarea name=\"party\" cols=\"70\" rows=\"12\" maxlength=\"750\" wrap=\"soft\" class=\"party\">";


--------------------


Extras: Filter Print Post Top
OfflineGypsy Boy
Redeemer
Male


Registered: 03/17/17
Posts: 4,501
Loc: Deep in the discoteka
Last seen: 2 months, 25 days
Re: Please help me with my website [Re: stubb]
    #26655599 - 05/07/20 05:05 PM (3 years, 8 months ago)

I COULD KISS YOU

5 shrooms :heart:


--------------------





Edited by Gypsy Boy (05/07/20 05:11 PM)


Extras: Filter Print Post Top
Invisiblestubb
Dahg Rastubfari
 User Gallery


Registered: 03/23/19
Posts: 1,310
Loc: Memory Flag
Re: Please help me with my website [Re: Gypsy Boy]
    #26655688 - 05/07/20 06:01 PM (3 years, 8 months ago)

:cheers:

No prob, happy to help!


--------------------


Extras: Filter Print Post Top
OfflineGypsy Boy
Redeemer
Male


Registered: 03/17/17
Posts: 4,501
Loc: Deep in the discoteka
Last seen: 2 months, 25 days
Re: Please help me with my website [Re: stubb] * 1
    #26656677 - 05/08/20 06:04 AM (3 years, 8 months ago)

Well as of this morning, 2/3rds of my website is done.

I am yet to implement anti hacking steps.

I figured id do that after alpha/beta release.

So, i can now post my bulletin items, browse said items, All i need to do now is be able to search thro them , based on a really neat algorithm - post code search - compare 2 post codes and output bulletins which go under a certain amount of miles. :awesome:

A BIG thank you to all who helped.


--------------------





Extras: Filter Print Post Top
OfflineGypsy Boy
Redeemer
Male


Registered: 03/17/17
Posts: 4,501
Loc: Deep in the discoteka
Last seen: 2 months, 25 days
Re: Please help me with my website [Re: Gypsy Boy]
    #26660160 - 05/09/20 02:28 PM (3 years, 8 months ago)

Moving onto the next Step

Last part of my website:

1. Acquire target postcode and distance thro html form

2. Compare given postcode with every postcode in the table

3. Figure out how far post codes are between each other

4. If given post code and database postcode is within given distance

5. Print that row/text area in database where distance is under the limit


I got it all sorted except one thing:

how do I compare given postcode with a post code in the database as there can be any number of rows / postcodes??

If I knew say there 20 rows, I would just use

For(counter =1; counter< 20; counter++)
Compare and Print all 20 boxes/records/row

But there is no fixed number of rows in my table. It can be 20, it can be 2000

Columns In my table There’s :
post_id
Message
Email
Town
Date
Postcode

See what I’m saying? I need to circulate through all postcodes in the table, and there’s no way of knowing how many rows there are. All there is a auto increment post_id column : and every time someone posts a new record post_id gets a unique auto increment number which I use to retrieve and compare postcodes.

Sorry but I tried my best to explain, hope u understand what I’m saying.

I need some kind of algorithm that loops thro post_id column until there no more of them, at which point the loop stops.


--------------------





Extras: Filter Print Post Top
Invisiblestubb
Dahg Rastubfari
 User Gallery


Registered: 03/23/19
Posts: 1,310
Loc: Memory Flag
Re: Please help me with my website [Re: Gypsy Boy]
    #26660314 - 05/09/20 03:59 PM (3 years, 8 months ago)

*** I've confused myself, don't wanna confuse you.  I'll reedit when I get my shit together.  *** :rofldrunk:

You can simply use a while loop:

$result = mysql_query("SELECT * FROM address_table");
while($row = mysql_fetch_array($result)) {
    // compare to $row['postalcode'];
}



Edited by stubb (05/09/20 04:40 PM)


Extras: Filter Print Post Top
OfflineGypsy Boy
Redeemer
Male


Registered: 03/17/17
Posts: 4,501
Loc: Deep in the discoteka
Last seen: 2 months, 25 days
Re: Please help me with my website [Re: stubb]
    #26661682 - 05/10/20 05:58 AM (3 years, 8 months ago)

Did you mean mysqli_query instead of mysql_query??


--------------------





Edited by Gypsy Boy (05/10/20 06:36 AM)


Extras: Filter Print Post Top
OfflineGypsy Boy
Redeemer
Male


Registered: 03/17/17
Posts: 4,501
Loc: Deep in the discoteka
Last seen: 2 months, 25 days
Re: Please help me with my website [Re: Gypsy Boy]
    #26661684 - 05/10/20 05:59 AM (3 years, 8 months ago)

Lets go over this again:



Connect to the database

Start while loop (need help here)

{
compare 2 postcodes

fetch east from HTML form postcode A
fetch north from HTML form postcode A

fetch east from FIRST ROW postcode stored in database
fetch north from FIRST ROW postcode stored in database

Calculate distance between 2 postcodes. (first code from HTML second code from database)

IF (distance is WITHIN specified range)
    {
    print FIRST ROW textarea
    }

} // end of while loop

Seems simple but its not. Because 2nd time the loop runs it needs to be SECOND ROW postcode. And then the loop must end when it reaches last postcode row entry in the database.


--------------------





Edited by Gypsy Boy (05/10/20 06:06 AM)


Extras: Filter Print Post Top
OfflineGypsy Boy
Redeemer
Male


Registered: 03/17/17
Posts: 4,501
Loc: Deep in the discoteka
Last seen: 2 months, 25 days
Re: Please help me with my website [Re: Gypsy Boy]
    #26661704 - 05/10/20 06:16 AM (3 years, 8 months ago)

a word about my database tables:

first table called postcodes - 3 columns: east, north and postcode.

Second table called "posts"

6 columns:
post_id
message
email
date
town
postcode

post_id is primary key and its auto increment.

If you look at database you'll see rows going

post_id  12  postcode "NE3 SUE"
post_id  15  postcode "DD3 8IN"
post_id  20  postcode "Gl53 "ES"

And so on. Theres a gap in post_id - it doesnt go evenly 1 2 3 4 5 , cos some rows need to be deleted - hence the gap.

HOW do i implement post_id into postcode comparison?


--------------------





Extras: Filter Print Post Top
OfflineGypsy Boy
Redeemer
Male


Registered: 03/17/17
Posts: 4,501
Loc: Deep in the discoteka
Last seen: 2 months, 25 days
Re: Please help me with my website [Re: Gypsy Boy]
    #26661731 - 05/10/20 06:34 AM (3 years, 8 months ago)

I tried 2 loops:


One you gave me

Quote:


$sql = ("SELECT post_id FROM posts");
$sqlresult = mysqli_query($dbc, $sql);
while($row = mysqli_fetch_array($sqlresult))





Error:
Object of class mysqli_result could not be converted to string

And one of mine:

Quote:

$sql = ("SELECT post_id FROM posts");
$sqlresult = mysqli_query($dbc, $sql);
$resultarr = mysqli_fetch_assoc($sqlresult);
$resultid = $resultarr["post_id"];
while($resultid)





Produces rogue unlimited loop :shrug:


Dude, i appreciate your help. If you help me thro this i will share some benefits with you :wink:


--------------------





Edited by Gypsy Boy (05/10/20 06:51 AM)


Extras: Filter Print Post Top
OfflineGypsy Boy
Redeemer
Male


Registered: 03/17/17
Posts: 4,501
Loc: Deep in the discoteka
Last seen: 2 months, 25 days
Re: Please help me with my website [Re: Gypsy Boy]
    #26661800 - 05/10/20 07:33 AM (3 years, 8 months ago)

Alright, i seem to be moving somewhere:

First of all, my barebones code works.

For example i fetch postcode stored in post_id 12. And i get my textarea printed.

What i did i used

SELECT COUNT(post_id)
FROM posts

And it gives me number of records in my table.

For example it gives me 3.

All i do is create a count variable and then assign it 3 and run loop 3 times prionting all my 3 posts.

if it was that easy :lol:  Like i said my primary key post_id variable does no abide to number 3. At teh start of table life it went 1 2 3... but some records have been deleted and now it looks like  12, 15, 20 etc..

Get my drift?

How do i implement count that only counts existing post_id rows?


--------------------





Extras: Filter Print Post Top
OfflineGypsy Boy
Redeemer
Male


Registered: 03/17/17
Posts: 4,501
Loc: Deep in the discoteka
Last seen: 2 months, 25 days
Re: Please help me with my website [Re: Gypsy Boy]
    #26661812 - 05/10/20 07:44 AM (3 years, 8 months ago)

NOW we getting somewhere


I used:

Quote:

SELECT post_id
FROM posts
WHERE EXISTS
(SELECT * FROM posts);





And it came up with a valid response:


12

14

15


So as you can see there 3 rows with post_id numbers in them.

Now i need to implement this into my loop somehow.


If i use:

Quote:

$sql = ("SELECT post_id
FROM posts
WHERE EXISTS
(SELECT * FROM posts)");
$result = mysqli_query($dbc, $sql);




Will it store all 3 numbers in $result?

How do i separate them ?


Extras: Filter Print Post Top
Offlinesinglet_oxygen
Stranger
Registered: 05/10/20
Posts: 32
Last seen: 3 years, 6 months
Re: Please help me with my website [Re: Gypsy Boy]
    #26661846 - 05/10/20 08:17 AM (3 years, 8 months ago)

Quote:

Gypsy Boy said:


Will it store all 3 numbers in $result?

How do i separate them ?




Sorry haven't been through all the replies in the thread.

Most people would use this pattern:

Code:

$result = $conn->query("SELECT post_id...");
while($row = $result->fetch_assoc()) {
echo $row['post_id'];
}



Making sure first at least one result is returned ($result->num_rows).

If you only want 3 rows returned use LIMIT in your query like "SELECT post_id ... LIMIT 3".


--------------------
1O2


Extras: Filter Print Post Top
OfflineGypsy Boy
Redeemer
Male


Registered: 03/17/17
Posts: 4,501
Loc: Deep in the discoteka
Last seen: 2 months, 25 days
Re: Please help me with my website [Re: singlet_oxygen]
    #26661909 - 05/10/20 09:05 AM (3 years, 8 months ago)

Right :strokebeard:

I just tried



Quote:

$test = ("SELECT post_id
FROM posts
WHERE EXISTS
(SELECT * FROM posts)");
$result = mysqli_query($dbc, $test);
$resultarr = mysqli_fetch_assoc($result);
$r1 = $resultarr["post_id"];
echo $r1;





And the answer printed was "12" !!

What happened to 14 and 15? how do i retrieve them?


--------------------





Extras: Filter Print Post Top
OfflineGypsy Boy
Redeemer
Male


Registered: 03/17/17
Posts: 4,501
Loc: Deep in the discoteka
Last seen: 2 months, 25 days
Re: Please help me with my website [Re: Gypsy Boy]
    #26661913 - 05/10/20 09:06 AM (3 years, 8 months ago)

singlet_oxygen, hows it going buddy, thanks for stopping by and helping! :wink:

Im gonna try yer code now.

$result = $conn->query("SELECT post_id...");
while($row = $result->fetch_assoc()) {
    echo $row['post_id'];
  }

Im a little confused tho

Whats variable $row about?? I dont see it declaring anywhere


Extras: Filter Print Post Top
OfflineGypsy Boy
Redeemer
Male


Registered: 03/17/17
Posts: 4,501
Loc: Deep in the discoteka
Last seen: 2 months, 25 days
Re: Please help me with my website [Re: Gypsy Boy]
    #26661930 - 05/10/20 09:18 AM (3 years, 8 months ago)

$sql = ("SELECT post_id FROM posts WHERE EXISTS (SELECT * FROM posts)");
$result = mysqli_query($dbc, $sql);

while($row = $result->fetch_assoc()) {
    echo $row['post_id'];
$id = $row['post_id'];
echo "\r\n";
    echo "\r\n";
    echo $id;

Seems to work



--------------------





Edited by Gypsy Boy (05/10/20 09:44 AM)


Extras: Filter Print Post Top
Offlinesinglet_oxygen
Stranger
Registered: 05/10/20
Posts: 32
Last seen: 3 years, 6 months
Re: Please help me with my website [Re: Gypsy Boy]
    #26661943 - 05/10/20 09:25 AM (3 years, 8 months ago)

Quote:

Gypsy Boy said:
singlet_oxygen, hows it going buddy, thanks for stopping by and helping! :wink:

Im gonna try yer code now.

$result = $conn->query("SELECT post_id...");
while($row = $result->fetch_assoc()) {
    echo $row['post_id'];
  }

Im a little confused tho

Whats variable $row about?? I dont see it declaring anywhere




I've highlighted to show where it's declared.

fetch_assoc will return a associative array variable which we load into $row.

The while loop will keep loading $row until $result is expended.

If you click that link you can see it in action in the examples, I prefer OO style.

Edit: Just seen your $conn error, I guess I will have to read the other replies serves me right for just jumping in. I recommend you look at the link above for fetch_assoc and make your code look like the idiom either Example 1 (object orientated) or Example 2 (procedural) style.

https://www.shroomery.org/forums/showflat.php/Number/26654748#26654748 The code you screenshot here looks good (it's idiomatic procedural style).






Quote:

Gypsy Boy said:
Right :strokebeard:

I just tried



Quote:

$test = ("SELECT post_id
FROM posts
WHERE EXISTS
(SELECT * FROM posts)");
$result = mysqli_query($dbc, $test);
$resultarr = mysqli_fetch_assoc($result);
$r1 = $resultarr["post_id"];
echo $r1;





And the answer printed was "12" !!

What happened to 14 and 15? how do i retrieve them?





Try:

Code:

$test = ("SELECT post_id FROM posts");

if($result = mysqli_query($dbc, $test)){
while ($resultarr = mysqli_fetch_assoc($result)) {
$r1 = $resultarr["post_id"];
echo $r1;
}
}



But what is "SELECT post_id FROM posts WHERE EXISTS(SELECT * FROM posts)" trying to do?!


--------------------
1O2


Edited by singlet_oxygen (05/10/20 09:33 AM)


Extras: Filter Print Post Top
OfflineGypsy Boy
Redeemer
Male


Registered: 03/17/17
Posts: 4,501
Loc: Deep in the discoteka
Last seen: 2 months, 25 days
Re: Please help me with my website [Re: singlet_oxygen]
    #26662088 - 05/10/20 10:39 AM (3 years, 8 months ago)

while($row = $result->fetch_assoc()) {
   
$id = $row['post_id'];

echo $id;
}


Works!!!!

I finally did it. Everything seems to work fine.

Pheeewwwwwww... took me a while

HUGE THANK YOU to all who helped.

We havent finished yet, there gonna be more questions. But alpha/beta stage of my website is now complete!!! :gethigh:


--------------------





Extras: Filter Print Post Top
Jump to top Pages: < Back | 1 | 2 | 3 | Next >  [ show all ]

Shop: Kraken Kratom Red Vein Kratom   Bridgetown Botanicals CBD Concentrates   PhytoExtractum Kratom Powder for Sale, Maeng Da Thai Kratom Leaf Powder


Similar ThreadsPosterViewsRepliesLast post
* Why is the text on some websites so SMALL!?! SillyWilly 925 8 10/27/04 05:22 PM
by MarioNett
* Post deleted by Administrator
( 1 2 3 all )
Alien 8,905 51 11/12/02 04:21 PM
by Anonymous
* building a website LethalX5 741 7 03/17/05 04:00 AM
by phishman
* something to hide website names? gdman 1,094 10 07/29/03 12:32 AM
by matts
* Buying domain names; owning a website 3eyes 616 3 11/22/04 09:02 PM
by AhronZombi
* question about my website and search engines stefan 569 3 01/25/05 01:39 PM
by stefan
* Nothing exists MushyMay 1,206 8 03/11/03 10:23 AM
by iconoclast
* hosting a website
( 1 2 all )
funkymonk 2,512 23 03/19/05 08:08 PM
by kadakuda

Extra information
You cannot start new topics / You cannot reply to topics
HTML is disabled / BBCode is enabled
Moderator: trendal, automan, Northerner
1,454 topic views. 0 members, 1 guests and 0 web crawlers are browsing this forum.
[ Show Images Only | Sort by Score | Print Topic ]
Search this thread:

Copyright 1997-2024 Mind Media. Some rights reserved.

Generated in 0.028 seconds spending 0.007 seconds on 13 queries.