Hello i 'd like to post something because i believe its right but for some reason it doesnt work... I d like to make a link that gets the ID from the url and then displays data

the url returns as wanted e.g. localhost/rove/login/php?showallphoto=536 so they is no need to post the whole $query

<a class="showallphoto" href="'.$base_url.'login.php?showallphoto=' . $messageid . '" style="cursor:pointer">

i use javascript to open colorbox

<script type="text/javascript">
$(document).ready(function(){
    $(".showallphoto").colorbox({width:"70%", height:'80%', inline:true});
    $("#click").click(function(){ 
        $('#click').css({"background-color":"#f00", "color":"#fff", "cursor":"inherit"}).text("Open this window again and this message will still be here.");
        return false;
    });
});
</script>

this is the php syntax i use to return the data

$query = mysql_query("SELECT M.msg_id FROM messages AS M WHERE M.msg_id = ".$GET_['showallphoto'] );
while($row=mysql_fetch_array($query))
{
    $messageid = $row['msg_id'];
    ?>
<div style="display:none">
    <div id="showallphoto<?php echo $messageid;?>" style="margin-left:20px">

Can anyone help?

you need to separate link params with an '&'

there is only one parameter the ID. why should i use '&'? i am seeing examples on the net and i can't figure it out. Can you post an example?

sorry didnt follow all the quotes right

$GET_['showallphoto'] should be $_GET['showallphoto']

Thanks but still the same

What do you mean with “for some reason it doesnt work” , what happens ? . What is the #click DOM element that clicking it returns false , is it inside this <a> ? There are many issues with the code that you provided that are irrelevant with your question but can cause serious problems, if you want I can be more analytic.

No there is not a #click DOM. The <a element is this. I dont know what the correct syntax is with the #click DOM.

<a class="showallphoto" id="showallphoto" href="'.$base_url.'?showallphoto=' . $messageid . '" style="cursor:pointer">

All i want to do is to return data using the ID from the url

this is the mysql

$query = mysql_query("SELECT M.msg_id, M.uploads, M.country_id, M.message, M.description, M.type, M.text, M.views_count, U.username, C.name as country_name, CA.name as category_name FROM users AS U LEFT JOIN messages AS M ON U.uid = M.uid_fk LEFT JOIN head_networks AS H ON M.network_id=H.network_id LEFT JOIN countries AS C ON M.country_id=C.country_id LEFT JOIN categoriestol AS CA ON M.category_id=CA.c_id WHERE M.msg_id = ".$_GET['showallphoto'])

when i click on the link e.g. localhost/rove/showallphoto345 the colorbox frame opens but shows nothing

and this is the javascript

<script type="text/javascript">
$(document).ready(function(){

    $(".showallphoto").colorbox({width:"70%", height:'80%', inline:true});

    $("#click").click(function(){ 
        $('#click').css({"background-color":"#f00", "color":"#fff", "cursor":"inherit"}).text("Open this window again and this message will still be here.");
        return false;
    });
});
</script>

what is the #click in your code ? What is colorbox ? I googled it , and I think that you should read their documentation. You don't pass anything in the constructing properties to be shown

OK. The colorbox works fine. its a jQuery lightbox http://www.jacklmoore.com/colorbox/

And i think we are missing the point.
The problem is the a attribute syntax. How can i get the ID of the showallphoto from the URL?

Is the code

<a class="showallphoto" href="'.$base_url.'login.php?showallphoto=' . $messageid . '" style="cursor:pointer">

echoed by a PHP script? If yes, show the whole line. Also test if the link gets constructed OK (by inspecting the generated code, by hovering with the mouse over it and checking the status line etc).

OK Broj thanks. Yes it is echoed by php. This is it. Yes the links returns OK. E.g. localhost/rove/?showallphoto=234

 echo '<a class="showallphoto" id="show_all_photo" href="'.$base_url.'?showallphoto=' . $messageid . '" style="cursor:pointer"><img class="small_icon" src="'.$base_url.'uploads/thumbs/'.$filename.'" original-title="'.$message.'" ></a>';

I am looking for a solution online i think i has to do with the #click element that jkon said. There is no #element here. I ll post the solution when i find it.

the solution is this

  echo '<a class="show-all-photo" href="#show-all-photo'.$messageid.'" style="cursor:pointer" id="show_all_photo">link</a>';

What i tried to do was to try and $_GET the message_id throught the url. I couldn't figure out how to do it and i put the colorbox html inside the while() so it returned ok.

If someone wants to get the parameters via url this is the best solution i find

http://stackoverflow.com/questions/7206931/pass-form-value-into-src-url-of-iframe-with-jquery

commented: Thnx for posting the solution +11
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.