|
Answer» Hi, another fun project: I'm printing a list from a table ALTERNATING line colors. I'm including a radio button on each line to link to the URL "target". I've greatly edited offerings from the net and all is well except that the buttons do nothing. I don't understand the line: echo ""; Thanks for any help!
Code: [Select]<!DOCTYPE html><html> <head> <title>Email Visits</title> </head> <body><center> <form id="testform" name="testform" action="" method="post" accept-charset="UTF-8">
Code: [Select] <?php $host="localhost";$USERNAME="root";$password="cookie"; $db_name="homedb";$tbl_name="emailtbl";
/*Connecttoserverandselectdatabse*/ mysql_connect("$host","$username","$password")ordie("cannotconnect"); mysql_select_db("$db_name")ordie("cannotselectDB");
//Define$count $count="";
$sql="SELECT*FROMemailtblORDERBYtargetASC"; $result=mysql_query($sql);
echo'<tableborder="1"cellspacing="0">'; while($res=mysql_fetch_assoc($result)) { //Add1totherowcount $count=$count+"1";
/*-------------If$count==1tablerowcolor=#FFC600----------*/ if($count=="1") {echo"<trbgcolor='#FFC600'>";}
/*-------------If$count==2tablerowcolor=#ccffff----------*/ if($count=="2") {echo"<trbgcolor='#ccffff'>";$count=$count-"2";}
echo"<td>"; echo"<inputtype=\"radio\"name=\"select\"value=\"{$res['target']}\">"; echo"</td>"; echo"<td>";echo$res['target'];echo"</td>"; echo"<td>";echo$res['username'];echo"</td>"; echo"<td>";echo$res['password'];echo"</td>"; echo"<td>";echo$res['emailused'];echo"</td>"; echo"<td>";echo$res['lastused'];echo"</td>"; echo"<td>";echo$res['purpose'];echo"</td>"; echo"<td>";echo$res['visits'];echo"</td>"; echo"<td>";echo$res['saved'];echo"</td>"; echo"</tr>";
} echo'</table>'; mysql_close(); ?>
Code: [Select] </table> </form></body></html> What is your local host? Do you see the code connecting to the local host? explain your post pleaseDo you have a local host? For example, the local host might be: 127.0.0.1 But a jump to that IP will GENERATE an error unless there is a service at location.
Why Is the Localhost IP 127.0.0.1?
The above is a tutorial that explains in more detail.
Meanwhile, you could TRY code that does not require a local host.
|