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: PhytoExtractum Maeng Da Thai Kratom Leaf Powder   Left Coast Kratom Buy Kratom Extract   North Spore North Spore Mushroom Grow Kits & Cultivation Supplies   Kraken Kratom Red Vein Kratom

Jump to first unread post Pages: 1
OfflineGypsy Boy
Redeemer
Male


Registered: 03/17/17
Posts: 4,501
Loc: Deep in the discoteka
Last seen: 2 months, 25 days
PHP and MySQL gurus !!
    #26502001 - 02/24/20 05:49 PM (3 years, 10 months ago)

I am working on a website...

could someone please help


I am just starting this. Basically i wrote a simple code that fetches a table thro PHP and then prints its content. Heres the code:

$sql = ("SELECT name FROM forums");
$result = mysqli_query($dbc, $sql);
$resultarr = mysqli_fetch_assoc($result);
$r = $resultarr["name"];

echo $r;


It works. But, it only prints the top value in the table - just 1, wheres SELECT in SQL lists entire table. How can i make it show the table in one go?


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





Edited by Gypsy Boy (03/15/20 08:51 AM)


Extras: Filter Print Post Top
Offlineaudiophoenix
Find Peace
Male User Gallery

Registered: 08/28/09
Posts: 4,107
Loc: Upstate NY
Last seen: 2 years, 8 months
Re: PHP and MySQL gurus come in here!! [Re: Gypsy Boy]
    #26502018 - 02/24/20 05:56 PM (3 years, 10 months ago)

It's so funny how people post on a mushroom enthusiast website for hep with the weirdest things


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


Extras: Filter Print Post Top
OnlineYthanA
ᕕ( ᐛ )ᕗ
Male User Gallery

Registered: 08/08/97
Posts: 18,774
Loc: NY/MA/VT Borderlands Flag
Last seen: 3 minutes, 7 seconds
Re: PHP and MySQL gurus come in here!! [Re: Gypsy Boy]
    #26502302 - 02/24/20 08:54 PM (3 years, 10 months ago)

You just need to loop through the results, like this:

Code:
$sql = ("SELECT name FROM forums");
$result = mysqli_query($dbc, $sql);

while ($resultarr = mysqli_fetch_assoc($result)) {
$r = $resultarr["name"];
echo $r;
}



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: PHP and MySQL gurus come in here!! [Re: Ythan]
    #26502619 - 02/25/20 05:58 AM (3 years, 10 months ago)

Hey dude thanks VERY much for help

It worked but now got another problem  on my hand.

I use HTML form to type in country name:

<form method="post" action="action.php">
<div class="center">
<p>Language</p>
<input type="text" name="language" value="">
<br>
<p>Show countries</p>
<input type="submit" name="submit" value="      Go    ">
<br>

Basically u type a language and it print outs all countries that speak it name

For some reason forum wont let me post php code so im attaching image


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





Edited by Gypsy Boy (02/25/20 07:47 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: PHP and MySQL gurus come in here!! [Re: Gypsy Boy]
    #26502660 - 02/25/20 06:55 AM (3 years, 10 months ago)



Gives this error

Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, bool given in C:\wamp64\www\world\action.php on line 26


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





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: PHP and MySQL gurus come in here!! [Re: Gypsy Boy]
    #26502669 - 02/25/20 07:05 AM (3 years, 10 months ago)

Funnily enough simple script like this:



Works just fine :shrug:

What the hell is wrong with world database?

So frustrating, i need a smoke


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





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: PHP and MySQL gurus come in here!! [Re: Gypsy Boy]
    #26502696 - 02/25/20 07:27 AM (3 years, 10 months ago)



This is getting fkin ridiculousness

I used WORKING code from small "forum" database and replaced variable names with world database. I get same

mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, bool given in C:\wamp64\www\world\action.php on line 26

error :sad:

BTW i used pics for code because forums woudlnt let me post it in text for some reason


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





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: PHP and MySQL gurus come in here!! [Re: Gypsy Boy]
    #26502705 - 02/25/20 07:39 AM (3 years, 10 months ago)

I finally got it :doublefacepalm:





$sql = ("SELECT name FROM country WHERE Continent = '$name'");

$name had to be double quoted :facepalm: cos it's a string I suppos

How the hell compiler didnt provide a meaningful error message?????


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





Edited by Gypsy Boy (02/25/20 08:49 AM)


Extras: Filter Print Post Top
Jump to top Pages: 1

Shop: PhytoExtractum Maeng Da Thai Kratom Leaf Powder   Left Coast Kratom Buy Kratom Extract   North Spore North Spore Mushroom Grow Kits & Cultivation Supplies   Kraken Kratom Red Vein Kratom


Similar ThreadsPosterViewsRepliesLast post
* ATTN: PHP/MySQL Gurus
( 1 2 all )
elbisivni 2,075 20 09/04/07 06:04 PM
by elbisivni
* PHP, MySQL Programmer (job offer in craigslist chicago!) ZippoZM 578 0 07/11/06 02:20 PM
by ZippoZ
* php & mysql Cepheus 799 8 01/22/07 01:36 PM
by Cepheus
* PHP/MySQL question daytripper05 983 7 04/28/08 04:43 PM
by daytripper05
* PHP/MySQL help daytripper05 1,182 7 04/20/08 10:48 PM
by ectolysergic
* PHP/MySQL question elbisivni 763 4 05/15/08 01:25 PM
by elbisivni
* PHP people HELLA_TIGHT 706 8 06/02/07 11:20 AM
by Ythan
* Want to learn PHP: Book recommendations? Gr8fulJ420 961 6 03/09/06 09:39 AM
by Shdwstr

Extra information
You cannot start new topics / You cannot reply to topics
HTML is disabled / BBCode is enabled
Moderator: trendal, automan, Northerner
314 topic views. 0 members, 0 guests and 2 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.027 seconds spending 0.008 seconds on 15 queries.