Jump to content
php.lv forumi

Random teksts


Blumish

Recommended Posts

Sveiki!

 

Seit ir php kods kas izvelk pilniigi uz dullo vienu ierakstu no datubazes:

 

<?php

$query = mysql_query("SELECT * FROM anekdotes WHERE redz=1");

$nume= mysql_num_rows($query);

$random = rand(1, $nume);

$lol = mysql_query("SELECT * FROM anekdotes WHERE id='".$random."'");

while($dada = mysql_fetch_array($lol))

{

echo'

<font size="4"><b>Pasmaidi: </b>'.$dada['anekdote'].'</font>

';

}

 

?>

 

Man ir vajadzigs sim kodam klaat kods kas parladee so tekstu.

 

Ar so kodu raadas kaads teksts, un vajadzeetu lai zem taa teksta buutu podzinja kuru uzpiezot, tiek izvilkts cits teksts no db un ieprieksejais pazustu..

 

Cerams ka saprataat mani!

Paldies.

Edited by Blumish
Link to comment
Share on other sites

Blumish.

jquery ar $.load funkciju.

<a href="#" onlick="reload();">reload</a>

function reload()

{

$("aaa").load("anekdotes.php");

}

 

hmm man tas kods nestradaa.. izdariiju tac pareizi ja?

 

<a href="#" onlick="reload();">reload</a>

<?

function reload()

{

$("anekdotes").load("lapas/anekdotes/random.php");

}

?>

Link to comment
Share on other sites

nestrada :(

 

luuk saadi:

<a href="#" onlick="reload();">reload</a>

<script>

function reload()

{

$("anekdotes").load("lapas/anekdotes/random.php");

}

</script>

 

un <head> daljaa ir:

<script type="text/javascript" src="js/jquery-1.3.2.min.js"></script>

 

Not work!

Link to comment
Share on other sites

itkaa visu saliku, bet vins man raada kkaadu erroru:

 

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\AppServ\www\lapas\anekdotes\random.php on line 5

 

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\AppServ\www\lapas\anekdotes\random.php on line 8

 

Luuk random kods:

 

<?php

$query = mysql_query("SELECT * FROM anekdotes WHERE redz=1");

$nume= mysql_num_rows($query);

$random = rand(1, $nume);

$lol = mysql_query("SELECT * FROM anekdotes WHERE id='".$random."'");

while($dada = mysql_fetch_array($lol))

{

echo'

<font size="4"><b>Pasmaidi: </b>'.$dada['anekdote'].'</font>

';

}

 

?>

 

Nesaprotu kas pa vainu, mekleju google, bet neko jedzigu neatradu

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...