//Sorry about the name, hit enter too early >.< Should be 'adding a link to PHP'

[indexphp.php]

<?php

if($_GET['act'] == "generate_quotes") {

$con = mysql_connect("*", "*", "*");
if (!$con)
  {
  
  die('Could not connect: ' . mysql_error());
  
  }
mysql_select_db("quote", $con);

	$result = mysql_query( " SELECT * FROM `quote`  ORDER BY RAND() LIMIT 0,1 " );

while($row = mysql_fetch_array($result))
  {

  echo '<span class="pink">' . $row['q_quote'] . "</span>";

  }
echo "</table>";

mysql_close($con);

echo '<a href="#lb1"><img src="1s.jpg" alt="LightBox" align="right" /></a>';


} else { 

echo "<img src=\"img/vpbgt.png\">";   

}
?>
</div>
<a href="indexphp.php?act=generate_quotes" class="style2">Generate</a>

Above is the php and link to generate it

<div id="lb1" class="lb"><a href="#top"><img src="1.jpg" alt="oh man" /></a></div>

And there is the div outside the wrap to make the screen dark.

What I'm trying to do is when the user click the generate the text, it ALSO dakrnes the screen, i thought this would work, which it does, but not exactly now I want it to.

What's happening is that it's using the link, because along with the echo'd content from the db is the little thumbnail image that the user can click to make a screen dark. But is there anyway to have it so when the user clicks the 'generate' link it darkens automatically?

SO when the user clicks:

<a href="indexphp.php?act=generate_quotes" class="style2">Generate</a>

the code acts as though:

<a href="#lb1"><img src="1s.jpg" alt="LightBox" align="right" /></a>

Has been clicked at the same time? So the screen darkens and the text is generated together?

Are you looking for something like a lightbox?
http://www.huddletogether.com/projects/lightbox2/

No no, I have a pure css lightbox working:

http://www.studiomoh.com/fun/csslightbox/

I just want it to be triggered when the user clicks 'generate'. But seeing as this link already calls text from my database, I thought I would be able to achieve this by doing something along the lines of what I posted before /\

I'm just having as few problems getting it to behave like I want it to.

sorry I'm not to sure what you actually want it to do.
the link was to a static page.
can you be a little more specific please?

Correct me if I'm wrong but your problem is that it should generate a fresh Quote whenever the link is clicked? and then what happened is that when the page opens, it also generate the quote?

if this is your problem, I think the problem is in your CSS lightbox. it is because it will get the page from your generating page automatically. it is because it is triggered when only the page loads and wait for someone to open it. as far as I can see. The lightbox you're using is not for these types of data retrieving. Because it is not an IFRAME. and IFrame box is what you need.


I can give you options:

1. (Recommended if you want it rush) try this one http://highslide.com/ as it does the same thing with your CSS Box. but it has an Iframe and that is what you need.

2. (Recommended if you want to learn and level up yourself) Try doing it yourself. using AJAX, this will make things possible. but I would recommend this for you because this will enhance your skills and knowledge in programming. if you want this, I would recommend using JQuery. this will make things easier for you.


Best of wishes! :D

Hello

very sorry I am an Arab >>> I'm not understand the problem good

but I understand :

you must use the events .. ex:

<a href ="**" clas="**" OnClick="">**</a>

sorry hit enter too early...again.

You'd think I'd learn, right?

No no, sorry I must not have explained this well, the problem isn't the quote, it's the screen darking working at the same time as the quote being generated so:


user click 'generate' --- quote is generated AND the screen is darkened.


The both work individually, If i were to put it a different way I want one click to do two things.

// When 'generate' is clicked, this function is run:

<?php
 
if($_GET['act'] == "generate_quotes") {
 
$con = mysql_connect("*", "*", "*");
if (!$con)
  {
 
  die('Could not connect: ' . mysql_error());
 
  }
mysql_select_db("quote", $con);
 
	$result = mysql_query( " SELECT * FROM `quote`  ORDER BY RAND() LIMIT 0,1 " );
 
while($row = mysql_fetch_array($result))
  {
 
  echo '<span class="pink">' . $row['q_quote'] . "</span>";
 
  }
echo "</table>";
 
mysql_close($con);




// Here is the problem. When I click this link normaly, the screen darkens. So I'm trying to get the PHP to act as though this has been clicked. So when the function is run, not only is the quote generated, but the screen goes dark using the link below. 

echo '<a href="#lb1"><img src="1s.jpg" alt="LightBox" align="right" /></a>';
 


 
} else { 
 
echo "<img src=\"img/vpbgt.png\">";   
 
}
?>
</div>

Sorry if I'm not explaining this well I don't know how to put it really, but I hope this helps clear it up somewhat?


I mean there maybe a different way to do this, but in it's simplest form:

<a href="indexphp.php?act=generate_quotes" class="style2">Generate</a>

When the user clicks the link above it acts as both the links below have been clicked, so both actions take place at the same time:

<a href="indexphp.php?act=generate_quotes" class="style2">

//AND

<a href="#lb1"><img src="1s.jpg" alt="LightBox" align="right" /></a>

//At the same time

//Sorry about the name, hit enter too early >.< Should be 'adding a link to PHP'

[indexphp.php]

<?php

if($_GET['act'] == "generate_quotes") {

$con = mysql_connect("*", "*", "*");
if (!$con)
  {
  
  die('Could not connect: ' . mysql_error());
  
  }
mysql_select_db("quote", $con);

	$result = mysql_query( " SELECT * FROM `quote`  ORDER BY RAND() LIMIT 0,1 " );

while($row = mysql_fetch_array($result))
  {

  echo '<span class="pink">' . $row['q_quote'] . "</span>";

  }
echo "</table>";

mysql_close($con);

echo '<a href="#lb1"><img src="1s.jpg" alt="LightBox" align="right" /></a>';


} else { 

echo "<img src=\"img/vpbgt.png\">";   

}
?>
</div>
<a href="indexphp.php?act=generate_quotes" class="style2">Generate</a>

Above is the php and link to generate it

<div id="lb1" class="lb"><a href="#top"><img src="1.jpg" alt="oh man" /></a></div>

And there is the div outside the wrap to make the screen dark.

What I'm trying to do is when the user click the generate the text, it ALSO dakrnes the screen, i thought this would work, which it does, but not exactly now I want it to.

What's happening is that it's using the link, because along with the echo'd content from the db is the little thumbnail image that the user can click to make a screen dark. But is there anyway to have it so when the user clicks the 'generate' link it darkens automatically?

SO when the user clicks:

<a href="indexphp.php?act=generate_quotes" class="style2">Generate</a>

the code acts as though:

<a href="#lb1"><img src="1s.jpg" alt="LightBox" align="right" /></a>

Has been clicked at the same time? So the screen darkens and the text is generated together?

http://www.translation.pkhttp://www.translation.pk

I think all you need is something like JQuery which is JS library to help you manipulate the DOM (Hide, show, effects et al) and with simplified AJAX methods, you can do a big deal of, almost, whatever you think of

Check it here

Hey thanks to everyone who replied, I have it working now, I made some new DIVs to messing around with and it eventually worked. But the problem is, it's only dimming the div the php is in, and not the whole page, anyone got any ideas how to go about getting this to effect all the screen? I thought about maybe calling two functions with the same click, and having one outside the page wrap [no idea if this is possible, just a suggestion]

But any ideas welcome.

wow its more complicated than I ever imagined. can you send some printscreens, maybe?

wow its more complicated than I ever imagined. can you send some printscreens, maybe?

haha tell me about it, but I've fixed it now. I just simply added another if statement which did the trick.

And as for the jquerey, I was avoiding using it as It really requires ALL users to have this effect to really make it work. I may still add a fade in fade out for the people with javascript enabled. But that's the reason I didn't want to do it that way, no matter how much i'd like too.

Thanks to eveyone that helped out :)

And as for the jquerey, I was avoiding using it as It really requires ALL users to have this effect to really make it work. I may still add a fade in fade out for the people with javascript enabled. But that's the reason I didn't want to do it that way, not matter how much i'd like too.

Whoever disables JS then will miss a lot of goodies in this world

Thanks to eveyone that helped out :)

Glad you resolved
Cheers :)

I do not have access to whatever lightbox is being used,
the code posted by the OP is not complete,

<a onclick="document.body.style.backgroundColor='#707070';return true;" href="indexphp.php?act=generate_quotes" class="style2">Generate</a>

to just change the backgrtond
or

<div id='shadow' style='background:#707070;width:100%;height:2000px;top:0;left:0;right:auto;bottom:auto;z-index:100;display:none;'></div>
<a onclick="document.getElementById('shadow').style.display='block';return true;" href="indexphp.php?act=generate_quotes"

to disable the underlying elements, (set opacity as well as color)
inline styles are tacky but its example only

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.