Kleine Vragen Topic #1

Gestart doorLennard4.284 reacties15.585 weergaven

4.285 berichten · pagina 9 van 286

Berichten
10.421
Reputatie
4
Punten
0,00
Lid sinds
Laatst gezien
$result = mysql_query("SELECT COUNT(1) as likecount FROM Images WHERE userID=42");
0
Berichten
11.263
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Jordyvc schreef:
Eerdere citaten tonen
Sanderc schreef:
Ik heb dus een meme script en ik wil showen hoeveel likes hij heeft. Hoe haal ik dat dan op?
Het staat in een tabel Images en dan vind je het bij Likes.
Met welk stukje code haal ik dat op?

Dat was toch iets met WHERE etc?

[COLOR= #0000BB]<?php[/COLOR]
Query [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT likes FROM Images"[/COLOR][COLOR= #007700]);[/COLOR]
?>


Zoiets?
Ja, maar dan van het juiste id van het plaatje?
0
Berichten
6.037
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Sanderc schreef:
Eerdere citaten tonen
Jordyvc schreef:
Eerdere citaten tonen
Sanderc schreef:
Ik heb dus een meme script en ik wil showen hoeveel likes hij heeft. Hoe haal ik dat dan op?
Het staat in een tabel Images en dan vind je het bij Likes.
Met welk stukje code haal ik dat op?

Dat was toch iets met WHERE etc?

[COLOR= #0000BB]<?php[/COLOR]
Query [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT likes FROM Images"[/COLOR][COLOR= #007700]);[/COLOR]
?>


Zoiets?
Ja, maar dan van het juiste id van het plaatje?
$Query = ("SELECT likes FROM Images ORDER BY id");


Zoiets dan? yummie
0
Berichten
11.263
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Jordyvc schreef:
Eerdere citaten tonen
Sanderc schreef:
Eerdere citaten tonen
Jordyvc schreef:
Eerdere citaten tonen
Sanderc schreef:
Ik heb dus een meme script en ik wil showen hoeveel likes hij heeft. Hoe haal ik dat dan op?
Het staat in een tabel Images en dan vind je het bij Likes.
Met welk stukje code haal ik dat op?

Dat was toch iets met WHERE etc?

[COLOR= #0000BB]<?php[/COLOR]
Query [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT likes FROM Images"[/COLOR][COLOR= #007700]);[/COLOR]
?>


Zoiets?
Ja, maar dan van het juiste id van het plaatje?
$Query = ("SELECT likes FROM Images ORDER BY id");


Zoiets dan? yummie
De image wordt zo weer gegeven:

<a href="/view/[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$image[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]link[/COLOR][COLOR= #007700]];[/COLOR] ?>.html"><img style="max-width:470px;" title="[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [URL="http://www.php.net/ucfirst"]ucfirst[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$image[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]title[/COLOR][COLOR= #007700]]);[/COLOR] ?>" alt="[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [URL="http://www.php.net/ucfirst"]ucfirst[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$image[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]title[/COLOR][COLOR= #007700]]);[/COLOR] ?>" src="/imagesystem/[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$image[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]link[/COLOR][COLOR= #007700]];[/COLOR] ?>.jpeg" /></a>


Hoe kies ik dat hij de likes van de juiste image zet want er staan er meerdere op een pagina.
0
Berichten
6.037
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Sanderc schreef:
Eerdere citaten tonen
Jordyvc schreef:
Eerdere citaten tonen
Sanderc schreef:
Eerdere citaten tonen
Jordyvc schreef:
Eerdere citaten tonen
Sanderc schreef:
Ik heb dus een meme script en ik wil showen hoeveel likes hij heeft. Hoe haal ik dat dan op?
Het staat in een tabel Images en dan vind je het bij Likes.
Met welk stukje code haal ik dat op?

Dat was toch iets met WHERE etc?

[COLOR= #0000BB]<?php[/COLOR]
Query [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT likes FROM Images"[/COLOR][COLOR= #007700]);[/COLOR]
?>


Zoiets?
Ja, maar dan van het juiste id van het plaatje?
$Query = ("SELECT likes FROM Images ORDER BY id");


Zoiets dan? yummie
De image wordt zo weer gegeven:

<a href="/view/[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$image[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]link[/COLOR][COLOR= #007700]];[/COLOR] ?>.html"><img style="max-width:470px;" title="[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [URL="http://www.php.net/ucfirst"]ucfirst[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$image[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]title[/COLOR][COLOR= #007700]]);[/COLOR] ?>" alt="[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [URL="http://www.php.net/ucfirst"]ucfirst[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$image[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]title[/COLOR][COLOR= #007700]]);[/COLOR] ?>" src="/imagesystem/[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$image[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]link[/COLOR][COLOR= #007700]];[/COLOR] ?>.jpeg" /></a>


Hoe kies ik dat hij de likes van de juiste image zet want er staan er meerdere op een pagina.
$image[like]; als je de juist query hebt
0
Berichten
11.263
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
$Query = ("SELECT likes FROM Images ORDER BY $image[like]");


Zo dan?
0
Berichten
6.037
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Sanderc schreef:
$Query = ("SELECT likes FROM Images ORDER BY $image[like]");
Zo dan?

Nee
Je query is dit:

$Query = ("SELECT likes FROM Images");


en dan de echo:
$Query[likes]
0
Berichten
11.263
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
$Query = ("SELECT likes FROM Images");
<a href="/view/[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$image[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]link[/COLOR][COLOR= #007700]];[/COLOR] ?>.html"><img style="max-width:470px;" title="[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [URL="http://www.php.net/ucfirst"]ucfirst[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$image[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]title[/COLOR][COLOR= #007700]]);[/COLOR] ?>" alt="[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [URL="http://www.php.net/ucfirst"]ucfirst[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$image[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]title[/COLOR][COLOR= #007700]]);[/COLOR] ?>" src="/imagesystem/[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$image[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]link[/COLOR][COLOR= #007700]];[/COLOR] ?>.jpeg" /></a>
[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Dit plaatje heeft [/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$Query[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]likes[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000] Likes.[/COLOR][COLOR= #007700];[/COLOR] ?>


Dit zou moeten werken?
0
Berichten
6.037
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Sanderc schreef:
$Query = ("SELECT likes FROM Images");
<a href="/view/[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$image[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]link[/COLOR][COLOR= #007700]];[/COLOR] ?>.html"><img style="max-width:470px;" title="[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [URL="http://www.php.net/ucfirst"]ucfirst[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$image[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]title[/COLOR][COLOR= #007700]]);[/COLOR] ?>" alt="[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [URL="http://www.php.net/ucfirst"]ucfirst[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$image[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]title[/COLOR][COLOR= #007700]]);[/COLOR] ?>" src="/imagesystem/[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$image[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]link[/COLOR][COLOR= #007700]];[/COLOR] ?>.jpeg" /></a>
[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Dit plaatje heeft [/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$Query[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]likes[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000] Likes.[/COLOR][COLOR= #007700];[/COLOR] ?>
Dit zou moeten werken?

Test het? Dan weet je het direct? yummie
0
Berichten
11.263
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Jordyvc schreef:
Eerdere citaten tonen
Sanderc schreef:
$Query = ("SELECT likes FROM Images");
<a href="/view/[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$image[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]link[/COLOR][COLOR= #007700]];[/COLOR] ?>.html"><img style="max-width:470px;" title="[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [URL="http://www.php.net/ucfirst"]ucfirst[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$image[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]title[/COLOR][COLOR= #007700]]);[/COLOR] ?>" alt="[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [URL="http://www.php.net/ucfirst"]ucfirst[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$image[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]title[/COLOR][COLOR= #007700]]);[/COLOR] ?>" src="/imagesystem/[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$image[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]link[/COLOR][COLOR= #007700]];[/COLOR] ?>.jpeg" /></a>
[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Dit plaatje heeft [/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$Query[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]likes[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000] Likes.[/COLOR][COLOR= #007700];[/COLOR] ?>
Dit zou moeten werken?
Test het? Dan weet je het direct? yummie
Dan komt er deze error:

Quote:
Warning: Illegal string offset likes in /home/sevenft/domains/sander.s2.one2xs.com/public_html/index.php on line 197
Dit plaatje heeft S Likes.
0
Marv

Lid

Berichten
3.092
Reputatie
1
Punten
0,21
Lid sinds
Laatst gezien
Sanderc schreef:
Eerdere citaten tonen
Jordyvc schreef:
Eerdere citaten tonen
Sanderc schreef:
$Query = ("SELECT likes FROM Images");
<a href="/view/[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$image[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]link[/COLOR][COLOR= #007700]];[/COLOR] ?>.html"><img style="max-width:470px;" title="[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [URL="http://www.php.net/ucfirst"]ucfirst[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$image[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]title[/COLOR][COLOR= #007700]]);[/COLOR] ?>" alt="[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [URL="http://www.php.net/ucfirst"]ucfirst[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$image[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]title[/COLOR][COLOR= #007700]]);[/COLOR] ?>" src="/imagesystem/[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$image[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]link[/COLOR][COLOR= #007700]];[/COLOR] ?>.jpeg" /></a>
[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Dit plaatje heeft [/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$Query[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]likes[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000] Likes.[/COLOR][COLOR= #007700];[/COLOR] ?>
Dit zou moeten werken?
Test het? Dan weet je het direct? yummie
Dan komt er deze error:

Quote:
Warning: Illegal string offset likes in /home/sevenft/domains/sander.s2.one2xs.com/public_html/index.php on line 197
Dit plaatje heeft S Likes.

mysql_num_rows of mysql_fetch_assoc? emo
0
Berichten
11.263
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Hoe los ik dit op? Hij vind dus likes niet.
Wat jij zegt ben ik niets mee want dat kan ik niet.

toevoeging op 7 juni 2012, 19:27:52:
Nu geeft hij die error niet meer emo. maar hij geeft nog steeds geen likes weer.

toevoeging op 7 juni 2012, 19:30:54:
Dit kan misschien ook helpen:
Op een andere pagina waar het oproepen wel werkt, maar waar maar 1 image staat, de unieke link van de image wordt het zo weergegeven:

<img id="t_up" title="Thumbs up" onclick="like(.$image[id].)" src="/icon/thumb_up.png" /> <b>.$image[likes].</b> Leuk &#8226;


En dit is de query

$mysql_query_images_get = mysql_query("SELECT * FROM `images` WHERE link = ".$fid." ") or die(mysql_error());
$image = mysql_fetch_assoc($mysql_query_images_get);
if(mysql_num_rows($mysql_query_images_get)==0){
echo <div id="page-bar"><h3>Error</h3></div><div id="content">;
echo "Afbeelding kon niet worden gevonden";
0
Berichten
6.037
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Marvinguich schreef:
Eerdere citaten tonen
Sanderc schreef:
Eerdere citaten tonen
Jordyvc schreef:
Eerdere citaten tonen
Sanderc schreef:
$Query = ("SELECT likes FROM Images");
<a href="/view/[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$image[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]link[/COLOR][COLOR= #007700]];[/COLOR] ?>.html"><img style="max-width:470px;" title="[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [URL="http://www.php.net/ucfirst"]ucfirst[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$image[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]title[/COLOR][COLOR= #007700]]);[/COLOR] ?>" alt="[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [URL="http://www.php.net/ucfirst"]ucfirst[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$image[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]title[/COLOR][COLOR= #007700]]);[/COLOR] ?>" src="/imagesystem/[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$image[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]link[/COLOR][COLOR= #007700]];[/COLOR] ?>.jpeg" /></a>
[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Dit plaatje heeft [/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$Query[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]likes[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000] Likes.[/COLOR][COLOR= #007700];[/COLOR] ?>
Dit zou moeten werken?
Test het? Dan weet je het direct? yummie
Dan komt er deze error:

Quote:
Warning: Illegal string offset likes in /home/sevenft/domains/sander.s2.one2xs.com/public_html/index.php on line 197
Dit plaatje heeft S Likes.
mysql_num_rows of mysql_fetch_assoc? emo
Jah.. Ik dacht dat hij dat wel wist emo
0
Berichten
11.263
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Niet dus sadleyMaar kunnen jullie me aub wel helpen zodat jullie het me dan iig kunnen leren?
0
Berichten
10.409
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Google > Tizag SELECT. Dan zie je hoe een SELECT query eruit ziet.
0

Jouw reactie

Deel je idee, stel een vraag of help een ander verder.

Editor laden…

Praat mee met de One2xs-community.

Inloggen om te reageren