$result = mysql_query("SELECT COUNT(1) as likecount FROM Images WHERE userID=42");
Kleine Vragen Topic #1
Jordyvc schreef:Ja, maar dan van het juiste id van het plaatje?Het staat in een tabel Images en dan vind je het bij Likes.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?
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?
Sanderc schreef:Ja, maar dan van het juiste id van het plaatje?Eerdere citaten tonen
Jordyvc schreef:Het staat in een tabel Images en dan vind je het bij Likes.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?
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?
$Query = ("SELECT likes FROM Images ORDER BY id"); Zoiets dan?

Jordyvc schreef:De image wordt zo weer gegeven:Eerdere citaten tonen
Sanderc schreef:Ja, maar dan van het juiste id van het plaatje?Eerdere citaten tonen
Jordyvc schreef:Het staat in een tabel Images en dan vind je het bij Likes.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?
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?$Query = ("SELECT likes FROM Images ORDER BY id");
Zoiets dan?
<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.
Sanderc schreef:$image[like]; als je de juist query hebtDe image wordt zo weer gegeven:Eerdere citaten tonen
Jordyvc schreef:Eerdere citaten tonen
Sanderc schreef:Ja, maar dan van het juiste id van het plaatje?Eerdere citaten tonen
Jordyvc schreef:Het staat in een tabel Images en dan vind je het bij Likes.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?
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?$Query = ("SELECT likes FROM Images ORDER BY id");
Zoiets dan?<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.
$Query = ("SELECT likes FROM Images ORDER BY $image[like]"); Zo dan?
Sanderc schreef:Zo dan?$Query = ("SELECT likes FROM Images ORDER BY $image[like]");
Nee
Je query is dit:
$Query = ("SELECT likes FROM Images"); en dan de echo:
$Query[likes]
$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?
Sanderc schreef:Dit zou moeten werken?$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] ?>
Test het? Dan weet je het direct?

Jordyvc schreef:Test het? Dan weet je het direct?Dit zou moeten werken?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] ?>

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.
Sanderc schreef:Dan komt er deze error:Test het? Dan weet je het direct?Eerdere citaten tonen
Jordyvc schreef:Dit zou moeten werken?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] ?>
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?

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
. 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:
En dit is de query
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
. 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 • 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"; Marvinguich schreef:mysql_num_rows of mysql_fetch_assoc?Dan komt er deze error:Eerdere citaten tonen
Sanderc schreef:Test het? Dan weet je het direct?Eerdere citaten tonen
Jordyvc schreef:Dit zou moeten werken?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] ?>
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.

Jah.. Ik dacht dat hij dat wel wist

Niet dus
Maar kunnen jullie me aub wel helpen zodat jullie het me dan iig kunnen leren?
Maar kunnen jullie me aub wel helpen zodat jullie het me dan iig kunnen leren?Google > Tizag SELECT. Dan zie je hoe een SELECT query eruit ziet.