Jump to content

mayman212

Members
  • Posts

    48
  • Joined

  • Last visited

    Never

Everything posted by mayman212

  1. PHP login tutorials...sorry I didn't make it quite clear.
  2. Hello all, I am relatively new to PHP, and i am making a login page to my website. Does anybody know a good tutorial on login systems? Any help would be most appreciative.
  3. when I post something into my html form, for example in the first name field, I enter in: John', i am getting the following error: Error in query: . You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Smith',Address_Line_1='rtuy657tr',Address_Line_2='',City='leicester',Postcode='L' at line 1 I know it has something to do with preparing the data before inserting it into the database. Anyone know what I have to do to fix it?
  4. anyone have anything? only thing I've found close enough to helping is a Korean website...
  5. hello all. I have a list of records, which each have a comment button, just like any forum does. when I click on the comment button it brings up the current record at the top, and a blank form, to which you enter in information. When I submit this information, I want it to show up on the main page as a child of the parent record. I want it similar to the example I've shown below: id name dob address email username 1 john smith 10/11/1986 124 Peermont Drive john.smith@yahoo.com john smith1 >> 2 Harry 15/12/1985 98 The Roundhay harry@gmail.com harry23 >>> 3 jhk 08/11/1976 65 dfgdfg gfdfg@ yahoo.com jhk345 4 john smith 10/11/1986 124 Peermont Drive john.smith@yahoo.com john smith1 >> 5 Harry 15/12/1985 98 The Roundhay harry@gmail.com harry23 >>>> 6 jhk 08/11/1976 65 dfgdfg gfdfg@ yahoo.com jhk345 I've been stuck on this for hours, and I haven't got anywhere. Any ideas?
  6. Anyone have anything, Ive been trying all day, unsuccessfully.... :'(
  7. I have a comment form that I have created. It gets the id from the database and prints out the data that goes with that id, but what it also does is prints out the information into the form. I want a blank form so that the user can add a comment to the record. Any ideas? This the code for the form: <form method="post" action="pv.php?id=<?php echo $row['ID']?>&action=<?php echo $form_action ?>"> <fieldset> <legend></legend> <p> <label for="cname">Date Of Birth</label> * <input id="cname" name="dateofbirth" class="required date" value="<?php echo $row['Date_Of_Birth']?>" /> (eg 1978.11.11) </p> <p> <label for="cgender">Gender</label> * <input type="radio" name="gender" value="Male" <?php if($row['Gender']=='male'){echo 'checked';}?>/> Male <input type="radio" name="gender" value="Female" <?php if($row['Gender']=='female'){echo 'checked';}?>/> Female </td> </p> <p> <label for="curl">Title</label> * <select name="title" id="title" class="required"> <option value="">Please Select</option> <option value="Mr" <?php if($row['Title']=='Mr'){echo 'selected';}?>>Mr</option> <option value="Ms" <?php if($row['Title']=='Ms'){echo 'selected';}?>>Ms</option> <option value="Mrs" <?php if($row['Title']=='Mrs'){echo 'selected';}?>>Mrs</option> <option value="Miss" <?php if($row['Title']=='Miss'){echo 'selected';}?>>Miss</option> <option value="Other" <?php if($row['Title']=='Other'){echo 'selected';}?>>Other</option> </select> </p> <p> <label for="ccomment">First Name</label> * <input type="text" name="firstname" value="<?php echo $row['First_Name']?>" maxlength="50" /> </p> <p> <label for="cemail">Last Name</label> * <input id="cemail" type="text" name="lastname" value="<?php echo $row['Last_Name']?>" maxlength="75" /> </p> <p> <label for="ccomment">Address 1</label>* <input type="text" name="address1" value="<?php echo $row['Address_Line_1']?>" maxlength="50" /> </p> <p> <label for="ccomment">Address 2</label> <input type="text" name="address2" value="<?php echo $row['Address_Line_2']?>" maxlength="50" /> </p> <p> <label for="ccomment">City</label>* <input type="text" name="city" value="<?php echo $row['City']?>" maxlength="50" /> </p> <p> <label for="ccomment">Postcode</label>* <input type="text" name="postcode" value="<?php echo $row['Postcode']?>" maxlength= "10" /> (eg LE5 5QE) </p> <p> <label for="ccomment">Contact No</label>* <input type="text" name="contactno" value="<?php echo $row['Contact_No']?>" maxlength= "12" /> (eg 077448825723) </p> <p> <label for="ccomment">Email</label>* <input type="text" name="email" value="<?php echo $row['Email']?>" maxlength= "40"/> (eg info@example.com) </p> <p> <label for="ccomment">Comment</label> <textarea rows="10" cols="30" name="note" maxlength= "500"><?php echo $row['Additional_Comment']?></textarea> </p> <p> <input class="submit" type="submit" value="Submit"/> </p> <p> <a href='pv.php'>Main Page</a> </p> </fieldset> This is the code for printing out the data on the page: if($_GET['action']=='comment'){ $form_action = 'comment_ok'; $id=$_GET['id']; $result = mysql_query("SELECT * FROM project_data WHERE id='$id'"); $row = mysql_fetch_array($result); echo'<b>'; echo $row['Date_Of_Birth']; echo '&nbsp&nbsp'; echo $row['Gender']; echo '&nbsp&nbsp'; echo $row['Title']; echo '&nbsp&nbsp'; echo $row['First_Name']; echo '&nbsp&nbsp'; echo $row['Last_Name']; echo '&nbsp&nbsp'; echo $row['Address_Line_1']; echo '&nbsp&nbsp'; echo $row['Address_Line_2']; echo '&nbsp&nbsp'; echo $row['City']; echo '&nbsp&nbsp'; echo $row['Postcode']; echo '&nbsp&nbsp'; echo $row['Contact_No']; echo '&nbsp&nbsp'; echo $row['Email']; echo '&nbsp&nbsp'; echo $row['Additional_Comment']; echo '</b>'; } and a snippet of the code I am using to send the id to the form: echo "<td><a href='pv.php?action=edit&id=" . $row['ID']."'>Edit</a>&nbsp&nbsp<a href='pv.php?action=delete_ok&id=" . $row['ID']."'>Delete</a>&nbsp&nbsp<a href='pv.php?action=comment&id=" . $row['ID']."'>Comment</a></td>"; echo "</tr>";
  8. <!--PHP Update--> <?php $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("project1", $con); if ($_GET['action']=='delete_ok'){ }elseif ($_GET['action']=='edit_ok'){ } switch($_GET['action']){ case 'write_ok': case 'edit_ok': case 'comment_ok'; $error=false; $msg=''; if($_POST['dateofbirth']=='' || !preg_match( "/^(19|20)\d\d[- \\.](0[1-9]|1[012])[- \\.](0[1-9]|[12][0-9]|3[01])$/",$_POST['dateofbirth'])){ $error=true; $msg.='Date of birth is required and in the correct format 0000.00.00\n'; } if($_POST['gender']==''){ $error=true; $msg.='Gender is a required field\n'; } if($_POST['title']==''){ $error=true; $msg.='Please select your title\n'; } if($_POST['firstname']==''){ $error=true; $msg.='Please Enter your First Name\n'; } if($_POST['lastname']==''){ $error=true; $msg.='Please Enter your Last Name\n'; } if($_POST['address1']==''){ $error=true; $msg.='Please Enter the first line of your address\n'; } if($_POST['city']==''){ $error=true; $msg.='Please Enter your city of residence\n'; } if($_POST['postcode']==''|| !preg_match( "/^([A-PR-UWYZ0-9][A-HK-Y0-9][AEHMNPRTVXY0-9]?[ABEHMNPRVWXY0-9]? {1,2}[0-9][ABD-HJLN-UW-Z]{2}|GIR 0AA)$/",$_POST['postcode'])){ $error=true; $msg.='Please Enter a Valid Postcode\n'; } if($_POST['contactno']==''|| !preg_match( "/^((\+44\s?\d{4}|\(?\d{5}\)?)\s?\d{6})|((\+44\s?|0)7\d{3}\s?\d{6})$/",$_POST['contactno'])){ $error=true; $msg.='Please Enter your Contact No\n'; } if($_POST['email']==''|| !preg_match( "/^([a-z0-9])(([-.]|[]+)?([a-z0-9]+))(@)([a-z0-9])((([-]+)?([a-z0-9]+))?)*((.[a-z]{2,3})?(.[a-z]{2,6}))$/",$_POST['email'])){ $error=true; $msg.='Please Enter a Valid Email Address\n'; } if($error){ echo '<script>alert("'.$msg.'");history.back()</script>'; // echo '<meta http-equiv="Refresh" content="0;URL=pv.php?action=write">'; }else{ if ($_GET['action']=='write_ok'){ $sql = "INSERT INTO project_data (Date_Of_Birth, Gender, Title, First_Name, Last_Name, Address_Line_1, Address_Line_2, City, Postcode, Contact_No, Email, Additional_Comment) VALUES ('".$_POST[dateofbirth]."','".$_POST[gender]."','".$_POST[title]."','".$_POST[firstname]."','".$_POST[lastname]."','".$_POST[address1]."','".$_POST[address2]."','".$_POST[city]."','".$_POST[postcode]."','".$_POST[contactno]."','".$_POST[email]."','".$_POST[note]."')"; if(!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } else{ echo '<script>alert("Data Has Been Successfully Updated");</script>'; echo '<meta http-equiv="Refresh" content="0;URL=pv.php">'; } }elseif($_GET['action']=='edit_ok'){ $id = $_GET['id']; mysql_query("UPDATE project_data SET Date_Of_Birth='".$_POST[dateofbirth]."',Gender='".$_POST[gender]."',Title='".$_POST[title]."',First_Name='".$_POST[firstname]."',Last_Name='".$_POST[lastname]."',Address_Line_1='".$_POST[address1]."',Address_Line_2='".$_POST[address2]."',City='".$_POST[city]."',Postcode='".$_POST[postcode]."',Contact_No='".$_POST[contactno]."',Email='".$_POST[email]."',Additional_Comment='".$_POST[note]."' WHERE ID='".$_GET['id']. "'") or die ("Error in query: $query. " . mysql_error()); echo '<script>alert("Data Has Been Successfully Updated");</script>'; echo '<meta http-equiv="Refresh" content="0;URL=pv.php">'; }elseif($_GET['action']=='comment_ok'){ } } break; break; case 'delete_ok': #########Delete OK Start################# $id= $_GET['id']; $result = mysql_query("DELETE FROM project_data WHERE ID = '$id'") or die ("Error in query: $query. " . mysql_error()); echo '<script>alert("Data Has Been Successfully Updated");</script>'; echo '<meta http-equiv="Refresh" content="0;URL=pv.php">'; #########Delete OK End ################# break; break; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> <title>pv.php</title> <link rel="stylesheet" type="text/css" media="screen" href="css/screen.css" /> <style type="text/css"> #commentForm { width: 500px; } #commentForm label { width: 250px; } #commentForm label.error, #commentForm input.submit { margin-left: 253px; color:red;} .paginate { font-family:Arial, Helvetica, sans-serif; padding: 3px; margin: 3px; } .paginate a { padding:2px 5px 2px 5px; margin:2px; border:1px solid #999; text-decoration:none; color: #666; } .paginate a:hover, .paginate a:active { border: 1px solid #999; color: #000; } .paginate span.current { margin: 2px; padding: 2px 5px 2px 5px; border: 1px solid #999; font-weight: bold; background-color: #999; color: #FFF; } .paginate span.disabled { padding:2px 5px 2px 5px; margin:2px; border:1px solid #eee; color:#DDD; } li{ padding:4px; margin-bottom:3px; background-color:#FCC; list-style:none;} ul{margin:6px; padding:0px;} </style> </head> <body> <?php switch($_GET['action']){ case 'delete': break; case 'edit': case 'write': case 'comment': if($_GET['action']=='edit'){ $form_action = 'edit_ok'; echo 'Edit Page'; }else{ $form_action = 'write_ok'; echo ''; } if($_GET['action']=='comment'){ $form_action = 'comment_ok'; echo 'New Comment'; } ?> <?php $id=$_GET['id']; $result = mysql_query("SELECT * FROM project_data WHERE id='$id'"); $row = mysql_fetch_array($result); ?> <form method="post" action="pv.php?id=<?php echo $row['ID']?>&action=<?php echo $form_action ?>"> <fieldset> <legend></legend> <p> <label for="cname">Date Of Birth</label> * <input id="cname" name="dateofbirth" class="required date" value="<?php echo $row['Date_Of_Birth']?>" /> (eg 1978.11.11) </p> <p> <label for="cgender">Gender</label> * <input type="radio" name="gender" value="Male" <?php if($row['Gender']=='male'){echo 'checked';}?>/> Male <input type="radio" name="gender" value="Female" <?php if($row['Gender']=='female'){echo 'checked';}?>/> Female </td> </p> <p> <label for="curl">Title</label> * <select name="title" id="title" class="required"> <option value="">Please Select</option> <option value="Mr" <?php if($row['Title']=='Mr'){echo 'selected';}?>>Mr</option> <option value="Ms" <?php if($row['Title']=='Ms'){echo 'selected';}?>>Ms</option> <option value="Mrs" <?php if($row['Title']=='Mrs'){echo 'selected';}?>>Mrs</option> <option value="Miss" <?php if($row['Title']=='Miss'){echo 'selected';}?>>Miss</option> <option value="Other" <?php if($row['Title']=='Other'){echo 'selected';}?>>Other</option> </select> </p> <p> <label for="ccomment">First Name</label> * <input type="text" name="firstname" value="<?php echo $row['First_Name']?>" maxlength="50" /> </p> <p> <label for="cemail">Last Name</label> * <input id="cemail" type="text" name="lastname" value="<?php echo $row['Last_Name']?>" maxlength="75" /> </p> <p> <label for="ccomment">Address 1</label>* <input type="text" name="address1" value="<?php echo $row['Address_Line_1']?>" maxlength="50" /> </p> <p> <label for="ccomment">Address 2</label> <input type="text" name="address2" value="<?php echo $row['Address_Line_2']?>" maxlength="50" /> </p> <p> <label for="ccomment">City</label>* <input type="text" name="city" value="<?php echo $row['City']?>" maxlength="50" /> </p> <p> <label for="ccomment">Postcode</label>* <input type="text" name="postcode" value="<?php echo $row['Postcode']?>" maxlength= "10" /> (eg LE5 5QE) </p> <p> <label for="ccomment">Contact No</label>* <input type="text" name="contactno" value="<?php echo $row['Contact_No']?>" maxlength= "12" /> (eg 077448825723) </p> <p> <label for="ccomment">Email</label>* <input type="text" name="email" value="<?php echo $row['Email']?>" maxlength= "40"/> (eg info@example.com) </p> <p> <label for="ccomment">Comment</label> <textarea rows="10" cols="30" name="note" maxlength= "500"><?php echo $row['Additional_Comment']?></textarea> </p> <p> <input class="submit" type="submit" value="Submit"/> </p> <p> <a href='pv.php'>Main Page</a> </p> </fieldset> </form> <?php break; //case 'write'; ?> <!--<table border = "1"> <form action="pv.php?action=write_ok" method="post"> <table> <tr> <td>Date Of Birth</td> <td><input type="text" name="dateofbirth" /></td> </tr> <tr> <td>Gender</td> <td><input type="radio" name="gender" value="male" />Male<input type="radio" name="gender" value="female" /> Female</td> </tr> <tr> <td>Title</td> <td><select name="title"> <option value="" selected="selcted">Please Select</option> <option value="Mr">Mr</option> <option value="Mrs">Mrs</option> <option value="Miss">Miss</option> <option value="Ms">Ms</option> <option value="Other">Other</option> </select></td> </tr> <tr> <td>First Name</td> <td><input type="text" name="firstname" /></td> </tr> <tr> <td>Last Name</td> <td><input type="text" name="lastname" /></td> </tr> <tr> <td>Address Line 1</td> <td><input type="text" name="address1" /></td> </tr> <tr> <td>Address Line 2</td> <td><input type="text" name="address2" /></td> </tr> <tr> <td>City</td> <td><input type="text" name="city" /></td> </tr> <tr> <td>Postcode</td> <td><input type="text" name="postcode" /></td> </tr> <tr> <td>Contact No</td> <td><input type="text" name="contactno" /></td> </tr> <tr> <td>Email</td> <td><input type="text" name="email" /></td> </tr> <tr> <td>Additional Info</td> <td><textarea rows="15" cols="30" name="note">Please Enter Any Additional Information</textarea></td> </tr> <tr> <td><input type="submit" value="Submit"></td> <td><a href='pv.php'>Back</a></td> </tr> </table> </form>--> <?php //break; default: ?> <style type="text/css"> </style> <?php echo "<table border='1'> <tr bgcolor ='#FFFACD'> <th>ID</th> <th>Date Of Birth</th> <th>Gender</th> <th>Title</th> <th>First Name</th> <th>Last Name</th> <th>Address Line 1</th> <th>Address Line 2</th> <th>City</th> <th>Postcode</th> <th>Contact No</th> <th>Email</th> <th>Additional Info</th> <th>Action</th> </tr>"; $tbl_name="project_data"; //your table name // How many adjacent pages should be shown on each side? $adjacents = 1; /* First get total number of rows in data table. If you have a WHERE clause in your query, make sure you mirror it here. */ $query = "SELECT COUNT(*) as num FROM $tbl_name"; $total_pages = mysql_fetch_array(mysql_query($query)); $total_pages = $total_pages[num]; /* Setup vars for query. */ $targetpage = "pv.php"; //your file name (the name of this file) $limit = 3; //how many items to show per page $page = $_GET['page']; if($page) $start = ($page - 1) * $limit; //first item to display on this page else $start = 0; //if no page var is given, set start to 0 /* Get data. order by ? group parent level */ $sql = "SELECT * FROM project_data LIMIT $start, $limit"; $result = mysql_query($sql); /* Setup page vars for display. */ if ($page == 0) $page = 1; //if no page var is given, default to 1. $prev = $page - 1; //previous page is page - 1 $next = $page + 1; //next page is page + 1 $lastpage = ceil($total_pages/$limit); //lastpage is = total pages / items per page, rounded up. $lpm1 = $lastpage - 1; //last page minus 1 /* Now we apply our rules and draw the pagination object. We're actually saving the code to a variable in case we want to draw it more than once. */ $pagination = ""; if($lastpage > 1) { $pagination .= "<div class=\"pagination\">"; //previous button if ($page > 1) $pagination.= " <a href=\"$targetpage?page=$prev\">« previous</a> "; else $pagination.= " <span class=\"disabled\">« previous</span> "; //pages if ($lastpage < 7 + ($adjacents * 2)) //not enough pages to bother breaking it up { for ($counter = 1; $counter <= $lastpage; $counter++) { if ($counter == $page) $pagination.= " <span class=\"current\">$counter</span >"; else $pagination.= " <a href=\"$targetpage?page=$counter\">$counter</a> "; } } elseif($lastpage > 5 + ($adjacents * 2)) //enough pages to hide some { //close to beginning; only hide later pages if($page < 1 + ($adjacents * 2)) { for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++) { if ($counter == $page) $pagination.= " <span class=\"current\">$counter</span> "; else $pagination.= " <a href=\"$targetpage?page=$counter\">$counter</a> "; } $pagination.= "..."; $pagination.= "<a href=\"$targetpage?page=$lpm1\">$lpm1</a>"; $pagination.= "<a href=\"$targetpage?page=$lastpage\">$lastpage</a>"; } //in middle; hide some front and some back elseif($lastpage - ($adjacents * 2) > $page && $page > ($adjacents * 2)) { $pagination.= "<a href=\"$targetpage?page=1\">1</a>"; $pagination.= "<a href=\"$targetpage?page=2\">2</a>"; $pagination.= "..."; for ($counter = $page - $adjacents; $counter <= $page + $adjacents; $counter++) { if ($counter == $page) $pagination.= "<span class=\"current\">$counter</span>"; else $pagination.= "<a href=\"$targetpage?page=$counter\">$counter</a>"; } $pagination.= "..."; $pagination.= "<a href=\"$targetpage?page=$lpm1\">$lpm1</a>"; $pagination.= "<a href=\"$targetpage?page=$lastpage\">$lastpage</a>"; } //close to end; only hide early pages else { $pagination.= "<a href=\"$targetpage?page=1\">1</a>"; $pagination.= "<a href=\"$targetpage?page=2\">2</a>"; $pagination.= "..."; for ($counter = $lastpage - (2 + ($adjacents * 2)); $counter <= $lastpage; $counter++) { if ($counter == $page) $pagination.= "<span class=\"current\">$counter</span>"; else $pagination.= "<a href=\"$targetpage?page=$counter\">$counter</a>"; } } } //next button if ($page < $counter - 1) $pagination.= "<a href=\"$targetpage?page=$next\">next »</a>"; else $pagination.= "<span class=\"disabled\">next »</span>"; $pagination.= "</div>\n"; } //$result = mysql_query("SELECT * FROM $tbl_name"); while($row = mysql_fetch_array($result)){ echo "<tr>"; echo "<td>" . $row['ID'] . "</td>"; echo "<td>" . $row['Date_Of_Birth'] . "</td>"; echo "<td>" . $row['Gender'] . "</td>"; echo "<td>" . $row['Title'] . "</td>"; echo "<td>" . $row['First_Name'] . "</td>"; echo "<td>" . $row['Last_Name'] . "</td>"; echo "<td>" . $row['Address_Line_1'] . "</td>"; echo "<td>" . $row['Address_Line_2'] . "</td>"; echo "<td>" . $row['City'] . "</td>"; echo "<td>" . $row['Postcode'] . "</td>"; echo "<td>" . $row['Contact_No'] . "</td>"; echo "<td>" . $row['Email'] . "</td>"; echo "<td>" . $row['Additional_Comment'] . "</td>"; echo "<td><a href='pv.php?action=edit&id=" . $row['ID']."'>Edit</a>&nbsp&nbsp<a href='pv.php?action=delete_ok&id=" . $row['ID']."'>Delete</a>&nbsp&nbsp<a href='pv.php?action=comment'>Comment</a></td>"; echo "</tr>"; } echo "</table>"; echo $pagination; echo "<a href='pv.php?action=write'>Insert</a>"; } mysql_close($con); ?> </body> </html> I have a link which is for a comment page, it takes me to a blank form when I click it on the current record. But what I want it to do is show the record that i clicked on, to show at the top of the page, my mind has gone completely blank. if($_GET['action']=='comment'){ $form_action = 'comment_ok'; echo 'should be something here'; Anyone have any idea?
  9. I need something with a little less lines, the code I have right now is a little too long. Anyone have any suggestions?
  10. Thanks for that. But has anyone got something with less lines?
  11. <table> <tr> <td align="center"> <?PHP $b = 1; for($a = 1; $a <= 26; $a++){ if($a == 1) echo $a ."<br />"; if($a == 2 || $ == 3) echo $a; if($a == 4) echo $a ."<br />"; } ?> </td> </tr> </table>
  12. <table> <tr> <td align="center"> <?PHP $b = 1; for ($a=1; $a<=1; $a++) { echo $b++; echo "<br>"; } $b = 2; for ($a=1; $a<=2; $a++) { echo $b++; } echo "<br>"; $b = 4; for ($a=1; $a<=3; $a++) { echo $b++; } echo "<br>"; $b = 7; for ($a=1; $a<=5; $a++) { echo $b++; } echo "<br>"; $b = 12; for ($a=1; $a<=5; $a++) { echo $b++; } echo "<br>"; $b = 17; for ($a=1; $a<=4; $a++) { echo $b++; } echo "<br>"; $b = 21; for ($a=1; $a<=3; $a++) { echo $b++; } echo "<br>"; $b = 24; for ($a=1; $a<=2; $a++) { echo $b++; } echo "<br>"; $b = 26; for ($a=1; $a<=1; $a++) { echo $b++; } ?> </td> </tr> </table> This is still the code I am using, the one you gave earlier came up with the unexpected error.
  13. anyone have any more clues?
  14. ( ! ) Parse error: syntax error, unexpected T_IS_EQUAL, expecting T_VARIABLE or '$' in C:\wamp\www\p1\m2.php on line 10 that is what's showing.
  15. nope that didnt work mate>
  16. <table> <tr> <td align="center"> <?PHP $b = 1; for ($a=1; $a<=1; $a++) { echo $b++; echo "<br>"; } $b = 2; for ($a=1; $a<=2; $a++) { echo $b++; } echo "<br>"; $b = 4; for ($a=1; $a<=3; $a++) { echo $b++; } echo "<br>"; $b = 7; for ($a=1; $a<=5; $a++) { echo $b++; } echo "<br>"; $b = 12; for ($a=1; $a<=5; $a++) { echo $b++; } echo "<br>"; $b = 17; for ($a=1; $a<=4; $a++) { echo $b++; } echo "<br>"; $b = 21; for ($a=1; $a<=3; $a++) { echo $b++; } echo "<br>"; $b = 24; for ($a=1; $a<=2; $a++) { echo $b++; } echo "<br>"; $b = 26; for ($a=1; $a<=1; $a++) { echo $b++; } ?> </td> </tr> </table> Okay, I figured it out, well kind of, but I need to reduce the amount of line have. Any ideas?
  17. <table> <tr> <td align="center"> <?PHP $b = 1; for ($a=1; $a<=16; $a++) { echo str_repeat($a, $b); $b++; echo "<br>"; } $b = 17; for ($a=17; $a<=26; $a++) { echo str_repeat($a, $b); $b++; echo "<br>"; } ?> </td> </tr> </table> I am trying to make something like this: 1 23 456 7891011 1213141516 17181920 212223 2425 26 But i have managed what I've shown above. Anyone have any help on this? (slightly updated)
  18. <table> <tr> <td align="center"> <?PHP $b = 1; for ($a=1; $a<=16; $a++) { echo str_repeat($a, $b); $b++; echo "<br>"; } $b = 17; for ($a=1; $a<=26; $a++) { echo str_repeat($a, $b); $b--; echo "<br>"; } ?> </td> </tr> </table> I am trying to make something like this: 1 23 456 7891011 1213141516 17181920 212223 2425 26 But i have managed what I've shown above. Anyone have any help on this?
  19. I asked for help, not how to do it.
  20. yeah are you going to give me an idea?
  21. <table> <tr> <td align="center"> <?PHP $b = 1; for ($a=1; $a<=10; $a++) { echo str_repeat('*', $b); $b++; echo "<br>"; } $b = 9; for ($a=1; $a<=9; $a++) { echo str_repeat('*', $b); $b--; echo "<br>"; } ?> </td> </tr> </table> this is the code for the asterix shape.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.