Jump to content

dawsba

Members
  • Posts

    180
  • Joined

  • Last visited

    Never

About dawsba

  • Birthday 05/16/1979

Contact Methods

  • Website URL
    http://www.webdesignukltd.com

Profile Information

  • Gender
    Male
  • Location
    London

dawsba's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. you could try this $result1 = $db->query('ALTER TABLE `'.$db->prefix.'users` DROP `id`;') or error('Unable to fetch total user count', __FILE__, __LINE__, $db->error()); $result2 = $db->query('ALTER TABLE `'.$db->prefix.'users` AUTO_INCREMENT = 1;') or error('Unable to fetch total user count', __FILE__, __LINE__, $db->error()); $result3 = $db->query('ALTER TABLE `'.$db->prefix.'users` ADD `id` int UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST;') or error('Unable to fetch total user count', __FILE__, __LINE__, $db->error()); $result = $db->query('SELECT COUNT(id) FROM '.$db->prefix.'users') or error('Unable to fetch total user count', __FILE__, __LINE__, $db->error()); $stats['total_users'] = $db->result($result);
  2. not 100% sure what you mean are you looking to have an add qty button to add multiple items, perhaps ajax? or a refresh each time they click add item: in which case i would structure your session array alittle different and add qty to the fields ie: if (!isset($_session['cart'])) $_SESSION["cart"]= '$id' ; if (isset($_POST['id']) &&!empty($_POST['id']) && isset($_POST['cost']) &&!empty($_POST['cost'])) { $id = $_POST['id']; $cost = $_POST['cost']; if($_SESSION['cart'][$id][qty]>0) { $_SESSION['cart'][$id][qty]++; } else { $_SESSION['cart'][$id][cost]=$cost); $_SESSION['cart'][$id][qty]=1; } foreach($_SESSION['cart'] as $key => $arr){ echo $key . ' '. $arr[cost].' '.$arr[qty].' TOTAL:$pound;'.number_format($arr[qty]*$arr[cost],2)); } } echo '<pre>'; print_r($_SESSION); echo '</pre>';
  3. you could try add ing limit 1 to the end of your sql $query = "SELECT id, firstname FROM `Members` WHERE id={$_SESSION['id']} LIMIT 1"; also are you actually getting the session variable correctly, can you echo the value to check against the id's
  4. <?php $search_chars = array(); for($i=128;$i<=255;$i++){array_push($search_chars,$i);} $string = "the lazy brown d..…"; $orig = $string; function strpos_chararray($haystack, $needles) { if(is_array($needles)) { foreach($needles as $key => $str) { if(is_numeric($str)){$str = chr($str);} if(is_array($str)) { $pos = strpos_array($haystack, $str); } else { $pos = strpos($haystack, $str); } if ($pos !== FALSE) { return $pos; } } if ($pos === FALSE) { return FALSE; } } else { return strpos($haystack, $needles); } } function rebuild($string) { global $search_chars; $str = explode(' ',$string); foreach($str as $str_bit) { $chk = strpos_chararray($str_bit, $search_chars); if($chk === FALSE) { $new_str .= ' '.$str_bit; } else{break;} } return $new_str; } if(strpos_chararray($string, $search_chars)) { $string = rebuild($string); } echo "ORIGINAL >> ".$orig."<br>"; echo "NEW >> ".$string."<br>"; ?>
  5. <?php function q($query,$assoc=1) { $r = @mysql_query($query); if( mysql_errno() ) { $error = "<script>window.location='?ref=0'</script>";//'MYSQL ERROR #'.mysql_errno().' : <small>' . mysql_error(). '</small><br><VAR>$query</VAR>'; echo($error); return FALSE; } if( strtolower(substr($query,0,6)) != 'select' ) return array(mysql_affected_rows(),mysql_insert_id()); $count = @mysql_num_rows($r); if( !$count ) return 0; if( $count == 1 ) { if( $assoc ) $f = mysql_fetch_assoc($r); else $f = mysql_fetch_row($r); mysql_free_result($r); if( count($f) == 1 ) { list($key) = array_keys($f); return $f[$key]; } else { $all = array(); $all[] = $f; return $all; } } else { $all = array(); for( $i = 0; $i < $count; $i++ ) { if( $assoc ) $f = mysql_fetch_assoc($r); else $f = mysql_fetch_row($r); $all[] = $f; } mysql_free_result($r); return $all; } } $sql = "SELECT * FROM `calendar`"; $result2 = mysql_db_query(YOURDATABASE,$sql,YOURLINK) or die("Invalid Query<br>". mysql_error()); while ($r3 = mysql_fetch_array($result2)) { $new_id = q("INSERT INTO `games` (game_id,sport,day,visitor,home,start,field,notes,level)VALUES('','".$r3[sport]."','".$r3[date]."','".$r3[visitor]."','".$r3[home]."','$r3[time]','".$r3[field]."','".$r3[notes]."','".$r3[level]."')"); $new_id = $new_id[0]; for($i=1;$i<=5;$i++) { q("INSERT INTO `scheduled_umps` (row,game_id,ump)VALUES('','".$new_id."','".$r3['ump'.$i]."')"); } } ?>
  6. your bouncing away with the header, try using sessions session_start(); //must be the first item on script! and on every script!!!!!! $_SESSION['mytext']=$_POST['text']; //before your header bounce :inplace of $text=$_POST[text]; <?php session_start(); include_once('../index.html'); echo "Hello, your text was " . $_SESSION['mytext'] . "!"; ?>
  7. are you asking for the data to dynamically appear on the page? if so you will need to include elements of javascript/ajax create the list as normal, in the select add onChange with your js function have the ajax bounce to anouther script to gather the data about the car etc and display in a hidden div have a look here, this should help you loads http://www.switchonthecode.com/tutorials/simple-ajax-php-and-javascript
  8. you should read alittle about understanding arrays ie:http://www.howtoforge.com/php_arrays <?php $users=array(); $users['user1']=array('email'=>'bob@bob.com','password'=>'mypass'); $users['user2']=array('email'=>'bob2@bob2.com','password'=>'mypass2'); //so if you get a new user $newusername = 'user3'; $newemail = 'user@bob.com'; $newpassword = 'ilikesprouts'; $users[$newusername]=array('email'=>$newemail,'password'=>$newpassword); ?>
  9. heres some code i wrote awhile ago, it'll need some cleaning and you'll have to work some bits out html: <? if(!isset($iiX)){$iiX=1;} ?> <form name="memnum" action="?ref=<?= $iiX; ?><?= $eXtra; ?>" enctype="multipart/form-data" method="post"> <table align="center"> <tr> <td colspan="3"><center><p><?= $title; ?></p></center></td> </tr> <tr> <td colspan="3"> <? if(strtolower($kspecial) != 'password'){$kspecial = 'text';} ?> <input type="<?= $kspecial; ?>" name="pad" id="rfid" class="memnumfield" width="32" height="30"/> </td> </tr> <script> document.memnum.pad.focus(); document.memnum.pad.select(); </script> <? for($i = 1; $i <= 10; $i++) { if($i == 10 || $i == 7 || $i == 4 || $i == 1) { echo "<tr>"; } if($i == 10) { echo " <td> <input name=submitmem type=\"submit\" class=\"keypad_button\" value=\"ENTER\"> </td> <td align=center> <input type=\"button\" class=\"keypad_button\" name=\"0\" value=\"0\" onclick=\"document.memnum.pad.value = document.memnum.pad.value+'0'\" onclick=\"goCheck(this)\"> </td> <td> <input type=\"button\" class=\"keypad_button\" value=\"RESET\" onclick=\"document.memnum.pad.value = ''\"> </td> "; } else { echo " <td> <input type=\"button\" class=\"keypad_button\" size=\"22\" name=\"".$i."\" value=\"".$i."\" onclick=\"document.memnum.pad.value = document.memnum.pad.value+'".$i."'\" onclick=\"goCheck(this)\"> </td> "; } if($i == 9 || $i == 6 || $i == 3 || $i == 10){echo "</tr>";} } echo " <td colspan=\"3\"> <input type=\"button\" class=\"keypad_button\" size=\"66\" name=\"Cancel\" value=\"Cancel\" style=\"width:335px; height:35px;\" onclick=\"window.location='?ref=0'\"> </td> "; ?> <tr><td colspan="3"> </td></tr> </table> </form>
  10. at the top of the script just add $count=0;
  11. set it to a html array and on post spin through the keys <?php if (isset($_POST['submitted'])) { include('connect1.php'); $category = $_POST['category']; $criteria = $_POST['criteria'] ; $query = ("SELECT name, badges, rank, userid FROM members WHERE $category LIKE '%".$criteria."%'"); $result = mysqli_query($dbcon, $query) or die('error getting data'); $num_rows = mysqli_num_rows($result); echo "$num_rows results found"; echo "<table width=\"896\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"; echo "<tr bgcolor=\"#F7E496\"><td bgcolor=\"#F7E496\"><strong>name</strong></td><td bgcolor=\"#F7E496\" ><strong>Merit Badges</strong></td><td bgcolor=\"#F7E496\"><strong>Rank</strong></td><td bgclor=\"#F7E496\"></td></tr>"; while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {$color = ($color == 'white')?'#fffccc':'white'; echo "<tr bgcolor='$color'><td> <input type=\"text\" name=\"userid\" id=\"userid\" value='".$row['userid']."'>"; echo $row['name']; echo " </td><td> <form action=\"scout.php\" method=\"post\"> <textarea name=\"badges[color=red][".$row['userid']."][/color]\" id=\"badges\" cols=\"40\" rows=\"3\" type=\"textarea\">".$row['badges']."</textarea></td><td> <span class=\"adfa\"> </span> <select name=\"rank[color=red][".$row['userid']."][/color]\" id=\"rank\"> <option value=\"Scout\">Scout</option> <option value=\"Tenderfoot\">Tenderfoot</option> <option value=\"Second Class Scout\">Second Class Scout</option> <option value=\"First Class Scout\">First Class Scout</option> <option value=\"Star Scout\">Star Scout</option> <option value=\"Life Scout\">Life Scout</option> <option value=\"Eagle Scout\">Eagle Scout</option> <option value=\"\" selected=\"selected\">".$row['rank']."</option> </td><td>"; echo "<input type=\"submit\" name=\"submit\" id=\"submit\" value=\"Save\" /> "; echo "</form>"; } echo "</table>"; echo "</td></tr>"; } ?> and on the post side <?php session_start(); // Must start session first thing /* Created By Adam Khoury @ [url=http://'http://www.flashbuilding.com/']www.flashbuilding.com[/url] -----------------------June 20, 2008----------------------- */ // Here we run a login check if (!isset($_SESSION['id'])) { echo 'Please <a href="login.php">log in</a> to access your account'; exit(); } //Connect to the database through our include include_once "connect_to_mysql.php"; // Place Session variable 'id' into local variable $userid = $_SESSION['id']; // Query member data from the database and ready it for display // Process the form if it is submitted if ($_POST['submit']) { $PS = $_POST['submit']; if(is_array($PS)) { foreach($PS as $user_id=>$type) { $badges=$type[badges]; $rand = $type[rank]; //user_id is now defined spin sql $sql = mysql_query("UPDATE members SET badges='$badges', rank='$rank' WHERE userid='".$user_id."'"); printf("Records updated: %d\n", mysql_affected_rows()) } } exit(); } // close if post ?> not tested but should give u a start
  12. foreach($users_associates as $is_associate) { if (($is_associate['user_id'] != $user_info['uid'])&&$count<=0) { $count++; ?> <li class="bass"> <a href="" title="Become Associates" id="becomeassoc" class="mll"> <span class="f_right">Become Associates</span><img src="../assets/img/becomeassoc.jpg" class="mrs vmiddle" alt="Become Associates" /> </a> </li> <?php } }
  13. Learn the language, then you wont need to frankenstein code in places; i buy this book for my students: http://www.amazon.co.uk/Sams-Teach-Yourself-MySQL-Apache/dp/0672328739 good luck
  14. i have no idea why you would want to, but hey cool lol i think youd be better using sessions as they transcend the refresh <?php session_start(); $urna=array(0,1,2,3,4,5,6,7,8,9,"a","b","c","d","e","f"); $cs="#"; if($_SESSION['hit']>=4) { for ($i=1; $i<=6; $i++) { $b .= $urna[rand(0,15)]; } $_SESSION['culoare'] = $cs.$b; } else { $_SESSION['hit']++; } ?> <body bgcolor="<?php echo $_SESSION['culoare']; ?>"> <form method=post> <input type="submit" name="submit" value="Schimba culoarea" /> </form>
  15. your forgetting enctype="multipart/form-data" in your form html
×
×
  • 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.