Jump to content
php.lv forumi
  • 0

Datu izvilkšana no datubāzes ar JavaScript


Cibiņš

Question

Kā var panākt lai "case" un "ba" izvelk ID no datubāzes? Ja "case" un "ba" ir 7 tad viss ir ok, savukart ja pie ID ir kads cits skaitlis tad attiecigi izvelk citu ID tas Javaskripts.

 

javaskripc.js

function peleVirsu(a)
{
switch (a){
case 7: {document.ba7.src ="attels1.jpg"}
break
}}

function peleAra(a)
{
switch (a){
case 7: {document.ba7.src ="attels2.jpg"}
break
}}

 

PHP

 

<?php
   $result = mysql_query("SELECT id, text, insert_data FROM tbl_arhivs_years ORDER BY insert_data;");
   if (!mysql_num_rows($result)) {
       echo "Nav datu!";
   } else {
       while ($row = mysql_fetch_assoc($result)) {
           extract($row, EXTR_PREFIX_ALL, "mb");
           echo "<tr align=\"center\"><td align=\"center\"><a id=\"link1_text\" href=\"index.php?view=arhivs&MBID=$mb_id\" 
onmouseover=\"peleVirsu($mb_id)\" onmouseout=\"peleAra($mb_id)\"><img style=\"vertical-align:middle; margin-right:10px\" src=\"attels2.jpg\"  
width=\"61\" height=\"58\" border=\"0\" name=\"ba$mb_id\">$mb_text</a><br /></tr></td>";
       }
   }
?>

Edited by Cibiņš
Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

ar :hover un background var panākt tādu pašu efektu kā ar js un img tagu

 

vsp priekš kam tu šajā piemērā tgd jauc iekšā php? var tač uztaisīt atsevišķu html+css. un kad ir panākts, ka tas strāda kā vajag, tad pārcelt uz php, lai ir dinamiski

 

un ja tomēr izmanto js, tad elementus labāk ņemt ar document.getElementById(). tam arī varēsi atkarībā no funkcijas argumenta nomainīt ba7,ba8,...

Edited by 2easy
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
Answer this question...

×   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...